Debian Codegraph @

mri/test/num.js

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