diff options
Diffstat (limited to 'flags/tests/parse.ts')
| -rwxr-xr-x | flags/tests/parse.ts | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/flags/tests/parse.ts b/flags/tests/parse.ts index d6a1be709..d58c67029 100755 --- a/flags/tests/parse.ts +++ b/flags/tests/parse.ts @@ -1,17 +1,18 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { test, assertEqual } from "../../testing/mod.ts"; +import { test } from "../../testing/mod.ts"; +import { assertEq } from "../../testing/asserts.ts"; import { parse } from "../mod.ts"; test(function _arseArgs() { - assertEqual(parse(["--no-moo"]), { moo: false, _: [] }); - assertEqual(parse(["-v", "a", "-v", "b", "-v", "c"]), { + assertEq(parse(["--no-moo"]), { moo: false, _: [] }); + assertEq(parse(["-v", "a", "-v", "b", "-v", "c"]), { v: ["a", "b", "c"], _: [] }); }); test(function comprehensive() { - assertEqual( + assertEq( parse([ "--name=meowmers", "bare", @@ -49,8 +50,8 @@ test(function comprehensive() { test(function flagBoolean() { const argv = parse(["-t", "moo"], { boolean: "t" }); - assertEqual(argv, { t: true, _: ["moo"] }); - assertEqual(typeof argv.t, "boolean"); + assertEq(argv, { t: true, _: ["moo"] }); + assertEq(typeof argv.t, "boolean"); }); test(function flagBooleanValue() { @@ -59,63 +60,63 @@ test(function flagBooleanValue() { default: { verbose: true } }); - assertEqual(argv, { + assertEq(argv, { verbose: false, t: true, _: ["moo"] }); - assertEqual(typeof argv.verbose, "boolean"); - assertEqual(typeof argv.t, "boolean"); + assertEq(typeof argv.verbose, "boolean"); + assertEq(typeof argv.t, "boolean"); }); test(function newlinesInParams() { const args = parse(["-s", "X\nX"]); - assertEqual(args, { _: [], s: "X\nX" }); + assertEq(args, { _: [], s: "X\nX" }); // reproduce in bash: // VALUE="new // line" // deno program.js --s="$VALUE" const args2 = parse(["--s=X\nX"]); - assertEqual(args2, { _: [], s: "X\nX" }); + assertEq(args2, { _: [], s: "X\nX" }); }); test(function strings() { const s = parse(["-s", "0001234"], { string: "s" }).s; - assertEqual(s, "0001234"); - assertEqual(typeof s, "string"); + assertEq(s, "0001234"); + assertEq(typeof s, "string"); const x = parse(["-x", "56"], { string: "x" }).x; - assertEqual(x, "56"); - assertEqual(typeof x, "string"); + assertEq(x, "56"); + assertEq(typeof x, "string"); }); test(function stringArgs() { const s = parse([" ", " "], { string: "_" })._; - assertEqual(s.length, 2); - assertEqual(typeof s[0], "string"); - assertEqual(s[0], " "); - assertEqual(typeof s[1], "string"); - assertEqual(s[1], " "); + assertEq(s.length, 2); + assertEq(typeof s[0], "string"); + assertEq(s[0], " "); + assertEq(typeof s[1], "string"); + assertEq(s[1], " "); }); test(function emptyStrings() { const s = parse(["-s"], { string: "s" }).s; - assertEqual(s, ""); - assertEqual(typeof s, "string"); + assertEq(s, ""); + assertEq(typeof s, "string"); const str = parse(["--str"], { string: "str" }).str; - assertEqual(str, ""); - assertEqual(typeof str, "string"); + assertEq(str, ""); + assertEq(typeof str, "string"); const letters = parse(["-art"], { string: ["a", "t"] }); - assertEqual(letters.a, ""); - assertEqual(letters.r, true); - assertEqual(letters.t, ""); + assertEq(letters.a, ""); + assertEq(letters.r, true); + assertEq(letters.t, ""); }); test(function stringAndAlias() { @@ -124,25 +125,25 @@ test(function stringAndAlias() { alias: { s: "str" } }); - assertEqual(x.str, "000123"); - assertEqual(typeof x.str, "string"); - assertEqual(x.s, "000123"); - assertEqual(typeof x.s, "string"); + assertEq(x.str, "000123"); + assertEq(typeof x.str, "string"); + assertEq(x.s, "000123"); + assertEq(typeof x.s, "string"); const y = parse(["-s", "000123"], { string: "str", alias: { str: "s" } }); - assertEqual(y.str, "000123"); - assertEqual(typeof y.str, "string"); - assertEqual(y.s, "000123"); - assertEqual(typeof y.s, "string"); + assertEq(y.str, "000123"); + assertEq(typeof y.str, "string"); + assertEq(y.s, "000123"); + assertEq(typeof y.s, "string"); }); test(function slashBreak() { - assertEqual(parse(["-I/foo/bar/baz"]), { I: "/foo/bar/baz", _: [] }); - assertEqual(parse(["-xyz/foo/bar/baz"]), { + assertEq(parse(["-I/foo/bar/baz"]), { I: "/foo/bar/baz", _: [] }); + assertEq(parse(["-xyz/foo/bar/baz"]), { x: true, y: true, z: "/foo/bar/baz", @@ -154,19 +155,19 @@ test(function alias() { const argv = parse(["-f", "11", "--zoom", "55"], { alias: { z: "zoom" } }); - assertEqual(argv.zoom, 55); - assertEqual(argv.z, argv.zoom); - assertEqual(argv.f, 11); + assertEq(argv.zoom, 55); + assertEq(argv.z, argv.zoom); + assertEq(argv.f, 11); }); test(function multiAlias() { const argv = parse(["-f", "11", "--zoom", "55"], { alias: { z: ["zm", "zoom"] } }); - assertEqual(argv.zoom, 55); - assertEqual(argv.z, argv.zoom); - assertEqual(argv.z, argv.zm); - assertEqual(argv.f, 11); + assertEq(argv.zoom, 55); + assertEq(argv.z, argv.zoom); + assertEq(argv.z, argv.zm); + assertEq(argv.f, 11); }); test(function nestedDottedObjects() { @@ -181,7 +182,7 @@ test(function nestedDottedObjects() { "--beep.boop" ]); - assertEqual(argv.foo, { + assertEq(argv.foo, { bar: 3, baz: 4, quux: { @@ -189,5 +190,5 @@ test(function nestedDottedObjects() { o_O: true } }); - assertEqual(argv.beep, { boop: true }); + assertEq(argv.beep, { boop: true }); }); |
