Skip to content

Commit

Permalink
std/flags: Add test for multiple boolean flags (#3103)
Browse files Browse the repository at this point in the history
  • Loading branch information
justjavac authored and ry committed Oct 16, 2019
1 parent b1685ce commit 5983507
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions std/flags/bool_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,39 @@ test(function booleanParsingTrueLike(): void {
const parsed3 = parse(["-t", "false123"], { boolean: ["t"] });
assertEquals(parsed3.t, true);
});

test(function booleanNegationAfterBoolean(): void {
const parsed = parse(["--foo", "--no-foo"], { boolean: ["foo"] });
assertEquals(parsed.foo, false);

const parsed2 = parse(["--foo", "--no-foo", "123"], { boolean: ["foo"] });
assertEquals(parsed2.foo, false);
});

test(function booleanAfterBooleanNegation(): void {
const parsed = parse(["--no--foo", "--foo"], { boolean: ["foo"] });
assertEquals(parsed.foo, true);

const parsed2 = parse(["--no--foo", "--foo", "123"], { boolean: ["foo"] });
assertEquals(parsed2.foo, true);
});

test(function latestFlagIsBooleanNegation(): void {
const parsed = parse(["--no-foo", "--foo", "--no-foo"], { boolean: ["foo"] });
assertEquals(parsed.foo, false);

const parsed2 = parse(["--no-foo", "--foo", "--no-foo", "123"], {
boolean: ["foo"]
});
assertEquals(parsed2.foo, false);
});

test(function latestFlagIsBoolean(): void {
const parsed = parse(["--foo", "--no-foo", "--foo"], { boolean: ["foo"] });
assertEquals(parsed.foo, true);

const parsed2 = parse(["--foo", "--no-foo", "--foo", "123"], {
boolean: ["foo"]
});
assertEquals(parsed2.foo, true);
});

0 comments on commit 5983507

Please sign in to comment.