mirror of
https://github.com/flynx/argv.js.git
synced 2025-10-28 10:20:09 +00:00
reworking tests...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2641f377d0
commit
889007f85a
69
test.js
69
test.js
@ -15,42 +15,27 @@ var test = require('ig-test')
|
||||
var argv = require('./argv')
|
||||
|
||||
|
||||
var bare = module.bare = require('./examples/bare').parser
|
||||
var options = module.options = require('./examples/options').parser
|
||||
var lang = module.lang = require('./examples/lang').parser
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
test.Setups({
|
||||
bare: require('./examples/bare').parser,
|
||||
options: require('./examples/options').parser,
|
||||
lang: require('./examples/lang').parser,
|
||||
})
|
||||
|
||||
test.Modifiers({
|
||||
})
|
||||
|
||||
test.Tests({
|
||||
})
|
||||
|
||||
|
||||
test.Cases({
|
||||
})
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
argv.Parser.typeHandlers.error = function(){
|
||||
throw new argv.ParserTypeError('type error') }
|
||||
|
||||
|
||||
var p =
|
||||
module.p =
|
||||
argv.Parser({
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
var setups =
|
||||
test.Setups({
|
||||
bare: function(){
|
||||
return require('./examples/bare').parser },
|
||||
options: function(){
|
||||
return require('./examples/options').parser },
|
||||
lang: function(){
|
||||
return require('./examples/lang').parser },
|
||||
|
||||
// NOTE: this will also load .bare, .options and .lang
|
||||
basic: function(assert){
|
||||
return argv.Parser({
|
||||
// disable exit on error...
|
||||
handleErrorExit: false,
|
||||
|
||||
@ -185,10 +170,9 @@ argv.Parser({
|
||||
'-m': '-k',
|
||||
|
||||
|
||||
'@bare': bare,
|
||||
'@opts': options,
|
||||
|
||||
'@lang': lang,
|
||||
'@bare': setups.bare(assert),
|
||||
'@opts': setups.options(assert),
|
||||
'@lang': setups.lang(assert),
|
||||
|
||||
|
||||
// collision test...
|
||||
@ -204,8 +188,17 @@ argv.Parser({
|
||||
.stop(function(){
|
||||
console.log('STOP', ...arguments) })
|
||||
.error(function(){
|
||||
console.log('ERROR', ...arguments) })
|
||||
console.log('ERROR', ...arguments) }) }
|
||||
})
|
||||
|
||||
test.Modifiers({
|
||||
})
|
||||
|
||||
test.Tests({
|
||||
})
|
||||
|
||||
test.Cases({
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
@ -224,10 +217,12 @@ p(['test', 'nested', '-h'])
|
||||
p(['test', '-h'])
|
||||
//*/
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
typeof(__filename) != 'undefined'
|
||||
&& __filename == (require.main || {}).filename
|
||||
&& console.log(p())
|
||||
//&& console.log(lang())
|
||||
&& console.log(setups.basic()())
|
||||
//&& test.run()
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user