summaryrefslogtreecommitdiff
path: root/std/flags
diff options
context:
space:
mode:
Diffstat (limited to 'std/flags')
-rwxr-xr-xstd/flags/all_bool_test.ts4
-rwxr-xr-xstd/flags/bool_test.ts28
-rwxr-xr-xstd/flags/dash_test.ts6
-rwxr-xr-xstd/flags/default_bool_test.ts6
-rwxr-xr-xstd/flags/dotted_test.ts6
-rwxr-xr-xstd/flags/kv_short_test.ts4
-rwxr-xr-xstd/flags/long_test.ts2
-rwxr-xr-xstd/flags/num_test.ts4
-rwxr-xr-xstd/flags/parse_test.ts28
-rwxr-xr-xstd/flags/short_test.ts8
-rwxr-xr-xstd/flags/stop_early_test.ts2
-rwxr-xr-xstd/flags/unknown_test.ts49
-rwxr-xr-xstd/flags/whitespace_test.ts2
13 files changed, 76 insertions, 73 deletions
diff --git a/std/flags/all_bool_test.ts b/std/flags/all_bool_test.ts
index cb5a36710..465635096 100755
--- a/std/flags/all_bool_test.ts
+++ b/std/flags/all_bool_test.ts
@@ -3,7 +3,7 @@ import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
// flag boolean true (default all --args to boolean)
-Deno.test(function flagBooleanTrue(): void {
+Deno.test("flagBooleanTrue", function (): void {
const argv = parse(["moo", "--honk", "cow"], {
boolean: true,
});
@@ -17,7 +17,7 @@ Deno.test(function flagBooleanTrue(): void {
});
// flag boolean true only affects double hyphen arguments without equals signs
-Deno.test(function flagBooleanTrueOnlyAffectsDoubleDash(): void {
+Deno.test("flagBooleanTrueOnlyAffectsDoubleDash", function (): 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 f2d88e617..a99be7366 100755
--- a/std/flags/bool_test.ts
+++ b/std/flags/bool_test.ts
@@ -2,7 +2,7 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function flagBooleanDefaultFalse(): void {
+Deno.test("flagBooleanDefaultFalse", function (): void {
const argv = parse(["moo"], {
boolean: ["t", "verbose"],
default: { verbose: false, t: false },
@@ -18,7 +18,7 @@ Deno.test(function flagBooleanDefaultFalse(): void {
assertEquals(typeof argv.t, "boolean");
});
-Deno.test(function booleanGroups(): void {
+Deno.test("booleanGroups", function (): void {
const argv = parse(["-x", "-z", "one", "two", "three"], {
boolean: ["x", "y", "z"],
});
@@ -35,7 +35,7 @@ Deno.test(function booleanGroups(): void {
assertEquals(typeof argv.z, "boolean");
});
-Deno.test(function booleanAndAliasWithChainableApi(): void {
+Deno.test("booleanAndAliasWithChainableApi", function (): void {
const aliased = ["-h", "derp"];
const regular = ["--herp", "derp"];
const aliasedArgv = parse(aliased, {
@@ -56,7 +56,7 @@ Deno.test(function booleanAndAliasWithChainableApi(): void {
assertEquals(propertyArgv, expected);
});
-Deno.test(function booleanAndAliasWithOptionsHash(): void {
+Deno.test("booleanAndAliasWithOptionsHash", function (): void {
const aliased = ["-h", "derp"];
const regular = ["--herp", "derp"];
const opts = {
@@ -74,7 +74,7 @@ Deno.test(function booleanAndAliasWithOptionsHash(): void {
assertEquals(propertyArgv, expected);
});
-Deno.test(function booleanAndAliasArrayWithOptionsHash(): void {
+Deno.test("booleanAndAliasArrayWithOptionsHash", function (): void {
const aliased = ["-h", "derp"];
const regular = ["--herp", "derp"];
const alt = ["--harp", "derp"];
@@ -96,7 +96,7 @@ Deno.test(function booleanAndAliasArrayWithOptionsHash(): void {
assertEquals(altPropertyArgv, expected);
});
-Deno.test(function booleanAndAliasUsingExplicitTrue(): void {
+Deno.test("booleanAndAliasUsingExplicitTrue", function (): void {
const aliased = ["-h", "true"];
const regular = ["--herp", "true"];
const opts = {
@@ -117,7 +117,7 @@ Deno.test(function booleanAndAliasUsingExplicitTrue(): void {
// regression, see https://github.com/substack/node-optimist/issues/71
// boolean and --x=true
-Deno.test(function booleanAndNonBoolean(): void {
+Deno.test("booleanAndNonBoolean", function (): void {
const parsed = parse(["--boool", "--other=true"], {
boolean: "boool",
});
@@ -133,7 +133,7 @@ Deno.test(function booleanAndNonBoolean(): void {
assertEquals(parsed2.other, "false");
});
-Deno.test(function booleanParsingTrue(): void {
+Deno.test("booleanParsingTrue", function (): void {
const parsed = parse(["--boool=true"], {
default: {
boool: false,
@@ -144,7 +144,7 @@ Deno.test(function booleanParsingTrue(): void {
assertEquals(parsed.boool, true);
});
-Deno.test(function booleanParsingFalse(): void {
+Deno.test("booleanParsingFalse", function (): void {
const parsed = parse(["--boool=false"], {
default: {
boool: true,
@@ -155,7 +155,7 @@ Deno.test(function booleanParsingFalse(): void {
assertEquals(parsed.boool, false);
});
-Deno.test(function booleanParsingTrueLike(): void {
+Deno.test("booleanParsingTrueLike", function (): void {
const parsed = parse(["-t", "true123"], { boolean: ["t"] });
assertEquals(parsed.t, true);
@@ -166,7 +166,7 @@ Deno.test(function booleanParsingTrueLike(): void {
assertEquals(parsed3.t, true);
});
-Deno.test(function booleanNegationAfterBoolean(): void {
+Deno.test("booleanNegationAfterBoolean", function (): void {
const parsed = parse(["--foo", "--no-foo"], { boolean: ["foo"] });
assertEquals(parsed.foo, false);
@@ -174,7 +174,7 @@ Deno.test(function booleanNegationAfterBoolean(): void {
assertEquals(parsed2.foo, false);
});
-Deno.test(function booleanAfterBooleanNegation(): void {
+Deno.test("booleanAfterBooleanNegation", function (): void {
const parsed = parse(["--no--foo", "--foo"], { boolean: ["foo"] });
assertEquals(parsed.foo, true);
@@ -182,7 +182,7 @@ Deno.test(function booleanAfterBooleanNegation(): void {
assertEquals(parsed2.foo, true);
});
-Deno.test(function latestFlagIsBooleanNegation(): void {
+Deno.test("latestFlagIsBooleanNegation", function (): void {
const parsed = parse(["--no-foo", "--foo", "--no-foo"], { boolean: ["foo"] });
assertEquals(parsed.foo, false);
@@ -192,7 +192,7 @@ Deno.test(function latestFlagIsBooleanNegation(): void {
assertEquals(parsed2.foo, false);
});
-Deno.test(function latestFlagIsBoolean(): void {
+Deno.test("latestFlagIsBoolean", function (): 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 3df169291..896305cc4 100755
--- a/std/flags/dash_test.ts
+++ b/std/flags/dash_test.ts
@@ -2,7 +2,7 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function hyphen(): void {
+Deno.test("hyphen", function (): void {
assertEquals(parse(["-n", "-"]), { n: "-", _: [] });
assertEquals(parse(["-"]), { _: ["-"] });
assertEquals(parse(["-f-"]), { f: "-", _: [] });
@@ -10,13 +10,13 @@ Deno.test(function hyphen(): void {
assertEquals(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] });
});
-Deno.test(function doubleDash(): void {
+Deno.test("doubleDash", function (): void {
assertEquals(parse(["-a", "--", "b"]), { a: true, _: ["b"] });
assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
});
-Deno.test(function moveArgsAfterDoubleDashIntoOwnArray(): void {
+Deno.test("moveArgsAfterDoubleDashIntoOwnArray", function (): 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 4376038fe..e433a965d 100755
--- a/std/flags/default_bool_test.ts
+++ b/std/flags/default_bool_test.ts
@@ -2,7 +2,7 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function booleanDefaultTrue(): void {
+Deno.test("booleanDefaultTrue", function (): void {
const argv = parse([], {
boolean: "sometrue",
default: { sometrue: true },
@@ -10,7 +10,7 @@ Deno.test(function booleanDefaultTrue(): void {
assertEquals(argv.sometrue, true);
});
-Deno.test(function booleanDefaultFalse(): void {
+Deno.test("booleanDefaultFalse", function (): void {
const argv = parse([], {
boolean: "somefalse",
default: { somefalse: false },
@@ -18,7 +18,7 @@ Deno.test(function booleanDefaultFalse(): void {
assertEquals(argv.somefalse, false);
});
-Deno.test(function booleanDefaultNull(): void {
+Deno.test("booleanDefaultNull", function (): void {
const argv = parse([], {
boolean: "maybe",
default: { maybe: null },
diff --git a/std/flags/dotted_test.ts b/std/flags/dotted_test.ts
index c86392f2a..73013228c 100755
--- a/std/flags/dotted_test.ts
+++ b/std/flags/dotted_test.ts
@@ -2,7 +2,7 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function dottedAlias(): void {
+Deno.test("dottedAlias", function (): void {
const argv = parse(["--a.b", "22"], {
default: { "a.b": 11 },
alias: { "a.b": "aa.bb" },
@@ -11,13 +11,13 @@ Deno.test(function dottedAlias(): void {
assertEquals(argv.aa.bb, 22);
});
-Deno.test(function dottedDefault(): void {
+Deno.test("dottedDefault", function (): void {
const argv = parse([], { default: { "a.b": 11 }, alias: { "a.b": "aa.bb" } });
assertEquals(argv.a.b, 11);
assertEquals(argv.aa.bb, 11);
});
-Deno.test(function dottedDefaultWithNoAlias(): void {
+Deno.test("dottedDefaultWithNoAlias", function (): 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 050e550e3..dca05fb87 100755
--- a/std/flags/kv_short_test.ts
+++ b/std/flags/kv_short_test.ts
@@ -2,12 +2,12 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function short(): void {
+Deno.test("short", function (): void {
const argv = parse(["-b=123"]);
assertEquals(argv, { b: 123, _: [] });
});
-Deno.test(function multiShort(): void {
+Deno.test("multiShort", function (): 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 f0f4d7545..1c8ccca51 100755
--- a/std/flags/long_test.ts
+++ b/std/flags/long_test.ts
@@ -2,7 +2,7 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function longOpts(): void {
+Deno.test("longOpts", function (): 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 f8a0d11ac..a457ba959 100755
--- a/std/flags/num_test.ts
+++ b/std/flags/num_test.ts
@@ -2,7 +2,7 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function nums(): void {
+Deno.test("nums", function (): void {
const argv = parse([
"-x",
"1234",
@@ -32,7 +32,7 @@ Deno.test(function nums(): void {
assertEquals(typeof argv._[0], "number");
});
-Deno.test(function alreadyNumber(): void {
+Deno.test("alreadyNumber", function (): 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 abba42e16..c6a40d1ee 100755
--- a/std/flags/parse_test.ts
+++ b/std/flags/parse_test.ts
@@ -2,7 +2,7 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function parseArgs(): void {
+Deno.test("parseArgs", function (): void {
assertEquals(parse(["--no-moo"]), { moo: false, _: [] });
assertEquals(parse(["-v", "a", "-v", "b", "-v", "c"]), {
v: ["a", "b", "c"],
@@ -10,7 +10,7 @@ Deno.test(function parseArgs(): void {
});
});
-Deno.test(function comprehensive(): void {
+Deno.test("comprehensive", function (): void {
assertEquals(
parse([
"--name=meowmers",
@@ -47,13 +47,13 @@ Deno.test(function comprehensive(): void {
);
});
-Deno.test(function flagBoolean(): void {
+Deno.test("flagBoolean", function (): void {
const argv = parse(["-t", "moo"], { boolean: "t" });
assertEquals(argv, { t: true, _: ["moo"] });
assertEquals(typeof argv.t, "boolean");
});
-Deno.test(function flagBooleanValue(): void {
+Deno.test("flagBooleanValue", function (): void {
const argv = parse(["--verbose", "false", "moo", "-t", "true"], {
boolean: ["t", "verbose"],
default: { verbose: true },
@@ -69,7 +69,7 @@ Deno.test(function flagBooleanValue(): void {
assertEquals(typeof argv.t, "boolean");
});
-Deno.test(function newlinesInParams(): void {
+Deno.test("newlinesInParams", function (): void {
const args = parse(["-s", "X\nX"]);
assertEquals(args, { _: [], s: "X\nX" });
@@ -81,7 +81,7 @@ Deno.test(function newlinesInParams(): void {
assertEquals(args2, { _: [], s: "X\nX" });
});
-Deno.test(function strings(): void {
+Deno.test("strings", function (): void {
const s = parse(["-s", "0001234"], { string: "s" }).s;
assertEquals(s, "0001234");
assertEquals(typeof s, "string");
@@ -91,7 +91,7 @@ Deno.test(function strings(): void {
assertEquals(typeof x, "string");
});
-Deno.test(function stringArgs(): void {
+Deno.test("stringArgs", function (): void {
const s = parse([" ", " "], { string: "_" })._;
assertEquals(s.length, 2);
assertEquals(typeof s[0], "string");
@@ -100,7 +100,7 @@ Deno.test(function stringArgs(): void {
assertEquals(s[1], " ");
});
-Deno.test(function emptyStrings(): void {
+Deno.test("emptyStrings", function (): void {
const s = parse(["-s"], { string: "s" }).s;
assertEquals(s, "");
assertEquals(typeof s, "string");
@@ -118,7 +118,7 @@ Deno.test(function emptyStrings(): void {
assertEquals(letters.t, "");
});
-Deno.test(function stringAndAlias(): void {
+Deno.test("stringAndAlias", function (): void {
const x = parse(["--str", "000123"], {
string: "s",
alias: { s: "str" },
@@ -140,7 +140,7 @@ Deno.test(function stringAndAlias(): void {
assertEquals(typeof y.s, "string");
});
-Deno.test(function slashBreak(): void {
+Deno.test("slashBreak", function (): void {
assertEquals(parse(["-I/foo/bar/baz"]), { I: "/foo/bar/baz", _: [] });
assertEquals(parse(["-xyz/foo/bar/baz"]), {
x: true,
@@ -150,7 +150,7 @@ Deno.test(function slashBreak(): void {
});
});
-Deno.test(function alias(): void {
+Deno.test("alias", function (): void {
const argv = parse(["-f", "11", "--zoom", "55"], {
alias: { z: "zoom" },
});
@@ -159,7 +159,7 @@ Deno.test(function alias(): void {
assertEquals(argv.f, 11);
});
-Deno.test(function multiAlias(): void {
+Deno.test("multiAlias", function (): void {
const argv = parse(["-f", "11", "--zoom", "55"], {
alias: { z: ["zm", "zoom"] },
});
@@ -169,7 +169,7 @@ Deno.test(function multiAlias(): void {
assertEquals(argv.f, 11);
});
-Deno.test(function nestedDottedObjects(): void {
+Deno.test("nestedDottedObjects", function (): void {
const argv = parse([
"--foo.bar",
"3",
@@ -192,7 +192,7 @@ Deno.test(function nestedDottedObjects(): void {
assertEquals(argv.beep, { boop: true });
});
-Deno.test(function flagBuiltinProperty(): void {
+Deno.test("flagBuiltinProperty", function (): 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 6305bbb94..d152a3736 100755
--- a/std/flags/short_test.ts
+++ b/std/flags/short_test.ts
@@ -2,12 +2,12 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function numbericShortArgs(): void {
+Deno.test("numbericShortArgs", function (): void {
assertEquals(parse(["-n123"]), { n: 123, _: [] });
assertEquals(parse(["-123", "456"]), { 1: true, 2: true, 3: 456, _: [] });
});
-Deno.test(function short(): void {
+Deno.test("short", function (): 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, _: [] });
@@ -26,7 +26,7 @@ Deno.test(function short(): void {
});
});
-Deno.test(function mixedShortBoolAndCapture(): void {
+Deno.test("mixedShortBoolAndCapture", function (): void {
assertEquals(parse(["-h", "localhost", "-fp", "555", "script.js"]), {
f: true,
p: 555,
@@ -35,7 +35,7 @@ Deno.test(function mixedShortBoolAndCapture(): void {
});
});
-Deno.test(function shortAndLong(): void {
+Deno.test("shortAndLong", function (): 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 4b7eac097..219ef8042 100755
--- a/std/flags/stop_early_test.ts
+++ b/std/flags/stop_early_test.ts
@@ -3,7 +3,7 @@ import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
// stops parsing on the first non-option when stopEarly is set
-Deno.test(function stopParsing(): void {
+Deno.test("stopParsing", function (): 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 0d822144d..d6db78371 100755
--- a/std/flags/unknown_test.ts
+++ b/std/flags/unknown_test.ts
@@ -2,7 +2,7 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function booleanAndAliasIsNotUnknown(): void {
+Deno.test("booleanAndAliasIsNotUnknown", function (): void {
const unknown: unknown[] = [];
function unknownFn(arg: string, k?: string, v?: unknown): boolean {
unknown.push({ arg, k, v });
@@ -24,28 +24,31 @@ Deno.test(function booleanAndAliasIsNotUnknown(): void {
]);
});
-Deno.test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown(): void {
- const unknown: unknown[] = [];
- function unknownFn(arg: string, k?: string, v?: unknown): boolean {
- unknown.push({ arg, k, v });
- return false;
+Deno.test(
+ "flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown",
+ function (): void {
+ const unknown: unknown[] = [];
+ function unknownFn(arg: string, k?: string, v?: unknown): boolean {
+ unknown.push({ arg, k, v });
+ return false;
+ }
+ const argv = parse(["--honk", "--tacos=good", "cow", "-p", "55"], {
+ boolean: true,
+ unknown: unknownFn,
+ });
+ assertEquals(unknown, [
+ { arg: "--tacos=good", k: "tacos", v: "good" },
+ { arg: "cow", k: undefined, v: undefined },
+ { arg: "-p", k: "p", v: "55" },
+ ]);
+ assertEquals(argv, {
+ honk: true,
+ _: [],
+ });
}
- const argv = parse(["--honk", "--tacos=good", "cow", "-p", "55"], {
- boolean: true,
- unknown: unknownFn,
- });
- assertEquals(unknown, [
- { arg: "--tacos=good", k: "tacos", v: "good" },
- { arg: "cow", k: undefined, v: undefined },
- { arg: "-p", k: "p", v: "55" },
- ]);
- assertEquals(argv, {
- honk: true,
- _: [],
- });
-});
+);
-Deno.test(function stringAndAliasIsNotUnkown(): void {
+Deno.test("stringAndAliasIsNotUnkown", function (): void {
const unknown: unknown[] = [];
function unknownFn(arg: string, k?: string, v?: unknown): boolean {
unknown.push({ arg, k, v });
@@ -67,7 +70,7 @@ Deno.test(function stringAndAliasIsNotUnkown(): void {
]);
});
-Deno.test(function defaultAndAliasIsNotUnknown(): void {
+Deno.test("defaultAndAliasIsNotUnknown", function (): void {
const unknown: unknown[] = [];
function unknownFn(arg: string, k?: string, v?: unknown): boolean {
unknown.push({ arg, k, v });
@@ -86,7 +89,7 @@ Deno.test(function defaultAndAliasIsNotUnknown(): void {
assertEquals(unknown, []);
});
-Deno.test(function valueFollowingDoubleHyphenIsNotUnknown(): void {
+Deno.test("valueFollowingDoubleHyphenIsNotUnknown", function (): void {
const unknown: unknown[] = [];
function unknownFn(arg: string, k?: string, v?: unknown): boolean {
unknown.push({ arg, k, v });
diff --git a/std/flags/whitespace_test.ts b/std/flags/whitespace_test.ts
index 878ed28df..ff7e2c5aa 100755
--- a/std/flags/whitespace_test.ts
+++ b/std/flags/whitespace_test.ts
@@ -2,6 +2,6 @@
import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";
-Deno.test(function whitespaceShouldBeWhitespace(): void {
+Deno.test("whitespaceShouldBeWhitespace", function (): void {
assertEquals(parse(["-x", "\t"]).x, "\t");
});