Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
909 bytes
|
Rev | Line | |
---|
[6a3a178] | 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 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.