mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
f113312ef2
Original: 5440377495
24 lines
924 B
TypeScript
Executable file
24 lines
924 B
TypeScript
Executable file
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
|
import { test, assertEqual } from "../../testing/mod.ts";
|
|
import { parse } from "../mod.ts";
|
|
|
|
test(function hyphen() {
|
|
assertEqual(parse(["-n", "-"]), { n: "-", _: [] });
|
|
assertEqual(parse(["-"]), { _: ["-"] });
|
|
assertEqual(parse(["-f-"]), { f: "-", _: [] });
|
|
assertEqual(parse(["-b", "-"], { boolean: "b" }), { b: true, _: ["-"] });
|
|
assertEqual(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] });
|
|
});
|
|
|
|
test(function doubleDash() {
|
|
assertEqual(parse(["-a", "--", "b"]), { a: true, _: ["b"] });
|
|
assertEqual(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
|
|
assertEqual(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
|
|
});
|
|
|
|
test(function moveArgsAfterDoubleDashIntoOwnArray() {
|
|
assertEqual(
|
|
parse(["--name", "John", "before", "--", "after"], { "--": true }),
|
|
{ name: "John", _: ["before"], "--": ["after"] }
|
|
);
|
|
});
|