diff options
Diffstat (limited to 'std/flags')
-rwxr-xr-x | std/flags/all_bool_test.ts | 5 | ||||
-rwxr-xr-x | std/flags/bool_test.ts | 29 | ||||
-rwxr-xr-x | std/flags/dash_test.ts | 7 | ||||
-rwxr-xr-x | std/flags/default_bool_test.ts | 7 | ||||
-rwxr-xr-x | std/flags/dotted_test.ts | 7 | ||||
-rwxr-xr-x | std/flags/kv_short_test.ts | 5 | ||||
-rwxr-xr-x | std/flags/long_test.ts | 3 | ||||
-rwxr-xr-x | std/flags/num_test.ts | 5 | ||||
-rwxr-xr-x | std/flags/parse_test.ts | 29 | ||||
-rwxr-xr-x | std/flags/short_test.ts | 9 | ||||
-rwxr-xr-x | std/flags/stop_early_test.ts | 3 | ||||
-rwxr-xr-x | std/flags/unknown_test.ts | 11 | ||||
-rwxr-xr-x | std/flags/whitespace_test.ts | 3 |
13 files changed, 55 insertions, 68 deletions
diff --git a/std/flags/all_bool_test.ts b/std/flags/all_bool_test.ts index d738d1afc..6516f48ed 100755 --- a/std/flags/all_bool_test.ts +++ b/std/flags/all_bool_test.ts @@ -1,10 +1,9 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; // flag boolean true (default all --args to boolean) -test(function flagBooleanTrue(): void { +Deno.test(function flagBooleanTrue(): void { const argv = parse(["moo", "--honk", "cow"], { boolean: true }); @@ -18,7 +17,7 @@ test(function flagBooleanTrue(): void { }); // flag boolean true only affects double hyphen arguments without equals signs -test(function flagBooleanTrueOnlyAffectsDoubleDash(): void { +Deno.test(function flagBooleanTrueOnlyAffectsDoubleDash(): void { const argv = parse(["moo", "--honk", "cow", "-p", "55", "--tacos=good"], { boolean: true }); diff --git a/std/flags/bool_test.ts b/std/flags/bool_test.ts index fd3b6487f..2d6a8b938 100755 --- a/std/flags/bool_test.ts +++ b/std/flags/bool_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function flagBooleanDefaultFalse(): void { +Deno.test(function flagBooleanDefaultFalse(): void { const argv = parse(["moo"], { boolean: ["t", "verbose"], default: { verbose: false, t: false } @@ -19,7 +18,7 @@ test(function flagBooleanDefaultFalse(): void { assertEquals(typeof argv.t, "boolean"); }); -test(function booleanGroups(): void { +Deno.test(function booleanGroups(): void { const argv = parse(["-x", "-z", "one", "two", "three"], { boolean: ["x", "y", "z"] }); @@ -36,7 +35,7 @@ test(function booleanGroups(): void { assertEquals(typeof argv.z, "boolean"); }); -test(function booleanAndAliasWithChainableApi(): void { +Deno.test(function booleanAndAliasWithChainableApi(): void { const aliased = ["-h", "derp"]; const regular = ["--herp", "derp"]; const aliasedArgv = parse(aliased, { @@ -57,7 +56,7 @@ test(function booleanAndAliasWithChainableApi(): void { assertEquals(propertyArgv, expected); }); -test(function booleanAndAliasWithOptionsHash(): void { +Deno.test(function booleanAndAliasWithOptionsHash(): void { const aliased = ["-h", "derp"]; const regular = ["--herp", "derp"]; const opts = { @@ -75,7 +74,7 @@ test(function booleanAndAliasWithOptionsHash(): void { assertEquals(propertyArgv, expected); }); -test(function booleanAndAliasArrayWithOptionsHash(): void { +Deno.test(function booleanAndAliasArrayWithOptionsHash(): void { const aliased = ["-h", "derp"]; const regular = ["--herp", "derp"]; const alt = ["--harp", "derp"]; @@ -97,7 +96,7 @@ test(function booleanAndAliasArrayWithOptionsHash(): void { assertEquals(altPropertyArgv, expected); }); -test(function booleanAndAliasUsingExplicitTrue(): void { +Deno.test(function booleanAndAliasUsingExplicitTrue(): void { const aliased = ["-h", "true"]; const regular = ["--herp", "true"]; const opts = { @@ -118,7 +117,7 @@ test(function booleanAndAliasUsingExplicitTrue(): void { // regression, see https://github.com/substack/node-optimist/issues/71 // boolean and --x=true -test(function booleanAndNonBoolean(): void { +Deno.test(function booleanAndNonBoolean(): void { const parsed = parse(["--boool", "--other=true"], { boolean: "boool" }); @@ -134,7 +133,7 @@ test(function booleanAndNonBoolean(): void { assertEquals(parsed2.other, "false"); }); -test(function booleanParsingTrue(): void { +Deno.test(function booleanParsingTrue(): void { const parsed = parse(["--boool=true"], { default: { boool: false @@ -145,7 +144,7 @@ test(function booleanParsingTrue(): void { assertEquals(parsed.boool, true); }); -test(function booleanParsingFalse(): void { +Deno.test(function booleanParsingFalse(): void { const parsed = parse(["--boool=false"], { default: { boool: true @@ -156,7 +155,7 @@ test(function booleanParsingFalse(): void { assertEquals(parsed.boool, false); }); -test(function booleanParsingTrueLike(): void { +Deno.test(function booleanParsingTrueLike(): void { const parsed = parse(["-t", "true123"], { boolean: ["t"] }); assertEquals(parsed.t, true); @@ -167,7 +166,7 @@ test(function booleanParsingTrueLike(): void { assertEquals(parsed3.t, true); }); -test(function booleanNegationAfterBoolean(): void { +Deno.test(function booleanNegationAfterBoolean(): void { const parsed = parse(["--foo", "--no-foo"], { boolean: ["foo"] }); assertEquals(parsed.foo, false); @@ -175,7 +174,7 @@ test(function booleanNegationAfterBoolean(): void { assertEquals(parsed2.foo, false); }); -test(function booleanAfterBooleanNegation(): void { +Deno.test(function booleanAfterBooleanNegation(): void { const parsed = parse(["--no--foo", "--foo"], { boolean: ["foo"] }); assertEquals(parsed.foo, true); @@ -183,7 +182,7 @@ test(function booleanAfterBooleanNegation(): void { assertEquals(parsed2.foo, true); }); -test(function latestFlagIsBooleanNegation(): void { +Deno.test(function latestFlagIsBooleanNegation(): void { const parsed = parse(["--no-foo", "--foo", "--no-foo"], { boolean: ["foo"] }); assertEquals(parsed.foo, false); @@ -193,7 +192,7 @@ test(function latestFlagIsBooleanNegation(): void { assertEquals(parsed2.foo, false); }); -test(function latestFlagIsBoolean(): void { +Deno.test(function latestFlagIsBoolean(): void { const parsed = parse(["--foo", "--no-foo", "--foo"], { boolean: ["foo"] }); assertEquals(parsed.foo, true); diff --git a/std/flags/dash_test.ts b/std/flags/dash_test.ts index 053351fbd..bdf8f502d 100755 --- a/std/flags/dash_test.ts +++ b/std/flags/dash_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function hyphen(): void { +Deno.test(function hyphen(): void { assertEquals(parse(["-n", "-"]), { n: "-", _: [] }); assertEquals(parse(["-"]), { _: ["-"] }); assertEquals(parse(["-f-"]), { f: "-", _: [] }); @@ -11,13 +10,13 @@ test(function hyphen(): void { assertEquals(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] }); }); -test(function doubleDash(): void { +Deno.test(function doubleDash(): void { assertEquals(parse(["-a", "--", "b"]), { a: true, _: ["b"] }); assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] }); assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] }); }); -test(function moveArgsAfterDoubleDashIntoOwnArray(): void { +Deno.test(function moveArgsAfterDoubleDashIntoOwnArray(): void { assertEquals( parse(["--name", "John", "before", "--", "after"], { "--": true }), { diff --git a/std/flags/default_bool_test.ts b/std/flags/default_bool_test.ts index bf44f5b47..813b6870b 100755 --- a/std/flags/default_bool_test.ts +++ b/std/flags/default_bool_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function booleanDefaultTrue(): void { +Deno.test(function booleanDefaultTrue(): void { const argv = parse([], { boolean: "sometrue", default: { sometrue: true } @@ -11,7 +10,7 @@ test(function booleanDefaultTrue(): void { assertEquals(argv.sometrue, true); }); -test(function booleanDefaultFalse(): void { +Deno.test(function booleanDefaultFalse(): void { const argv = parse([], { boolean: "somefalse", default: { somefalse: false } @@ -19,7 +18,7 @@ test(function booleanDefaultFalse(): void { assertEquals(argv.somefalse, false); }); -test(function booleanDefaultNull(): void { +Deno.test(function booleanDefaultNull(): void { const argv = parse([], { boolean: "maybe", default: { maybe: null } diff --git a/std/flags/dotted_test.ts b/std/flags/dotted_test.ts index 6b98d11d0..93dd3031f 100755 --- a/std/flags/dotted_test.ts +++ b/std/flags/dotted_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function dottedAlias(): void { +Deno.test(function dottedAlias(): void { const argv = parse(["--a.b", "22"], { default: { "a.b": 11 }, alias: { "a.b": "aa.bb" } @@ -12,13 +11,13 @@ test(function dottedAlias(): void { assertEquals(argv.aa.bb, 22); }); -test(function dottedDefault(): void { +Deno.test(function dottedDefault(): void { const argv = parse([], { default: { "a.b": 11 }, alias: { "a.b": "aa.bb" } }); assertEquals(argv.a.b, 11); assertEquals(argv.aa.bb, 11); }); -test(function dottedDefaultWithNoAlias(): void { +Deno.test(function dottedDefaultWithNoAlias(): void { const argv = parse([], { default: { "a.b": 11 } }); assertEquals(argv.a.b, 11); }); diff --git a/std/flags/kv_short_test.ts b/std/flags/kv_short_test.ts index e5aec0fd2..050e550e3 100755 --- a/std/flags/kv_short_test.ts +++ b/std/flags/kv_short_test.ts @@ -1,14 +1,13 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function short(): void { +Deno.test(function short(): void { const argv = parse(["-b=123"]); assertEquals(argv, { b: 123, _: [] }); }); -test(function multiShort(): void { +Deno.test(function multiShort(): void { const argv = parse(["-a=whatever", "-b=robots"]); assertEquals(argv, { a: "whatever", b: "robots", _: [] }); }); diff --git a/std/flags/long_test.ts b/std/flags/long_test.ts index 7c19efaca..e5b68f8c0 100755 --- a/std/flags/long_test.ts +++ b/std/flags/long_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function longOpts(): void { +Deno.test(function longOpts(): void { assertEquals(parse(["--bool"]), { bool: true, _: [] }); assertEquals(parse(["--pow", "xixxle"]), { pow: "xixxle", _: [] }); assertEquals(parse(["--pow=xixxle"]), { pow: "xixxle", _: [] }); diff --git a/std/flags/num_test.ts b/std/flags/num_test.ts index 265a4a3d4..979d36cbf 100755 --- a/std/flags/num_test.ts +++ b/std/flags/num_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function nums(): void { +Deno.test(function nums(): void { const argv = parse([ "-x", "1234", @@ -33,7 +32,7 @@ test(function nums(): void { assertEquals(typeof argv._[0], "number"); }); -test(function alreadyNumber(): void { +Deno.test(function alreadyNumber(): void { const argv = parse(["-x", 1234, 789]); assertEquals(argv, { x: 1234, _: [789] }); assertEquals(typeof argv.x, "number"); diff --git a/std/flags/parse_test.ts b/std/flags/parse_test.ts index 6ed158a9a..cd93c1f81 100755 --- a/std/flags/parse_test.ts +++ b/std/flags/parse_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function _arseArgs(): void { +Deno.test(function parseArgs(): void { assertEquals(parse(["--no-moo"]), { moo: false, _: [] }); assertEquals(parse(["-v", "a", "-v", "b", "-v", "c"]), { v: ["a", "b", "c"], @@ -11,7 +10,7 @@ test(function _arseArgs(): void { }); }); -test(function comprehensive(): void { +Deno.test(function comprehensive(): void { assertEquals( parse([ "--name=meowmers", @@ -48,13 +47,13 @@ test(function comprehensive(): void { ); }); -test(function flagBoolean(): void { +Deno.test(function flagBoolean(): void { const argv = parse(["-t", "moo"], { boolean: "t" }); assertEquals(argv, { t: true, _: ["moo"] }); assertEquals(typeof argv.t, "boolean"); }); -test(function flagBooleanValue(): void { +Deno.test(function flagBooleanValue(): void { const argv = parse(["--verbose", "false", "moo", "-t", "true"], { boolean: ["t", "verbose"], default: { verbose: true } @@ -70,7 +69,7 @@ test(function flagBooleanValue(): void { assertEquals(typeof argv.t, "boolean"); }); -test(function newlinesInParams(): void { +Deno.test(function newlinesInParams(): void { const args = parse(["-s", "X\nX"]); assertEquals(args, { _: [], s: "X\nX" }); @@ -82,7 +81,7 @@ test(function newlinesInParams(): void { assertEquals(args2, { _: [], s: "X\nX" }); }); -test(function strings(): void { +Deno.test(function strings(): void { const s = parse(["-s", "0001234"], { string: "s" }).s; assertEquals(s, "0001234"); assertEquals(typeof s, "string"); @@ -92,7 +91,7 @@ test(function strings(): void { assertEquals(typeof x, "string"); }); -test(function stringArgs(): void { +Deno.test(function stringArgs(): void { const s = parse([" ", " "], { string: "_" })._; assertEquals(s.length, 2); assertEquals(typeof s[0], "string"); @@ -101,7 +100,7 @@ test(function stringArgs(): void { assertEquals(s[1], " "); }); -test(function emptyStrings(): void { +Deno.test(function emptyStrings(): void { const s = parse(["-s"], { string: "s" }).s; assertEquals(s, ""); assertEquals(typeof s, "string"); @@ -119,7 +118,7 @@ test(function emptyStrings(): void { assertEquals(letters.t, ""); }); -test(function stringAndAlias(): void { +Deno.test(function stringAndAlias(): void { const x = parse(["--str", "000123"], { string: "s", alias: { s: "str" } @@ -141,7 +140,7 @@ test(function stringAndAlias(): void { assertEquals(typeof y.s, "string"); }); -test(function slashBreak(): void { +Deno.test(function slashBreak(): void { assertEquals(parse(["-I/foo/bar/baz"]), { I: "/foo/bar/baz", _: [] }); assertEquals(parse(["-xyz/foo/bar/baz"]), { x: true, @@ -151,7 +150,7 @@ test(function slashBreak(): void { }); }); -test(function alias(): void { +Deno.test(function alias(): void { const argv = parse(["-f", "11", "--zoom", "55"], { alias: { z: "zoom" } }); @@ -160,7 +159,7 @@ test(function alias(): void { assertEquals(argv.f, 11); }); -test(function multiAlias(): void { +Deno.test(function multiAlias(): void { const argv = parse(["-f", "11", "--zoom", "55"], { alias: { z: ["zm", "zoom"] } }); @@ -170,7 +169,7 @@ test(function multiAlias(): void { assertEquals(argv.f, 11); }); -test(function nestedDottedObjects(): void { +Deno.test(function nestedDottedObjects(): void { const argv = parse([ "--foo.bar", "3", @@ -193,7 +192,7 @@ test(function nestedDottedObjects(): void { assertEquals(argv.beep, { boop: true }); }); -test(function flagBuiltinProperty(): void { +Deno.test(function flagBuiltinProperty(): void { const argv = parse(["--toString", "--valueOf", "foo"]); assertEquals(argv, { toString: true, valueOf: "foo", _: [] }); assertEquals(typeof argv.toString, "boolean"); diff --git a/std/flags/short_test.ts b/std/flags/short_test.ts index ff0190437..d7171b920 100755 --- a/std/flags/short_test.ts +++ b/std/flags/short_test.ts @@ -1,14 +1,13 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function numbericShortArgs(): void { +Deno.test(function numbericShortArgs(): void { assertEquals(parse(["-n123"]), { n: 123, _: [] }); assertEquals(parse(["-123", "456"]), { 1: true, 2: true, 3: 456, _: [] }); }); -test(function short(): void { +Deno.test(function short(): void { assertEquals(parse(["-b"]), { b: true, _: [] }); assertEquals(parse(["foo", "bar", "baz"]), { _: ["foo", "bar", "baz"] }); assertEquals(parse(["-cats"]), { c: true, a: true, t: true, s: true, _: [] }); @@ -27,7 +26,7 @@ test(function short(): void { }); }); -test(function mixedShortBoolAndCapture(): void { +Deno.test(function mixedShortBoolAndCapture(): void { assertEquals(parse(["-h", "localhost", "-fp", "555", "script.js"]), { f: true, p: 555, @@ -36,7 +35,7 @@ test(function mixedShortBoolAndCapture(): void { }); }); -test(function shortAndLong(): void { +Deno.test(function shortAndLong(): void { assertEquals(parse(["-h", "localhost", "-fp", "555", "script.js"]), { f: true, p: 555, diff --git a/std/flags/stop_early_test.ts b/std/flags/stop_early_test.ts index f054d780b..d1996e7aa 100755 --- a/std/flags/stop_early_test.ts +++ b/std/flags/stop_early_test.ts @@ -1,10 +1,9 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; // stops parsing on the first non-option when stopEarly is set -test(function stopParsing(): void { +Deno.test(function stopParsing(): void { const argv = parse(["--aaa", "bbb", "ccc", "--ddd"], { stopEarly: true }); diff --git a/std/flags/unknown_test.ts b/std/flags/unknown_test.ts index b7817564c..acbb131ee 100755 --- a/std/flags/unknown_test.ts +++ b/std/flags/unknown_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function booleanAndAliasIsNotUnknown(): void { +Deno.test(function booleanAndAliasIsNotUnknown(): void { const unknown: unknown[] = []; function unknownFn(arg: unknown): boolean { unknown.push(arg); @@ -22,7 +21,7 @@ test(function booleanAndAliasIsNotUnknown(): void { assertEquals(unknown, ["--derp", "-d"]); }); -test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown(): void { +Deno.test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown(): void { const unknown: unknown[] = []; function unknownFn(arg: unknown): boolean { unknown.push(arg); @@ -39,7 +38,7 @@ test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown(): void { }); }); -test(function stringAndAliasIsNotUnkown(): void { +Deno.test(function stringAndAliasIsNotUnkown(): void { const unknown: unknown[] = []; function unknownFn(arg: unknown): boolean { unknown.push(arg); @@ -58,7 +57,7 @@ test(function stringAndAliasIsNotUnkown(): void { assertEquals(unknown, ["--derp", "-d"]); }); -test(function defaultAndAliasIsNotUnknown(): void { +Deno.test(function defaultAndAliasIsNotUnknown(): void { const unknown: unknown[] = []; function unknownFn(arg: unknown): boolean { unknown.push(arg); @@ -77,7 +76,7 @@ test(function defaultAndAliasIsNotUnknown(): void { assertEquals(unknown, []); }); -test(function valueFollowingDoubleHyphenIsNotUnknown(): void { +Deno.test(function valueFollowingDoubleHyphenIsNotUnknown(): void { const unknown: unknown[] = []; function unknownFn(arg: unknown): boolean { unknown.push(arg); diff --git a/std/flags/whitespace_test.ts b/std/flags/whitespace_test.ts index 9f66dfdfc..878ed28df 100755 --- a/std/flags/whitespace_test.ts +++ b/std/flags/whitespace_test.ts @@ -1,8 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { parse } from "./mod.ts"; -test(function whitespaceShouldBeWhitespace(): void { +Deno.test(function whitespaceShouldBeWhitespace(): void { assertEquals(parse(["-x", "\t"]).x, "\t"); }); |