forked from lukeed/mri
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnum.js
More file actions
36 lines (34 loc) · 701 Bytes
/
num.js
File metadata and controls
36 lines (34 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const test = require('tape');
const fn = require('../lib');
test('nums', t => {
const argv = fn([
'-x', '1234',
'-y', '5.67',
'-z', '1e7',
'-w', '10f',
'--hex', '0xdeadbeef',
'789'
]);
t.same(argv, {
x : 1234,
y : 5.67,
z : 1e7,
w : '10f',
hex : 0xdeadbeef,
_ : ['789']
});
t.is(typeof argv.x, 'number');
t.is(typeof argv.y, 'number');
t.is(typeof argv.z, 'number');
t.is(typeof argv.w, 'string');
t.is(typeof argv.hex, 'number');
t.is(typeof argv._[0], 'string');
t.end();
});
test('already a number', t => {
const argv = fn(['-x', 1234, 789]);
t.same(argv, { x:1234, _:[789] });
t.is(typeof argv._[0], 'number');
t.is(typeof argv.x, 'number');
t.end();
});