2018-12-19 13:06:31 -05:00
|
|
|
import { test, assertEqual } from "https://deno.land/x/testing/testing.ts";
|
2018-12-21 13:02:52 -05:00
|
|
|
import { parse } from "../index.ts";
|
2018-12-19 13:06:31 -05:00
|
|
|
|
|
|
|
test(function nums() {
|
2018-12-21 13:02:52 -05:00
|
|
|
const argv = parse([
|
2018-12-19 13:06:31 -05:00
|
|
|
'-x', '1234',
|
|
|
|
'-y', '5.67',
|
|
|
|
'-z', '1e7',
|
|
|
|
'-w', '10f',
|
|
|
|
'--hex', '0xdeadbeef',
|
|
|
|
'789'
|
|
|
|
]);
|
|
|
|
assertEqual(argv, {
|
|
|
|
x : 1234,
|
|
|
|
y : 5.67,
|
|
|
|
z : 1e7,
|
|
|
|
w : '10f',
|
|
|
|
hex : 0xdeadbeef,
|
|
|
|
_ : [ 789 ]
|
|
|
|
});
|
|
|
|
assertEqual(typeof argv.x, 'number');
|
|
|
|
assertEqual(typeof argv.y, 'number');
|
|
|
|
assertEqual(typeof argv.z, 'number');
|
|
|
|
assertEqual(typeof argv.w, 'string');
|
|
|
|
assertEqual(typeof argv.hex, 'number');
|
|
|
|
assertEqual(typeof argv._[0], 'number');
|
|
|
|
});
|
|
|
|
|
|
|
|
test(function alreadyNumber() {
|
2018-12-21 13:02:52 -05:00
|
|
|
const argv = parse([ '-x', 1234, 789 ]);
|
2018-12-19 13:06:31 -05:00
|
|
|
assertEqual(argv, { x : 1234, _ : [ 789 ] });
|
|
|
|
assertEqual(typeof argv.x, 'number');
|
|
|
|
assertEqual(typeof argv._[0], 'number');
|
|
|
|
});
|