1
|
var parse = require('../');
|
2
|
var test = require('tape');
|
3
|
|
4
|
test('nums', function (t) {
|
5
|
var argv = parse([
|
6
|
'-x', '1234',
|
7
|
'-y', '5.67',
|
8
|
'-z', '1e7',
|
9
|
'-w', '10f',
|
10
|
'--hex', '0xdeadbeef',
|
11
|
'789'
|
12
|
]);
|
13
|
t.deepEqual(argv, {
|
14
|
x : 1234,
|
15
|
y : 5.67,
|
16
|
z : 1e7,
|
17
|
w : '10f',
|
18
|
hex : 0xdeadbeef,
|
19
|
_ : [ 789 ]
|
20
|
});
|
21
|
t.deepEqual(typeof argv.x, 'number');
|
22
|
t.deepEqual(typeof argv.y, 'number');
|
23
|
t.deepEqual(typeof argv.z, 'number');
|
24
|
t.deepEqual(typeof argv.w, 'string');
|
25
|
t.deepEqual(typeof argv.hex, 'number');
|
26
|
t.deepEqual(typeof argv._[0], 'number');
|
27
|
t.end();
|
28
|
});
|
29
|
|
30
|
test('already a number', function (t) {
|
31
|
var argv = parse([ '-x', 1234, 789 ]);
|
32
|
t.deepEqual(argv, { x : 1234, _ : [ 789 ] });
|
33
|
t.deepEqual(typeof argv.x, 'number');
|
34
|
t.deepEqual(typeof argv._[0], 'number');
|
35
|
t.end();
|
36
|
});
|