diff options
| author | Axetroy <troy450409405@gmail.com> | 2019-03-20 01:24:11 +0800 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-19 13:24:11 -0400 |
| commit | aae6ea51a496301011c41a874a25b77596d5c560 (patch) | |
| tree | edfcefbbbae67a1e59baa6a8d5d1fd5b6009dfec /flags/dash_test.ts | |
| parent | adb19cbae366288a152dd3ab8293e5aea2edc80b (diff) | |
move test file out of tests dir in flags module (denoland/deno_std#293)
Original: https://github.com/denoland/deno_std/commit/e80f14489084d748bb52c4311519f5d0c7696f47
Diffstat (limited to 'flags/dash_test.ts')
| -rwxr-xr-x | flags/dash_test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/flags/dash_test.ts b/flags/dash_test.ts new file mode 100755 index 000000000..7d52e4905 --- /dev/null +++ b/flags/dash_test.ts @@ -0,0 +1,29 @@ +// Copyright 2018-2019 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() { + assertEquals(parse(["-n", "-"]), { n: "-", _: [] }); + assertEquals(parse(["-"]), { _: ["-"] }); + assertEquals(parse(["-f-"]), { f: "-", _: [] }); + assertEquals(parse(["-b", "-"], { boolean: "b" }), { b: true, _: ["-"] }); + assertEquals(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] }); +}); + +test(function doubleDash() { + assertEquals(parse(["-a", "--", "b"]), { a: true, _: ["b"] }); + assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] }); + assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] }); +}); + +test(function moveArgsAfterDoubleDashIntoOwnArray() { + assertEquals( + parse(["--name", "John", "before", "--", "after"], { "--": true }), + { + name: "John", + _: ["before"], + "--": ["after"] + } + ); +}); |
