mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 07:44:48 -05:00
Rename assertEq to assertEquals (denoland/deno_std#242)
After some discussion it was found that assertEquals is more common
in JS (vs assertEqual, assertEq) and sounds better in the negated form:
assertNotEquals vs assertNE.
Original: 4cf39d4a14
This commit is contained in:
parent
e36edfdb3f
commit
caa383a583
55 changed files with 720 additions and 714 deletions
|
@ -5,14 +5,14 @@ import {
|
|||
bytesHasPrefix
|
||||
} from "./bytes.ts";
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
|
||||
test(function bytesBytesFindIndex() {
|
||||
const i = bytesFindIndex(
|
||||
new Uint8Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 3]),
|
||||
new Uint8Array([0, 1, 2])
|
||||
);
|
||||
assertEq(i, 2);
|
||||
assertEquals(i, 2);
|
||||
});
|
||||
|
||||
test(function bytesBytesFindLastIndex1() {
|
||||
|
@ -20,7 +20,7 @@ test(function bytesBytesFindLastIndex1() {
|
|||
new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 3]),
|
||||
new Uint8Array([0, 1, 2])
|
||||
);
|
||||
assertEq(i, 3);
|
||||
assertEquals(i, 3);
|
||||
});
|
||||
|
||||
test(function bytesBytesBytesEqual() {
|
||||
|
@ -28,10 +28,10 @@ test(function bytesBytesBytesEqual() {
|
|||
new Uint8Array([0, 1, 2, 3]),
|
||||
new Uint8Array([0, 1, 2, 3])
|
||||
);
|
||||
assertEq(v, true);
|
||||
assertEquals(v, true);
|
||||
});
|
||||
|
||||
test(function bytesBytesHasPrefix() {
|
||||
const v = bytesHasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([0, 1]));
|
||||
assertEq(v, true);
|
||||
assertEquals(v, true);
|
||||
});
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { red, bgBlue, setEnabled, getEnabled } from "./mod.ts";
|
||||
import "./example.ts";
|
||||
|
||||
test(function singleColor() {
|
||||
assertEq(red("Hello world"), "[31mHello world[39m");
|
||||
assertEquals(red("Hello world"), "[31mHello world[39m");
|
||||
});
|
||||
|
||||
test(function doubleColor() {
|
||||
assertEq(bgBlue(red("Hello world")), "[44m[31mHello world[39m[49m");
|
||||
assertEquals(bgBlue(red("Hello world")), "[44m[31mHello world[39m[49m");
|
||||
});
|
||||
|
||||
test(function replacesCloseCharacters() {
|
||||
assertEq(red("Hel[39mlo"), "[31mHel[31mlo[39m");
|
||||
assertEquals(red("Hel[39mlo"), "[31mHel[31mlo[39m");
|
||||
});
|
||||
|
||||
test(function enablingColors() {
|
||||
assertEq(getEnabled(), true);
|
||||
assertEquals(getEnabled(), true);
|
||||
setEnabled(false);
|
||||
assertEq(bgBlue(red("Hello world")), "Hello world");
|
||||
assertEquals(bgBlue(red("Hello world")), "Hello world");
|
||||
setEnabled(true);
|
||||
assertEq(red("Hello world"), "[31mHello world[39m");
|
||||
assertEquals(red("Hello world"), "[31mHello world[39m");
|
||||
});
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assert, assertEq } from "../testing/asserts.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import * as datetime from "./mod.ts";
|
||||
|
||||
test(function parseDateTime() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDateTime("01-03-2019 16:34", "mm-dd-yyyy hh:mm"),
|
||||
new Date(2019, 1, 3, 16, 34)
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDateTime("03-01-2019 16:34", "dd-mm-yyyy hh:mm"),
|
||||
new Date(2019, 1, 3, 16, 34)
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDateTime("2019-01-03 16:34", "yyyy-mm-dd hh:mm"),
|
||||
new Date(2019, 1, 3, 16, 34)
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDateTime("16:34 01-03-2019", "hh:mm mm-dd-yyyy"),
|
||||
new Date(2019, 1, 3, 16, 34)
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDateTime("16:34 03-01-2019", "hh:mm dd-mm-yyyy"),
|
||||
new Date(2019, 1, 3, 16, 34)
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDateTime("16:34 2019-01-03", "hh:mm yyyy-mm-dd"),
|
||||
new Date(2019, 1, 3, 16, 34)
|
||||
);
|
||||
|
@ -36,20 +36,20 @@ test(function invalidParseDateTimeFormatThrows() {
|
|||
(datetime as any).parseDateTime("2019-01-01 00:00", "x-y-z");
|
||||
assert(false, "no exception was thrown");
|
||||
} catch (e) {
|
||||
assertEq(e.message, "Invalid datetime format!");
|
||||
assertEquals(e.message, "Invalid datetime format!");
|
||||
}
|
||||
});
|
||||
|
||||
test(function parseDate() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDate("01-03-2019", "mm-dd-yyyy"),
|
||||
new Date(2019, 1, 3)
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDate("03-01-2019", "dd-mm-yyyy"),
|
||||
new Date(2019, 1, 3)
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.parseDate("2019-01-03", "yyyy-mm-dd"),
|
||||
new Date(2019, 1, 3)
|
||||
);
|
||||
|
@ -61,12 +61,12 @@ test(function invalidParseDateFormatThrows() {
|
|||
(datetime as any).parseDate("2019-01-01", "x-y-z");
|
||||
assert(false, "no exception was thrown");
|
||||
} catch (e) {
|
||||
assertEq(e.message, "Invalid date format!");
|
||||
assertEquals(e.message, "Invalid date format!");
|
||||
}
|
||||
});
|
||||
|
||||
test(function currentDayOfYear() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
datetime.currentDayOfYear(),
|
||||
Math.ceil(new Date().getTime() / 86400000) -
|
||||
Math.floor(
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
const { run } = Deno;
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
|
||||
/** Example of how to do basic tests */
|
||||
test(function t1() {
|
||||
assertEq("hello", "hello");
|
||||
assertEquals("hello", "hello");
|
||||
});
|
||||
|
||||
test(function t2() {
|
||||
assertEq("world", "world");
|
||||
assertEquals("world", "world");
|
||||
});
|
||||
|
||||
/** A more complicated test that runs a subprocess. */
|
||||
|
@ -19,5 +19,5 @@ test(async function catSmoke() {
|
|||
stdout: "piped"
|
||||
});
|
||||
const s = await p.status();
|
||||
assertEq(s.code, 0);
|
||||
assertEquals(s.code, 0);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
// flag boolean true (default all --args to boolean)
|
||||
|
@ -9,12 +9,12 @@ test(function flagBooleanTrue() {
|
|||
boolean: true
|
||||
});
|
||||
|
||||
assertEq(argv, {
|
||||
assertEquals(argv, {
|
||||
honk: true,
|
||||
_: ["moo", "cow"]
|
||||
});
|
||||
|
||||
assertEq(typeof argv.honk, "boolean");
|
||||
assertEquals(typeof argv.honk, "boolean");
|
||||
});
|
||||
|
||||
// flag boolean true only affects double hyphen arguments without equals signs
|
||||
|
@ -23,12 +23,12 @@ test(function flagBooleanTrueOnlyAffectsDoubleDash() {
|
|||
boolean: true
|
||||
});
|
||||
|
||||
assertEq(argv, {
|
||||
assertEquals(argv, {
|
||||
honk: true,
|
||||
tacos: "good",
|
||||
p: 55,
|
||||
_: ["moo", "cow"]
|
||||
});
|
||||
|
||||
assertEq(typeof argv.honk, "boolean");
|
||||
assertEquals(typeof argv.honk, "boolean");
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function flagBooleanDefaultFalse() {
|
||||
|
@ -9,14 +9,14 @@ test(function flagBooleanDefaultFalse() {
|
|||
default: { verbose: false, t: false }
|
||||
});
|
||||
|
||||
assertEq(argv, {
|
||||
assertEquals(argv, {
|
||||
verbose: false,
|
||||
t: false,
|
||||
_: ["moo"]
|
||||
});
|
||||
|
||||
assertEq(typeof argv.verbose, "boolean");
|
||||
assertEq(typeof argv.t, "boolean");
|
||||
assertEquals(typeof argv.verbose, "boolean");
|
||||
assertEquals(typeof argv.t, "boolean");
|
||||
});
|
||||
|
||||
test(function booleanGroups() {
|
||||
|
@ -24,16 +24,16 @@ test(function booleanGroups() {
|
|||
boolean: ["x", "y", "z"]
|
||||
});
|
||||
|
||||
assertEq(argv, {
|
||||
assertEquals(argv, {
|
||||
x: true,
|
||||
y: false,
|
||||
z: true,
|
||||
_: ["one", "two", "three"]
|
||||
});
|
||||
|
||||
assertEq(typeof argv.x, "boolean");
|
||||
assertEq(typeof argv.y, "boolean");
|
||||
assertEq(typeof argv.z, "boolean");
|
||||
assertEquals(typeof argv.x, "boolean");
|
||||
assertEquals(typeof argv.y, "boolean");
|
||||
assertEquals(typeof argv.z, "boolean");
|
||||
});
|
||||
|
||||
test(function booleanAndAliasWithChainableApi() {
|
||||
|
@ -56,8 +56,8 @@ test(function booleanAndAliasWithChainableApi() {
|
|||
_: ["derp"]
|
||||
};
|
||||
|
||||
assertEq(aliasedArgv, expected);
|
||||
assertEq(propertyArgv, expected);
|
||||
assertEquals(aliasedArgv, expected);
|
||||
assertEquals(propertyArgv, expected);
|
||||
});
|
||||
|
||||
test(function booleanAndAliasWithOptionsHash() {
|
||||
|
@ -74,8 +74,8 @@ test(function booleanAndAliasWithOptionsHash() {
|
|||
h: true,
|
||||
_: ["derp"]
|
||||
};
|
||||
assertEq(aliasedArgv, expected);
|
||||
assertEq(propertyArgv, expected);
|
||||
assertEquals(aliasedArgv, expected);
|
||||
assertEquals(propertyArgv, expected);
|
||||
});
|
||||
|
||||
test(function booleanAndAliasArrayWithOptionsHash() {
|
||||
|
@ -95,9 +95,9 @@ test(function booleanAndAliasArrayWithOptionsHash() {
|
|||
h: true,
|
||||
_: ["derp"]
|
||||
};
|
||||
assertEq(aliasedArgv, expected);
|
||||
assertEq(propertyArgv, expected);
|
||||
assertEq(altPropertyArgv, expected);
|
||||
assertEquals(aliasedArgv, expected);
|
||||
assertEquals(propertyArgv, expected);
|
||||
assertEquals(altPropertyArgv, expected);
|
||||
});
|
||||
|
||||
test(function booleanAndAliasUsingExplicitTrue() {
|
||||
|
@ -115,8 +115,8 @@ test(function booleanAndAliasUsingExplicitTrue() {
|
|||
_: []
|
||||
};
|
||||
|
||||
assertEq(aliasedArgv, expected);
|
||||
assertEq(propertyArgv, expected);
|
||||
assertEquals(aliasedArgv, expected);
|
||||
assertEquals(propertyArgv, expected);
|
||||
});
|
||||
|
||||
// regression, see https://github.com/substack/node-optimist/issues/71
|
||||
|
@ -126,15 +126,15 @@ test(function booleanAndNonBoolean() {
|
|||
boolean: "boool"
|
||||
});
|
||||
|
||||
assertEq(parsed.boool, true);
|
||||
assertEq(parsed.other, "true");
|
||||
assertEquals(parsed.boool, true);
|
||||
assertEquals(parsed.other, "true");
|
||||
|
||||
const parsed2 = parse(["--boool", "--other=false"], {
|
||||
boolean: "boool"
|
||||
});
|
||||
|
||||
assertEq(parsed2.boool, true);
|
||||
assertEq(parsed2.other, "false");
|
||||
assertEquals(parsed2.boool, true);
|
||||
assertEquals(parsed2.other, "false");
|
||||
});
|
||||
|
||||
test(function booleanParsingTrue() {
|
||||
|
@ -145,7 +145,7 @@ test(function booleanParsingTrue() {
|
|||
boolean: ["boool"]
|
||||
});
|
||||
|
||||
assertEq(parsed.boool, true);
|
||||
assertEquals(parsed.boool, true);
|
||||
});
|
||||
|
||||
test(function booleanParsingFalse() {
|
||||
|
@ -156,5 +156,5 @@ test(function booleanParsingFalse() {
|
|||
boolean: ["boool"]
|
||||
});
|
||||
|
||||
assertEq(parsed.boool, false);
|
||||
assertEquals(parsed.boool, false);
|
||||
});
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function hyphen() {
|
||||
assertEq(parse(["-n", "-"]), { n: "-", _: [] });
|
||||
assertEq(parse(["-"]), { _: ["-"] });
|
||||
assertEq(parse(["-f-"]), { f: "-", _: [] });
|
||||
assertEq(parse(["-b", "-"], { boolean: "b" }), { b: true, _: ["-"] });
|
||||
assertEq(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] });
|
||||
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() {
|
||||
assertEq(parse(["-a", "--", "b"]), { a: true, _: ["b"] });
|
||||
assertEq(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
|
||||
assertEq(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
|
||||
assertEquals(parse(["-a", "--", "b"]), { a: true, _: ["b"] });
|
||||
assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
|
||||
assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
|
||||
});
|
||||
|
||||
test(function moveArgsAfterDoubleDashIntoOwnArray() {
|
||||
assertEq(parse(["--name", "John", "before", "--", "after"], { "--": true }), {
|
||||
name: "John",
|
||||
_: ["before"],
|
||||
"--": ["after"]
|
||||
});
|
||||
assertEquals(
|
||||
parse(["--name", "John", "before", "--", "after"], { "--": true }),
|
||||
{
|
||||
name: "John",
|
||||
_: ["before"],
|
||||
"--": ["after"]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function booleanDefaultTrue() {
|
||||
|
@ -8,7 +8,7 @@ test(function booleanDefaultTrue() {
|
|||
boolean: "sometrue",
|
||||
default: { sometrue: true }
|
||||
});
|
||||
assertEq(argv.sometrue, true);
|
||||
assertEquals(argv.sometrue, true);
|
||||
});
|
||||
|
||||
test(function booleanDefaultFalse() {
|
||||
|
@ -16,7 +16,7 @@ test(function booleanDefaultFalse() {
|
|||
boolean: "somefalse",
|
||||
default: { somefalse: false }
|
||||
});
|
||||
assertEq(argv.somefalse, false);
|
||||
assertEquals(argv.somefalse, false);
|
||||
});
|
||||
|
||||
test(function booleanDefaultNull() {
|
||||
|
@ -24,10 +24,10 @@ test(function booleanDefaultNull() {
|
|||
boolean: "maybe",
|
||||
default: { maybe: null }
|
||||
});
|
||||
assertEq(argv.maybe, null);
|
||||
assertEquals(argv.maybe, null);
|
||||
const argv2 = parse(["--maybe"], {
|
||||
boolean: "maybe",
|
||||
default: { maybe: null }
|
||||
});
|
||||
assertEq(argv2.maybe, true);
|
||||
assertEquals(argv2.maybe, true);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function dottedAlias() {
|
||||
|
@ -8,17 +8,17 @@ test(function dottedAlias() {
|
|||
default: { "a.b": 11 },
|
||||
alias: { "a.b": "aa.bb" }
|
||||
});
|
||||
assertEq(argv.a.b, 22);
|
||||
assertEq(argv.aa.bb, 22);
|
||||
assertEquals(argv.a.b, 22);
|
||||
assertEquals(argv.aa.bb, 22);
|
||||
});
|
||||
|
||||
test(function dottedDefault() {
|
||||
const argv = parse("", { default: { "a.b": 11 }, alias: { "a.b": "aa.bb" } });
|
||||
assertEq(argv.a.b, 11);
|
||||
assertEq(argv.aa.bb, 11);
|
||||
assertEquals(argv.a.b, 11);
|
||||
assertEquals(argv.aa.bb, 11);
|
||||
});
|
||||
|
||||
test(function dottedDefaultWithNoAlias() {
|
||||
const argv = parse("", { default: { "a.b": 11 } });
|
||||
assertEq(argv.a.b, 11);
|
||||
assertEquals(argv.a.b, 11);
|
||||
});
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function short() {
|
||||
const argv = parse(["-b=123"]);
|
||||
assertEq(argv, { b: 123, _: [] });
|
||||
assertEquals(argv, { b: 123, _: [] });
|
||||
});
|
||||
|
||||
test(function multiShort() {
|
||||
const argv = parse(["-a=whatever", "-b=robots"]);
|
||||
assertEq(argv, { a: "whatever", b: "robots", _: [] });
|
||||
assertEquals(argv, { a: "whatever", b: "robots", _: [] });
|
||||
});
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function longOpts() {
|
||||
assertEq(parse(["--bool"]), { bool: true, _: [] });
|
||||
assertEq(parse(["--pow", "xixxle"]), { pow: "xixxle", _: [] });
|
||||
assertEq(parse(["--pow=xixxle"]), { pow: "xixxle", _: [] });
|
||||
assertEq(parse(["--host", "localhost", "--port", "555"]), {
|
||||
assertEquals(parse(["--bool"]), { bool: true, _: [] });
|
||||
assertEquals(parse(["--pow", "xixxle"]), { pow: "xixxle", _: [] });
|
||||
assertEquals(parse(["--pow=xixxle"]), { pow: "xixxle", _: [] });
|
||||
assertEquals(parse(["--host", "localhost", "--port", "555"]), {
|
||||
host: "localhost",
|
||||
port: 555,
|
||||
_: []
|
||||
});
|
||||
assertEq(parse(["--host=localhost", "--port=555"]), {
|
||||
assertEquals(parse(["--host=localhost", "--port=555"]), {
|
||||
host: "localhost",
|
||||
port: 555,
|
||||
_: []
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function nums() {
|
||||
|
@ -17,7 +17,7 @@ test(function nums() {
|
|||
"0xdeadbeef",
|
||||
"789"
|
||||
]);
|
||||
assertEq(argv, {
|
||||
assertEquals(argv, {
|
||||
x: 1234,
|
||||
y: 5.67,
|
||||
z: 1e7,
|
||||
|
@ -25,17 +25,17 @@ test(function nums() {
|
|||
hex: 0xdeadbeef,
|
||||
_: [789]
|
||||
});
|
||||
assertEq(typeof argv.x, "number");
|
||||
assertEq(typeof argv.y, "number");
|
||||
assertEq(typeof argv.z, "number");
|
||||
assertEq(typeof argv.w, "string");
|
||||
assertEq(typeof argv.hex, "number");
|
||||
assertEq(typeof argv._[0], "number");
|
||||
assertEquals(typeof argv.x, "number");
|
||||
assertEquals(typeof argv.y, "number");
|
||||
assertEquals(typeof argv.z, "number");
|
||||
assertEquals(typeof argv.w, "string");
|
||||
assertEquals(typeof argv.hex, "number");
|
||||
assertEquals(typeof argv._[0], "number");
|
||||
});
|
||||
|
||||
test(function alreadyNumber() {
|
||||
const argv = parse(["-x", 1234, 789]);
|
||||
assertEq(argv, { x: 1234, _: [789] });
|
||||
assertEq(typeof argv.x, "number");
|
||||
assertEq(typeof argv._[0], "number");
|
||||
assertEquals(argv, { x: 1234, _: [789] });
|
||||
assertEquals(typeof argv.x, "number");
|
||||
assertEquals(typeof argv._[0], "number");
|
||||
});
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function _arseArgs() {
|
||||
assertEq(parse(["--no-moo"]), { moo: false, _: [] });
|
||||
assertEq(parse(["-v", "a", "-v", "b", "-v", "c"]), {
|
||||
assertEquals(parse(["--no-moo"]), { moo: false, _: [] });
|
||||
assertEquals(parse(["-v", "a", "-v", "b", "-v", "c"]), {
|
||||
v: ["a", "b", "c"],
|
||||
_: []
|
||||
});
|
||||
});
|
||||
|
||||
test(function comprehensive() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
parse([
|
||||
"--name=meowmers",
|
||||
"bare",
|
||||
|
@ -50,8 +50,8 @@ test(function comprehensive() {
|
|||
|
||||
test(function flagBoolean() {
|
||||
const argv = parse(["-t", "moo"], { boolean: "t" });
|
||||
assertEq(argv, { t: true, _: ["moo"] });
|
||||
assertEq(typeof argv.t, "boolean");
|
||||
assertEquals(argv, { t: true, _: ["moo"] });
|
||||
assertEquals(typeof argv.t, "boolean");
|
||||
});
|
||||
|
||||
test(function flagBooleanValue() {
|
||||
|
@ -60,63 +60,63 @@ test(function flagBooleanValue() {
|
|||
default: { verbose: true }
|
||||
});
|
||||
|
||||
assertEq(argv, {
|
||||
assertEquals(argv, {
|
||||
verbose: false,
|
||||
t: true,
|
||||
_: ["moo"]
|
||||
});
|
||||
|
||||
assertEq(typeof argv.verbose, "boolean");
|
||||
assertEq(typeof argv.t, "boolean");
|
||||
assertEquals(typeof argv.verbose, "boolean");
|
||||
assertEquals(typeof argv.t, "boolean");
|
||||
});
|
||||
|
||||
test(function newlinesInParams() {
|
||||
const args = parse(["-s", "X\nX"]);
|
||||
assertEq(args, { _: [], s: "X\nX" });
|
||||
assertEquals(args, { _: [], s: "X\nX" });
|
||||
|
||||
// reproduce in bash:
|
||||
// VALUE="new
|
||||
// line"
|
||||
// deno program.js --s="$VALUE"
|
||||
const args2 = parse(["--s=X\nX"]);
|
||||
assertEq(args2, { _: [], s: "X\nX" });
|
||||
assertEquals(args2, { _: [], s: "X\nX" });
|
||||
});
|
||||
|
||||
test(function strings() {
|
||||
const s = parse(["-s", "0001234"], { string: "s" }).s;
|
||||
assertEq(s, "0001234");
|
||||
assertEq(typeof s, "string");
|
||||
assertEquals(s, "0001234");
|
||||
assertEquals(typeof s, "string");
|
||||
|
||||
const x = parse(["-x", "56"], { string: "x" }).x;
|
||||
assertEq(x, "56");
|
||||
assertEq(typeof x, "string");
|
||||
assertEquals(x, "56");
|
||||
assertEquals(typeof x, "string");
|
||||
});
|
||||
|
||||
test(function stringArgs() {
|
||||
const s = parse([" ", " "], { string: "_" })._;
|
||||
assertEq(s.length, 2);
|
||||
assertEq(typeof s[0], "string");
|
||||
assertEq(s[0], " ");
|
||||
assertEq(typeof s[1], "string");
|
||||
assertEq(s[1], " ");
|
||||
assertEquals(s.length, 2);
|
||||
assertEquals(typeof s[0], "string");
|
||||
assertEquals(s[0], " ");
|
||||
assertEquals(typeof s[1], "string");
|
||||
assertEquals(s[1], " ");
|
||||
});
|
||||
|
||||
test(function emptyStrings() {
|
||||
const s = parse(["-s"], { string: "s" }).s;
|
||||
assertEq(s, "");
|
||||
assertEq(typeof s, "string");
|
||||
assertEquals(s, "");
|
||||
assertEquals(typeof s, "string");
|
||||
|
||||
const str = parse(["--str"], { string: "str" }).str;
|
||||
assertEq(str, "");
|
||||
assertEq(typeof str, "string");
|
||||
assertEquals(str, "");
|
||||
assertEquals(typeof str, "string");
|
||||
|
||||
const letters = parse(["-art"], {
|
||||
string: ["a", "t"]
|
||||
});
|
||||
|
||||
assertEq(letters.a, "");
|
||||
assertEq(letters.r, true);
|
||||
assertEq(letters.t, "");
|
||||
assertEquals(letters.a, "");
|
||||
assertEquals(letters.r, true);
|
||||
assertEquals(letters.t, "");
|
||||
});
|
||||
|
||||
test(function stringAndAlias() {
|
||||
|
@ -125,25 +125,25 @@ test(function stringAndAlias() {
|
|||
alias: { s: "str" }
|
||||
});
|
||||
|
||||
assertEq(x.str, "000123");
|
||||
assertEq(typeof x.str, "string");
|
||||
assertEq(x.s, "000123");
|
||||
assertEq(typeof x.s, "string");
|
||||
assertEquals(x.str, "000123");
|
||||
assertEquals(typeof x.str, "string");
|
||||
assertEquals(x.s, "000123");
|
||||
assertEquals(typeof x.s, "string");
|
||||
|
||||
const y = parse(["-s", "000123"], {
|
||||
string: "str",
|
||||
alias: { str: "s" }
|
||||
});
|
||||
|
||||
assertEq(y.str, "000123");
|
||||
assertEq(typeof y.str, "string");
|
||||
assertEq(y.s, "000123");
|
||||
assertEq(typeof y.s, "string");
|
||||
assertEquals(y.str, "000123");
|
||||
assertEquals(typeof y.str, "string");
|
||||
assertEquals(y.s, "000123");
|
||||
assertEquals(typeof y.s, "string");
|
||||
});
|
||||
|
||||
test(function slashBreak() {
|
||||
assertEq(parse(["-I/foo/bar/baz"]), { I: "/foo/bar/baz", _: [] });
|
||||
assertEq(parse(["-xyz/foo/bar/baz"]), {
|
||||
assertEquals(parse(["-I/foo/bar/baz"]), { I: "/foo/bar/baz", _: [] });
|
||||
assertEquals(parse(["-xyz/foo/bar/baz"]), {
|
||||
x: true,
|
||||
y: true,
|
||||
z: "/foo/bar/baz",
|
||||
|
@ -155,19 +155,19 @@ test(function alias() {
|
|||
const argv = parse(["-f", "11", "--zoom", "55"], {
|
||||
alias: { z: "zoom" }
|
||||
});
|
||||
assertEq(argv.zoom, 55);
|
||||
assertEq(argv.z, argv.zoom);
|
||||
assertEq(argv.f, 11);
|
||||
assertEquals(argv.zoom, 55);
|
||||
assertEquals(argv.z, argv.zoom);
|
||||
assertEquals(argv.f, 11);
|
||||
});
|
||||
|
||||
test(function multiAlias() {
|
||||
const argv = parse(["-f", "11", "--zoom", "55"], {
|
||||
alias: { z: ["zm", "zoom"] }
|
||||
});
|
||||
assertEq(argv.zoom, 55);
|
||||
assertEq(argv.z, argv.zoom);
|
||||
assertEq(argv.z, argv.zm);
|
||||
assertEq(argv.f, 11);
|
||||
assertEquals(argv.zoom, 55);
|
||||
assertEquals(argv.z, argv.zoom);
|
||||
assertEquals(argv.z, argv.zm);
|
||||
assertEquals(argv.f, 11);
|
||||
});
|
||||
|
||||
test(function nestedDottedObjects() {
|
||||
|
@ -182,7 +182,7 @@ test(function nestedDottedObjects() {
|
|||
"--beep.boop"
|
||||
]);
|
||||
|
||||
assertEq(argv.foo, {
|
||||
assertEquals(argv.foo, {
|
||||
bar: 3,
|
||||
baz: 4,
|
||||
quux: {
|
||||
|
@ -190,5 +190,5 @@ test(function nestedDottedObjects() {
|
|||
o_O: true
|
||||
}
|
||||
});
|
||||
assertEq(argv.beep, { boop: true });
|
||||
assertEquals(argv.beep, { boop: true });
|
||||
});
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function numbericShortArgs() {
|
||||
assertEq(parse(["-n123"]), { n: 123, _: [] });
|
||||
assertEq(parse(["-123", "456"]), { 1: true, 2: true, 3: 456, _: [] });
|
||||
assertEquals(parse(["-n123"]), { n: 123, _: [] });
|
||||
assertEquals(parse(["-123", "456"]), { 1: true, 2: true, 3: 456, _: [] });
|
||||
});
|
||||
|
||||
test(function short() {
|
||||
assertEq(parse(["-b"]), { b: true, _: [] });
|
||||
assertEq(parse(["foo", "bar", "baz"]), { _: ["foo", "bar", "baz"] });
|
||||
assertEq(parse(["-cats"]), { c: true, a: true, t: true, s: true, _: [] });
|
||||
assertEq(parse(["-cats", "meow"]), {
|
||||
assertEquals(parse(["-b"]), { b: true, _: [] });
|
||||
assertEquals(parse(["foo", "bar", "baz"]), { _: ["foo", "bar", "baz"] });
|
||||
assertEquals(parse(["-cats"]), { c: true, a: true, t: true, s: true, _: [] });
|
||||
assertEquals(parse(["-cats", "meow"]), {
|
||||
c: true,
|
||||
a: true,
|
||||
t: true,
|
||||
s: "meow",
|
||||
_: []
|
||||
});
|
||||
assertEq(parse(["-h", "localhost"]), { h: "localhost", _: [] });
|
||||
assertEq(parse(["-h", "localhost", "-p", "555"]), {
|
||||
assertEquals(parse(["-h", "localhost"]), { h: "localhost", _: [] });
|
||||
assertEquals(parse(["-h", "localhost", "-p", "555"]), {
|
||||
h: "localhost",
|
||||
p: 555,
|
||||
_: []
|
||||
|
@ -28,7 +28,7 @@ test(function short() {
|
|||
});
|
||||
|
||||
test(function mixedShortBoolAndCapture() {
|
||||
assertEq(parse(["-h", "localhost", "-fp", "555", "script.js"]), {
|
||||
assertEquals(parse(["-h", "localhost", "-fp", "555", "script.js"]), {
|
||||
f: true,
|
||||
p: 555,
|
||||
h: "localhost",
|
||||
|
@ -37,7 +37,7 @@ test(function mixedShortBoolAndCapture() {
|
|||
});
|
||||
|
||||
test(function shortAndLong() {
|
||||
assertEq(parse(["-h", "localhost", "-fp", "555", "script.js"]), {
|
||||
assertEquals(parse(["-h", "localhost", "-fp", "555", "script.js"]), {
|
||||
f: true,
|
||||
p: 555,
|
||||
h: "localhost",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
// stops parsing on the first non-option when stopEarly is set
|
||||
|
@ -9,7 +9,7 @@ test(function stopParsing() {
|
|||
stopEarly: true
|
||||
});
|
||||
|
||||
assertEq(argv, {
|
||||
assertEquals(argv, {
|
||||
aaa: "bbb",
|
||||
_: ["ccc", "--ddd"]
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function booleanAndAliasIsNotUnknown() {
|
||||
|
@ -19,7 +19,7 @@ test(function booleanAndAliasIsNotUnknown() {
|
|||
const aliasedArgv = parse(aliased, opts);
|
||||
const propertyArgv = parse(regular, opts);
|
||||
|
||||
assertEq(unknown, ["--derp", "-d"]);
|
||||
assertEquals(unknown, ["--derp", "-d"]);
|
||||
});
|
||||
|
||||
test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown() {
|
||||
|
@ -32,8 +32,8 @@ test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown() {
|
|||
boolean: true,
|
||||
unknown: unknownFn
|
||||
});
|
||||
assertEq(unknown, ["--tacos=good", "cow", "-p"]);
|
||||
assertEq(argv, {
|
||||
assertEquals(unknown, ["--tacos=good", "cow", "-p"]);
|
||||
assertEquals(argv, {
|
||||
honk: true,
|
||||
_: []
|
||||
});
|
||||
|
@ -55,7 +55,7 @@ test(function stringAndAliasIsNotUnkown() {
|
|||
const aliasedArgv = parse(aliased, opts);
|
||||
const propertyArgv = parse(regular, opts);
|
||||
|
||||
assertEq(unknown, ["--derp", "-d"]);
|
||||
assertEquals(unknown, ["--derp", "-d"]);
|
||||
});
|
||||
|
||||
test(function defaultAndAliasIsNotUnknown() {
|
||||
|
@ -74,7 +74,7 @@ test(function defaultAndAliasIsNotUnknown() {
|
|||
const aliasedArgv = parse(aliased, opts);
|
||||
const propertyArgv = parse(regular, opts);
|
||||
|
||||
assertEq(unknown, []);
|
||||
assertEquals(unknown, []);
|
||||
});
|
||||
|
||||
test(function valueFollowingDoubleHyphenIsNotUnknown() {
|
||||
|
@ -90,8 +90,8 @@ test(function valueFollowingDoubleHyphenIsNotUnknown() {
|
|||
};
|
||||
const argv = parse(aliased, opts);
|
||||
|
||||
assertEq(unknown, ["--bad"]);
|
||||
assertEq(argv, {
|
||||
assertEquals(unknown, ["--bad"]);
|
||||
assertEquals(argv, {
|
||||
"--": ["good", "arg"],
|
||||
_: []
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import { parse } from "../mod.ts";
|
||||
|
||||
test(function whitespaceShouldBeWhitespace() {
|
||||
assertEq(parse(["-x", "\t"]).x, "\t");
|
||||
assertEquals(parse(["-x", "\t"]).x, "\t");
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { mkdir, open } = Deno;
|
||||
import { FileInfo } from "deno";
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { glob } from "./glob.ts";
|
||||
import { join } from "./path.ts";
|
||||
import { testWalk } from "./walk_test.ts";
|
||||
|
@ -23,43 +23,43 @@ async function walkArray(
|
|||
const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) =>
|
||||
f.path.replace(/\\/g, "/")
|
||||
).sort();
|
||||
assertEq(arr, arr_sync);
|
||||
assertEquals(arr, arr_sync);
|
||||
return arr;
|
||||
}
|
||||
|
||||
test({
|
||||
name: "glob: glob to regex",
|
||||
fn() {
|
||||
assertEq(glob("unicorn.*") instanceof RegExp, true);
|
||||
assertEq(glob("unicorn.*").test("poney.ts"), false);
|
||||
assertEq(glob("unicorn.*").test("unicorn.py"), true);
|
||||
assertEq(glob("*.ts").test("poney.ts"), true);
|
||||
assertEq(glob("*.ts").test("unicorn.js"), false);
|
||||
assertEq(
|
||||
assertEquals(glob("unicorn.*") instanceof RegExp, true);
|
||||
assertEquals(glob("unicorn.*").test("poney.ts"), false);
|
||||
assertEquals(glob("unicorn.*").test("unicorn.py"), true);
|
||||
assertEquals(glob("*.ts").test("poney.ts"), true);
|
||||
assertEquals(glob("*.ts").test("unicorn.js"), false);
|
||||
assertEquals(
|
||||
glob(join("unicorn", "**", "cathedral.ts")).test(
|
||||
join("unicorn", "in", "the", "cathedral.ts")
|
||||
),
|
||||
true
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
glob(join("unicorn", "**", "cathedral.ts")).test(
|
||||
join("unicorn", "in", "the", "kitchen.ts")
|
||||
),
|
||||
false
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
glob(join("unicorn", "**", "bathroom.*")).test(
|
||||
join("unicorn", "sleeping", "in", "bathroom.py")
|
||||
),
|
||||
true
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
glob(join("unicorn", "!(sleeping)", "bathroom.ts"), {
|
||||
extended: true
|
||||
}).test(join("unicorn", "flying", "bathroom.ts")),
|
||||
true
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
glob(join("unicorn", "(!sleeping)", "bathroom.ts"), {
|
||||
extended: true
|
||||
}).test(join("unicorn", "sleeping", "bathroom.ts")),
|
||||
|
@ -75,8 +75,8 @@ testWalk(
|
|||
},
|
||||
async function globInWalk() {
|
||||
const arr = await walkArray(".", { match: [glob("*.ts")] });
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "./a/x.ts");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "./a/x.ts");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -90,9 +90,9 @@ testWalk(
|
|||
},
|
||||
async function globInWalkWildcardFiles() {
|
||||
const arr = await walkArray(".", { match: [glob("*.ts")] });
|
||||
assertEq(arr.length, 2);
|
||||
assertEq(arr[0], "./a/x.ts");
|
||||
assertEq(arr[1], "./b/z.ts");
|
||||
assertEquals(arr.length, 2);
|
||||
assertEquals(arr[0], "./a/x.ts");
|
||||
assertEquals(arr[1], "./b/z.ts");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -111,8 +111,8 @@ testWalk(
|
|||
})
|
||||
]
|
||||
});
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "./a/yo/x.ts");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "./a/yo/x.ts");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -135,9 +135,9 @@ testWalk(
|
|||
})
|
||||
]
|
||||
});
|
||||
assertEq(arr.length, 2);
|
||||
assertEq(arr[0], "./a/deno/x.ts");
|
||||
assertEq(arr[1], "./a/raptor/x.ts");
|
||||
assertEquals(arr.length, 2);
|
||||
assertEquals(arr[0], "./a/deno/x.ts");
|
||||
assertEquals(arr[1], "./a/raptor/x.ts");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -152,8 +152,8 @@ testWalk(
|
|||
match: [glob("x.*", { flags: "g", globstar: true })]
|
||||
});
|
||||
console.log(arr);
|
||||
assertEq(arr.length, 2);
|
||||
assertEq(arr[0], "./x.js");
|
||||
assertEq(arr[1], "./x.ts");
|
||||
assertEquals(arr.length, 2);
|
||||
assertEquals(arr[0], "./x.js");
|
||||
assertEquals(arr[1], "./x.ts");
|
||||
}
|
||||
);
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
import * as deno from "deno";
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { globrex } from "./globrex.ts";
|
||||
|
||||
const isWin = deno.platform.os === "win";
|
||||
const t = { equal: assertEq, is: assertEq };
|
||||
const t = { equal: assertEquals, is: assertEquals };
|
||||
|
||||
function match(glob, strUnix, strWin?, opts = {}) {
|
||||
if (typeof strWin === "object") {
|
||||
|
|
|
@ -2,72 +2,75 @@
|
|||
// Ported from https://github.com/browserify/path-browserify/
|
||||
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
test(function basename() {
|
||||
assertEq(path.basename(".js", ".js"), "");
|
||||
assertEq(path.basename(""), "");
|
||||
assertEq(path.basename("/dir/basename.ext"), "basename.ext");
|
||||
assertEq(path.basename("/basename.ext"), "basename.ext");
|
||||
assertEq(path.basename("basename.ext"), "basename.ext");
|
||||
assertEq(path.basename("basename.ext/"), "basename.ext");
|
||||
assertEq(path.basename("basename.ext//"), "basename.ext");
|
||||
assertEq(path.basename("aaa/bbb", "/bbb"), "bbb");
|
||||
assertEq(path.basename("aaa/bbb", "a/bbb"), "bbb");
|
||||
assertEq(path.basename("aaa/bbb", "bbb"), "bbb");
|
||||
assertEq(path.basename("aaa/bbb//", "bbb"), "bbb");
|
||||
assertEq(path.basename("aaa/bbb", "bb"), "b");
|
||||
assertEq(path.basename("aaa/bbb", "b"), "bb");
|
||||
assertEq(path.basename("/aaa/bbb", "/bbb"), "bbb");
|
||||
assertEq(path.basename("/aaa/bbb", "a/bbb"), "bbb");
|
||||
assertEq(path.basename("/aaa/bbb", "bbb"), "bbb");
|
||||
assertEq(path.basename("/aaa/bbb//", "bbb"), "bbb");
|
||||
assertEq(path.basename("/aaa/bbb", "bb"), "b");
|
||||
assertEq(path.basename("/aaa/bbb", "b"), "bb");
|
||||
assertEq(path.basename("/aaa/bbb"), "bbb");
|
||||
assertEq(path.basename("/aaa/"), "aaa");
|
||||
assertEq(path.basename("/aaa/b"), "b");
|
||||
assertEq(path.basename("/a/b"), "b");
|
||||
assertEq(path.basename("//a"), "a");
|
||||
assertEquals(path.basename(".js", ".js"), "");
|
||||
assertEquals(path.basename(""), "");
|
||||
assertEquals(path.basename("/dir/basename.ext"), "basename.ext");
|
||||
assertEquals(path.basename("/basename.ext"), "basename.ext");
|
||||
assertEquals(path.basename("basename.ext"), "basename.ext");
|
||||
assertEquals(path.basename("basename.ext/"), "basename.ext");
|
||||
assertEquals(path.basename("basename.ext//"), "basename.ext");
|
||||
assertEquals(path.basename("aaa/bbb", "/bbb"), "bbb");
|
||||
assertEquals(path.basename("aaa/bbb", "a/bbb"), "bbb");
|
||||
assertEquals(path.basename("aaa/bbb", "bbb"), "bbb");
|
||||
assertEquals(path.basename("aaa/bbb//", "bbb"), "bbb");
|
||||
assertEquals(path.basename("aaa/bbb", "bb"), "b");
|
||||
assertEquals(path.basename("aaa/bbb", "b"), "bb");
|
||||
assertEquals(path.basename("/aaa/bbb", "/bbb"), "bbb");
|
||||
assertEquals(path.basename("/aaa/bbb", "a/bbb"), "bbb");
|
||||
assertEquals(path.basename("/aaa/bbb", "bbb"), "bbb");
|
||||
assertEquals(path.basename("/aaa/bbb//", "bbb"), "bbb");
|
||||
assertEquals(path.basename("/aaa/bbb", "bb"), "b");
|
||||
assertEquals(path.basename("/aaa/bbb", "b"), "bb");
|
||||
assertEquals(path.basename("/aaa/bbb"), "bbb");
|
||||
assertEquals(path.basename("/aaa/"), "aaa");
|
||||
assertEquals(path.basename("/aaa/b"), "b");
|
||||
assertEquals(path.basename("/a/b"), "b");
|
||||
assertEquals(path.basename("//a"), "a");
|
||||
|
||||
// On unix a backslash is just treated as any other character.
|
||||
assertEq(path.posix.basename("\\dir\\basename.ext"), "\\dir\\basename.ext");
|
||||
assertEq(path.posix.basename("\\basename.ext"), "\\basename.ext");
|
||||
assertEq(path.posix.basename("basename.ext"), "basename.ext");
|
||||
assertEq(path.posix.basename("basename.ext\\"), "basename.ext\\");
|
||||
assertEq(path.posix.basename("basename.ext\\\\"), "basename.ext\\\\");
|
||||
assertEq(path.posix.basename("foo"), "foo");
|
||||
assertEquals(
|
||||
path.posix.basename("\\dir\\basename.ext"),
|
||||
"\\dir\\basename.ext"
|
||||
);
|
||||
assertEquals(path.posix.basename("\\basename.ext"), "\\basename.ext");
|
||||
assertEquals(path.posix.basename("basename.ext"), "basename.ext");
|
||||
assertEquals(path.posix.basename("basename.ext\\"), "basename.ext\\");
|
||||
assertEquals(path.posix.basename("basename.ext\\\\"), "basename.ext\\\\");
|
||||
assertEquals(path.posix.basename("foo"), "foo");
|
||||
|
||||
// POSIX filenames may include control characters
|
||||
const controlCharFilename = "Icon" + String.fromCharCode(13);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
path.posix.basename("/a/b/" + controlCharFilename),
|
||||
controlCharFilename
|
||||
);
|
||||
});
|
||||
|
||||
test(function basenameWin32() {
|
||||
assertEq(path.win32.basename("\\dir\\basename.ext"), "basename.ext");
|
||||
assertEq(path.win32.basename("\\basename.ext"), "basename.ext");
|
||||
assertEq(path.win32.basename("basename.ext"), "basename.ext");
|
||||
assertEq(path.win32.basename("basename.ext\\"), "basename.ext");
|
||||
assertEq(path.win32.basename("basename.ext\\\\"), "basename.ext");
|
||||
assertEq(path.win32.basename("foo"), "foo");
|
||||
assertEq(path.win32.basename("aaa\\bbb", "\\bbb"), "bbb");
|
||||
assertEq(path.win32.basename("aaa\\bbb", "a\\bbb"), "bbb");
|
||||
assertEq(path.win32.basename("aaa\\bbb", "bbb"), "bbb");
|
||||
assertEq(path.win32.basename("aaa\\bbb\\\\\\\\", "bbb"), "bbb");
|
||||
assertEq(path.win32.basename("aaa\\bbb", "bb"), "b");
|
||||
assertEq(path.win32.basename("aaa\\bbb", "b"), "bb");
|
||||
assertEq(path.win32.basename("C:"), "");
|
||||
assertEq(path.win32.basename("C:."), ".");
|
||||
assertEq(path.win32.basename("C:\\"), "");
|
||||
assertEq(path.win32.basename("C:\\dir\\base.ext"), "base.ext");
|
||||
assertEq(path.win32.basename("C:\\basename.ext"), "basename.ext");
|
||||
assertEq(path.win32.basename("C:basename.ext"), "basename.ext");
|
||||
assertEq(path.win32.basename("C:basename.ext\\"), "basename.ext");
|
||||
assertEq(path.win32.basename("C:basename.ext\\\\"), "basename.ext");
|
||||
assertEq(path.win32.basename("C:foo"), "foo");
|
||||
assertEq(path.win32.basename("file:stream"), "file:stream");
|
||||
assertEquals(path.win32.basename("\\dir\\basename.ext"), "basename.ext");
|
||||
assertEquals(path.win32.basename("\\basename.ext"), "basename.ext");
|
||||
assertEquals(path.win32.basename("basename.ext"), "basename.ext");
|
||||
assertEquals(path.win32.basename("basename.ext\\"), "basename.ext");
|
||||
assertEquals(path.win32.basename("basename.ext\\\\"), "basename.ext");
|
||||
assertEquals(path.win32.basename("foo"), "foo");
|
||||
assertEquals(path.win32.basename("aaa\\bbb", "\\bbb"), "bbb");
|
||||
assertEquals(path.win32.basename("aaa\\bbb", "a\\bbb"), "bbb");
|
||||
assertEquals(path.win32.basename("aaa\\bbb", "bbb"), "bbb");
|
||||
assertEquals(path.win32.basename("aaa\\bbb\\\\\\\\", "bbb"), "bbb");
|
||||
assertEquals(path.win32.basename("aaa\\bbb", "bb"), "b");
|
||||
assertEquals(path.win32.basename("aaa\\bbb", "b"), "bb");
|
||||
assertEquals(path.win32.basename("C:"), "");
|
||||
assertEquals(path.win32.basename("C:."), ".");
|
||||
assertEquals(path.win32.basename("C:\\"), "");
|
||||
assertEquals(path.win32.basename("C:\\dir\\base.ext"), "base.ext");
|
||||
assertEquals(path.win32.basename("C:\\basename.ext"), "basename.ext");
|
||||
assertEquals(path.win32.basename("C:basename.ext"), "basename.ext");
|
||||
assertEquals(path.win32.basename("C:basename.ext\\"), "basename.ext");
|
||||
assertEquals(path.win32.basename("C:basename.ext\\\\"), "basename.ext");
|
||||
assertEquals(path.win32.basename("C:foo"), "foo");
|
||||
assertEquals(path.win32.basename("file:stream"), "file:stream");
|
||||
});
|
||||
|
|
|
@ -2,61 +2,61 @@
|
|||
// Ported from https://github.com/browserify/path-browserify/
|
||||
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
test(function dirname() {
|
||||
assertEq(path.posix.dirname("/a/b/"), "/a");
|
||||
assertEq(path.posix.dirname("/a/b"), "/a");
|
||||
assertEq(path.posix.dirname("/a"), "/");
|
||||
assertEq(path.posix.dirname(""), ".");
|
||||
assertEq(path.posix.dirname("/"), "/");
|
||||
assertEq(path.posix.dirname("////"), "/");
|
||||
assertEq(path.posix.dirname("//a"), "//");
|
||||
assertEq(path.posix.dirname("foo"), ".");
|
||||
assertEquals(path.posix.dirname("/a/b/"), "/a");
|
||||
assertEquals(path.posix.dirname("/a/b"), "/a");
|
||||
assertEquals(path.posix.dirname("/a"), "/");
|
||||
assertEquals(path.posix.dirname(""), ".");
|
||||
assertEquals(path.posix.dirname("/"), "/");
|
||||
assertEquals(path.posix.dirname("////"), "/");
|
||||
assertEquals(path.posix.dirname("//a"), "//");
|
||||
assertEquals(path.posix.dirname("foo"), ".");
|
||||
});
|
||||
|
||||
test(function dirnameWin32() {
|
||||
assertEq(path.win32.dirname("c:\\"), "c:\\");
|
||||
assertEq(path.win32.dirname("c:\\foo"), "c:\\");
|
||||
assertEq(path.win32.dirname("c:\\foo\\"), "c:\\");
|
||||
assertEq(path.win32.dirname("c:\\foo\\bar"), "c:\\foo");
|
||||
assertEq(path.win32.dirname("c:\\foo\\bar\\"), "c:\\foo");
|
||||
assertEq(path.win32.dirname("c:\\foo\\bar\\baz"), "c:\\foo\\bar");
|
||||
assertEq(path.win32.dirname("\\"), "\\");
|
||||
assertEq(path.win32.dirname("\\foo"), "\\");
|
||||
assertEq(path.win32.dirname("\\foo\\"), "\\");
|
||||
assertEq(path.win32.dirname("\\foo\\bar"), "\\foo");
|
||||
assertEq(path.win32.dirname("\\foo\\bar\\"), "\\foo");
|
||||
assertEq(path.win32.dirname("\\foo\\bar\\baz"), "\\foo\\bar");
|
||||
assertEq(path.win32.dirname("c:"), "c:");
|
||||
assertEq(path.win32.dirname("c:foo"), "c:");
|
||||
assertEq(path.win32.dirname("c:foo\\"), "c:");
|
||||
assertEq(path.win32.dirname("c:foo\\bar"), "c:foo");
|
||||
assertEq(path.win32.dirname("c:foo\\bar\\"), "c:foo");
|
||||
assertEq(path.win32.dirname("c:foo\\bar\\baz"), "c:foo\\bar");
|
||||
assertEq(path.win32.dirname("file:stream"), ".");
|
||||
assertEq(path.win32.dirname("dir\\file:stream"), "dir");
|
||||
assertEq(path.win32.dirname("\\\\unc\\share"), "\\\\unc\\share");
|
||||
assertEq(path.win32.dirname("\\\\unc\\share\\foo"), "\\\\unc\\share\\");
|
||||
assertEq(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\");
|
||||
assertEq(
|
||||
assertEquals(path.win32.dirname("c:\\"), "c:\\");
|
||||
assertEquals(path.win32.dirname("c:\\foo"), "c:\\");
|
||||
assertEquals(path.win32.dirname("c:\\foo\\"), "c:\\");
|
||||
assertEquals(path.win32.dirname("c:\\foo\\bar"), "c:\\foo");
|
||||
assertEquals(path.win32.dirname("c:\\foo\\bar\\"), "c:\\foo");
|
||||
assertEquals(path.win32.dirname("c:\\foo\\bar\\baz"), "c:\\foo\\bar");
|
||||
assertEquals(path.win32.dirname("\\"), "\\");
|
||||
assertEquals(path.win32.dirname("\\foo"), "\\");
|
||||
assertEquals(path.win32.dirname("\\foo\\"), "\\");
|
||||
assertEquals(path.win32.dirname("\\foo\\bar"), "\\foo");
|
||||
assertEquals(path.win32.dirname("\\foo\\bar\\"), "\\foo");
|
||||
assertEquals(path.win32.dirname("\\foo\\bar\\baz"), "\\foo\\bar");
|
||||
assertEquals(path.win32.dirname("c:"), "c:");
|
||||
assertEquals(path.win32.dirname("c:foo"), "c:");
|
||||
assertEquals(path.win32.dirname("c:foo\\"), "c:");
|
||||
assertEquals(path.win32.dirname("c:foo\\bar"), "c:foo");
|
||||
assertEquals(path.win32.dirname("c:foo\\bar\\"), "c:foo");
|
||||
assertEquals(path.win32.dirname("c:foo\\bar\\baz"), "c:foo\\bar");
|
||||
assertEquals(path.win32.dirname("file:stream"), ".");
|
||||
assertEquals(path.win32.dirname("dir\\file:stream"), "dir");
|
||||
assertEquals(path.win32.dirname("\\\\unc\\share"), "\\\\unc\\share");
|
||||
assertEquals(path.win32.dirname("\\\\unc\\share\\foo"), "\\\\unc\\share\\");
|
||||
assertEquals(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\");
|
||||
assertEquals(
|
||||
path.win32.dirname("\\\\unc\\share\\foo\\bar"),
|
||||
"\\\\unc\\share\\foo"
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
path.win32.dirname("\\\\unc\\share\\foo\\bar\\"),
|
||||
"\\\\unc\\share\\foo"
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
path.win32.dirname("\\\\unc\\share\\foo\\bar\\baz"),
|
||||
"\\\\unc\\share\\foo\\bar"
|
||||
);
|
||||
assertEq(path.win32.dirname("/a/b/"), "/a");
|
||||
assertEq(path.win32.dirname("/a/b"), "/a");
|
||||
assertEq(path.win32.dirname("/a"), "/");
|
||||
assertEq(path.win32.dirname(""), ".");
|
||||
assertEq(path.win32.dirname("/"), "/");
|
||||
assertEq(path.win32.dirname("////"), "/");
|
||||
assertEq(path.win32.dirname("foo"), ".");
|
||||
assertEquals(path.win32.dirname("/a/b/"), "/a");
|
||||
assertEquals(path.win32.dirname("/a/b"), "/a");
|
||||
assertEquals(path.win32.dirname("/a"), "/");
|
||||
assertEquals(path.win32.dirname(""), ".");
|
||||
assertEquals(path.win32.dirname("/"), "/");
|
||||
assertEquals(path.win32.dirname("////"), "/");
|
||||
assertEquals(path.win32.dirname("foo"), ".");
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Ported from https://github.com/browserify/path-browserify/
|
||||
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
const slashRE = /\//g;
|
||||
|
@ -56,35 +56,35 @@ test(function extname() {
|
|||
pairs.forEach(function(p) {
|
||||
const input = p[0];
|
||||
const expected = p[1];
|
||||
assertEq(expected, path.posix.extname(input));
|
||||
assertEquals(expected, path.posix.extname(input));
|
||||
});
|
||||
|
||||
// On *nix, backslash is a valid name component like any other character.
|
||||
assertEq(path.posix.extname(".\\"), "");
|
||||
assertEq(path.posix.extname("..\\"), ".\\");
|
||||
assertEq(path.posix.extname("file.ext\\"), ".ext\\");
|
||||
assertEq(path.posix.extname("file.ext\\\\"), ".ext\\\\");
|
||||
assertEq(path.posix.extname("file\\"), "");
|
||||
assertEq(path.posix.extname("file\\\\"), "");
|
||||
assertEq(path.posix.extname("file.\\"), ".\\");
|
||||
assertEq(path.posix.extname("file.\\\\"), ".\\\\");
|
||||
assertEquals(path.posix.extname(".\\"), "");
|
||||
assertEquals(path.posix.extname("..\\"), ".\\");
|
||||
assertEquals(path.posix.extname("file.ext\\"), ".ext\\");
|
||||
assertEquals(path.posix.extname("file.ext\\\\"), ".ext\\\\");
|
||||
assertEquals(path.posix.extname("file\\"), "");
|
||||
assertEquals(path.posix.extname("file\\\\"), "");
|
||||
assertEquals(path.posix.extname("file.\\"), ".\\");
|
||||
assertEquals(path.posix.extname("file.\\\\"), ".\\\\");
|
||||
});
|
||||
|
||||
test(function extnameWin32() {
|
||||
pairs.forEach(function(p) {
|
||||
const input = p[0].replace(slashRE, "\\");
|
||||
const expected = p[1];
|
||||
assertEq(expected, path.win32.extname(input));
|
||||
assertEq(expected, path.win32.extname("C:" + input));
|
||||
assertEquals(expected, path.win32.extname(input));
|
||||
assertEquals(expected, path.win32.extname("C:" + input));
|
||||
});
|
||||
|
||||
// On Windows, backslash is a path separator.
|
||||
assertEq(path.win32.extname(".\\"), "");
|
||||
assertEq(path.win32.extname("..\\"), "");
|
||||
assertEq(path.win32.extname("file.ext\\"), ".ext");
|
||||
assertEq(path.win32.extname("file.ext\\\\"), ".ext");
|
||||
assertEq(path.win32.extname("file\\"), "");
|
||||
assertEq(path.win32.extname("file\\\\"), "");
|
||||
assertEq(path.win32.extname("file.\\"), ".");
|
||||
assertEq(path.win32.extname("file.\\\\"), ".");
|
||||
assertEquals(path.win32.extname(".\\"), "");
|
||||
assertEquals(path.win32.extname("..\\"), "");
|
||||
assertEquals(path.win32.extname("file.ext\\"), ".ext");
|
||||
assertEquals(path.win32.extname("file.ext\\\\"), ".ext");
|
||||
assertEquals(path.win32.extname("file\\"), "");
|
||||
assertEquals(path.win32.extname("file\\\\"), "");
|
||||
assertEquals(path.win32.extname("file.\\"), ".");
|
||||
assertEquals(path.win32.extname("file.\\\\"), ".");
|
||||
});
|
||||
|
|
|
@ -2,33 +2,33 @@
|
|||
// Ported from https://github.com/browserify/path-browserify/
|
||||
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
test(function isAbsolute() {
|
||||
assertEq(path.posix.isAbsolute("/home/foo"), true);
|
||||
assertEq(path.posix.isAbsolute("/home/foo/.."), true);
|
||||
assertEq(path.posix.isAbsolute("bar/"), false);
|
||||
assertEq(path.posix.isAbsolute("./baz"), false);
|
||||
assertEquals(path.posix.isAbsolute("/home/foo"), true);
|
||||
assertEquals(path.posix.isAbsolute("/home/foo/.."), true);
|
||||
assertEquals(path.posix.isAbsolute("bar/"), false);
|
||||
assertEquals(path.posix.isAbsolute("./baz"), false);
|
||||
});
|
||||
|
||||
test(function isAbsoluteWin32() {
|
||||
assertEq(path.win32.isAbsolute("/"), true);
|
||||
assertEq(path.win32.isAbsolute("//"), true);
|
||||
assertEq(path.win32.isAbsolute("//server"), true);
|
||||
assertEq(path.win32.isAbsolute("//server/file"), true);
|
||||
assertEq(path.win32.isAbsolute("\\\\server\\file"), true);
|
||||
assertEq(path.win32.isAbsolute("\\\\server"), true);
|
||||
assertEq(path.win32.isAbsolute("\\\\"), true);
|
||||
assertEq(path.win32.isAbsolute("c"), false);
|
||||
assertEq(path.win32.isAbsolute("c:"), false);
|
||||
assertEq(path.win32.isAbsolute("c:\\"), true);
|
||||
assertEq(path.win32.isAbsolute("c:/"), true);
|
||||
assertEq(path.win32.isAbsolute("c://"), true);
|
||||
assertEq(path.win32.isAbsolute("C:/Users/"), true);
|
||||
assertEq(path.win32.isAbsolute("C:\\Users\\"), true);
|
||||
assertEq(path.win32.isAbsolute("C:cwd/another"), false);
|
||||
assertEq(path.win32.isAbsolute("C:cwd\\another"), false);
|
||||
assertEq(path.win32.isAbsolute("directory/directory"), false);
|
||||
assertEq(path.win32.isAbsolute("directory\\directory"), false);
|
||||
assertEquals(path.win32.isAbsolute("/"), true);
|
||||
assertEquals(path.win32.isAbsolute("//"), true);
|
||||
assertEquals(path.win32.isAbsolute("//server"), true);
|
||||
assertEquals(path.win32.isAbsolute("//server/file"), true);
|
||||
assertEquals(path.win32.isAbsolute("\\\\server\\file"), true);
|
||||
assertEquals(path.win32.isAbsolute("\\\\server"), true);
|
||||
assertEquals(path.win32.isAbsolute("\\\\"), true);
|
||||
assertEquals(path.win32.isAbsolute("c"), false);
|
||||
assertEquals(path.win32.isAbsolute("c:"), false);
|
||||
assertEquals(path.win32.isAbsolute("c:\\"), true);
|
||||
assertEquals(path.win32.isAbsolute("c:/"), true);
|
||||
assertEquals(path.win32.isAbsolute("c://"), true);
|
||||
assertEquals(path.win32.isAbsolute("C:/Users/"), true);
|
||||
assertEquals(path.win32.isAbsolute("C:\\Users\\"), true);
|
||||
assertEquals(path.win32.isAbsolute("C:cwd/another"), false);
|
||||
assertEquals(path.win32.isAbsolute("C:cwd\\another"), false);
|
||||
assertEquals(path.win32.isAbsolute("directory/directory"), false);
|
||||
assertEquals(path.win32.isAbsolute("directory\\directory"), false);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
const backslashRE = /\\/g;
|
||||
|
@ -109,17 +109,17 @@ const windowsJoinTests = [
|
|||
test(function join() {
|
||||
joinTests.forEach(function(p) {
|
||||
const actual = path.posix.join.apply(null, p[0]);
|
||||
assertEq(actual, p[1]);
|
||||
assertEquals(actual, p[1]);
|
||||
});
|
||||
});
|
||||
|
||||
test(function joinWin32() {
|
||||
joinTests.forEach(function(p) {
|
||||
const actual = path.win32.join.apply(null, p[0]).replace(backslashRE, "/");
|
||||
assertEq(actual, p[1]);
|
||||
assertEquals(actual, p[1]);
|
||||
});
|
||||
windowsJoinTests.forEach(function(p) {
|
||||
const actual = path.win32.join.apply(null, p[0]);
|
||||
assertEq(actual, p[1]);
|
||||
assertEquals(actual, p[1]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Ported from https://github.com/browserify/path-browserify/
|
||||
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
const winPaths = [
|
||||
|
@ -131,15 +131,15 @@ function checkParseFormat(path, paths) {
|
|||
paths.forEach(function(p) {
|
||||
const element = p[0];
|
||||
const output = path.parse(element);
|
||||
assertEq(typeof output.root, "string");
|
||||
assertEq(typeof output.dir, "string");
|
||||
assertEq(typeof output.base, "string");
|
||||
assertEq(typeof output.ext, "string");
|
||||
assertEq(typeof output.name, "string");
|
||||
assertEq(path.format(output), element);
|
||||
assertEq(output.rooroot, undefined);
|
||||
assertEq(output.dir, output.dir ? path.dirname(element) : "");
|
||||
assertEq(output.base, path.basename(element));
|
||||
assertEquals(typeof output.root, "string");
|
||||
assertEquals(typeof output.dir, "string");
|
||||
assertEquals(typeof output.base, "string");
|
||||
assertEquals(typeof output.ext, "string");
|
||||
assertEquals(typeof output.name, "string");
|
||||
assertEquals(path.format(output), element);
|
||||
assertEquals(output.rooroot, undefined);
|
||||
assertEquals(output.dir, output.dir ? path.dirname(element) : "");
|
||||
assertEquals(output.base, path.basename(element));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -149,14 +149,14 @@ function checkSpecialCaseParseFormat(path, testCases) {
|
|||
const expect = testCase[1];
|
||||
const output = path.parse(element);
|
||||
Object.keys(expect).forEach(function(key) {
|
||||
assertEq(output[key], expect[key]);
|
||||
assertEquals(output[key], expect[key]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function checkFormat(path, testCases) {
|
||||
testCases.forEach(function(testCase) {
|
||||
assertEq(path.format(testCase[0]), testCase[1]);
|
||||
assertEquals(path.format(testCase[0]), testCase[1]);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ test(function parseTrailingWin32() {
|
|||
windowsTrailingTests.forEach(function(p) {
|
||||
const actual = path.win32.parse(p[0] as string);
|
||||
const expected = p[1];
|
||||
assertEq(actual, expected);
|
||||
assertEquals(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -172,6 +172,6 @@ test(function parseTrailing() {
|
|||
posixTrailingTests.forEach(function(p) {
|
||||
const actual = path.posix.parse(p[0] as string);
|
||||
const expected = p[1];
|
||||
assertEq(actual, expected);
|
||||
assertEquals(actual, expected);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Ported from https://github.com/browserify/path-browserify/
|
||||
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
const relativeTests = {
|
||||
|
@ -60,7 +60,7 @@ test(function relative() {
|
|||
relativeTests.posix.forEach(function(p) {
|
||||
const expected = p[2];
|
||||
const actual = path.posix.relative(p[0], p[1]);
|
||||
assertEq(actual, expected);
|
||||
assertEquals(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -68,6 +68,6 @@ test(function relativeWin32() {
|
|||
relativeTests.win32.forEach(function(p) {
|
||||
const expected = p[2];
|
||||
const actual = path.win32.relative(p[0], p[1]);
|
||||
assertEq(actual, expected);
|
||||
assertEquals(actual, expected);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
const { cwd } = Deno;
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
const windowsTests =
|
||||
|
@ -38,13 +38,13 @@ const posixTests =
|
|||
test(function resolve() {
|
||||
posixTests.forEach(function(p) {
|
||||
const actual = path.posix.resolve.apply(null, p[0]);
|
||||
assertEq(actual, p[1]);
|
||||
assertEquals(actual, p[1]);
|
||||
});
|
||||
});
|
||||
|
||||
test(function resolveWin32() {
|
||||
windowsTests.forEach(function(p) {
|
||||
const actual = path.win32.resolve.apply(null, p[0]);
|
||||
assertEq(actual, p[1]);
|
||||
assertEquals(actual, p[1]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
const { cwd } = Deno;
|
||||
import { test } from "../../testing/mod.ts";
|
||||
import { assertEq } from "../../testing/asserts.ts";
|
||||
import { assertEquals } from "../../testing/asserts.ts";
|
||||
import * as path from "./mod.ts";
|
||||
|
||||
const pwd = cwd();
|
||||
|
@ -11,37 +11,37 @@ const pwd = cwd();
|
|||
test(function joinZeroLength() {
|
||||
// join will internally ignore all the zero-length strings and it will return
|
||||
// '.' if the joined string is a zero-length string.
|
||||
assertEq(path.posix.join(""), ".");
|
||||
assertEq(path.posix.join("", ""), ".");
|
||||
if (path.win32) assertEq(path.win32.join(""), ".");
|
||||
if (path.win32) assertEq(path.win32.join("", ""), ".");
|
||||
assertEq(path.join(pwd), pwd);
|
||||
assertEq(path.join(pwd, ""), pwd);
|
||||
assertEquals(path.posix.join(""), ".");
|
||||
assertEquals(path.posix.join("", ""), ".");
|
||||
if (path.win32) assertEquals(path.win32.join(""), ".");
|
||||
if (path.win32) assertEquals(path.win32.join("", ""), ".");
|
||||
assertEquals(path.join(pwd), pwd);
|
||||
assertEquals(path.join(pwd, ""), pwd);
|
||||
});
|
||||
|
||||
test(function normalizeZeroLength() {
|
||||
// normalize will return '.' if the input is a zero-length string
|
||||
assertEq(path.posix.normalize(""), ".");
|
||||
if (path.win32) assertEq(path.win32.normalize(""), ".");
|
||||
assertEq(path.normalize(pwd), pwd);
|
||||
assertEquals(path.posix.normalize(""), ".");
|
||||
if (path.win32) assertEquals(path.win32.normalize(""), ".");
|
||||
assertEquals(path.normalize(pwd), pwd);
|
||||
});
|
||||
|
||||
test(function isAbsoluteZeroLength() {
|
||||
// Since '' is not a valid path in any of the common environments, return false
|
||||
assertEq(path.posix.isAbsolute(""), false);
|
||||
if (path.win32) assertEq(path.win32.isAbsolute(""), false);
|
||||
assertEquals(path.posix.isAbsolute(""), false);
|
||||
if (path.win32) assertEquals(path.win32.isAbsolute(""), false);
|
||||
});
|
||||
|
||||
test(function resolveZeroLength() {
|
||||
// resolve, internally ignores all the zero-length strings and returns the
|
||||
// current working directory
|
||||
assertEq(path.resolve(""), pwd);
|
||||
assertEq(path.resolve("", ""), pwd);
|
||||
assertEquals(path.resolve(""), pwd);
|
||||
assertEquals(path.resolve("", ""), pwd);
|
||||
});
|
||||
|
||||
test(function relativeZeroLength() {
|
||||
// relative, internally calls resolve. So, '' is actually the current directory
|
||||
assertEq(path.relative("", pwd), "");
|
||||
assertEq(path.relative(pwd, ""), "");
|
||||
assertEq(path.relative(pwd, pwd), "");
|
||||
assertEquals(path.relative("", pwd), "");
|
||||
assertEquals(path.relative(pwd, ""), "");
|
||||
assertEquals(path.relative(pwd, pwd), "");
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ const {
|
|||
import { FileInfo } from "deno";
|
||||
import { walk, walkSync, WalkOptions } from "./walk.ts";
|
||||
import { test, TestFunction } from "../testing/mod.ts";
|
||||
import { assert, assertEq } from "../testing/asserts.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
|
||||
const isWindows = platform.os === "win";
|
||||
|
||||
|
@ -47,7 +47,7 @@ async function walkArray(
|
|||
const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) =>
|
||||
f.path.replace(/\\/g, "/")
|
||||
).sort();
|
||||
assertEq(arr, arr_sync);
|
||||
assertEquals(arr, arr_sync);
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ async function touch(path: string): Promise<void> {
|
|||
}
|
||||
function assertReady(expectedLength: number) {
|
||||
const arr = Array.from(walkSync(), (f: FileInfo) => f.path);
|
||||
assertEq(arr.length, expectedLength);
|
||||
assertEquals(arr.length, expectedLength);
|
||||
}
|
||||
|
||||
testWalk(
|
||||
|
@ -65,7 +65,7 @@ testWalk(
|
|||
},
|
||||
async function emptyDir() {
|
||||
const arr = await walkArray();
|
||||
assertEq(arr.length, 0);
|
||||
assertEquals(arr.length, 0);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -75,8 +75,8 @@ testWalk(
|
|||
},
|
||||
async function singleFile() {
|
||||
const arr = await walkArray();
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "./x");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "./x");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -89,11 +89,11 @@ testWalk(
|
|||
for (const f of walkSync()) {
|
||||
count += 1;
|
||||
}
|
||||
assertEq(count, 1);
|
||||
assertEquals(count, 1);
|
||||
for await (const f of walk()) {
|
||||
count += 1;
|
||||
}
|
||||
assertEq(count, 2);
|
||||
assertEquals(count, 2);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -104,8 +104,8 @@ testWalk(
|
|||
},
|
||||
async function nestedSingleFile() {
|
||||
const arr = await walkArray();
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "./a/x");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "./a/x");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -117,10 +117,10 @@ testWalk(
|
|||
async function depth() {
|
||||
assertReady(1);
|
||||
const arr_3 = await walkArray(".", { maxDepth: 3 });
|
||||
assertEq(arr_3.length, 0);
|
||||
assertEquals(arr_3.length, 0);
|
||||
const arr_5 = await walkArray(".", { maxDepth: 5 });
|
||||
assertEq(arr_5.length, 1);
|
||||
assertEq(arr_5[0], "./a/b/c/d/x");
|
||||
assertEquals(arr_5.length, 1);
|
||||
assertEquals(arr_5[0], "./a/b/c/d/x");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -132,8 +132,8 @@ testWalk(
|
|||
async function ext() {
|
||||
assertReady(2);
|
||||
const arr = await walkArray(".", { exts: [".ts"] });
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "./x.ts");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "./x.ts");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -146,9 +146,9 @@ testWalk(
|
|||
async function extAny() {
|
||||
assertReady(3);
|
||||
const arr = await walkArray(".", { exts: [".rs", ".ts"] });
|
||||
assertEq(arr.length, 2);
|
||||
assertEq(arr[0], "./x.ts");
|
||||
assertEq(arr[1], "./y.rs");
|
||||
assertEquals(arr.length, 2);
|
||||
assertEquals(arr[0], "./x.ts");
|
||||
assertEquals(arr[1], "./y.rs");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -160,8 +160,8 @@ testWalk(
|
|||
async function match() {
|
||||
assertReady(2);
|
||||
const arr = await walkArray(".", { match: [/x/] });
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "./x");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "./x");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -174,9 +174,9 @@ testWalk(
|
|||
async function matchAny() {
|
||||
assertReady(3);
|
||||
const arr = await walkArray(".", { match: [/x/, /y/] });
|
||||
assertEq(arr.length, 2);
|
||||
assertEq(arr[0], "./x");
|
||||
assertEq(arr[1], "./y");
|
||||
assertEquals(arr.length, 2);
|
||||
assertEquals(arr[0], "./x");
|
||||
assertEquals(arr[1], "./y");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -188,8 +188,8 @@ testWalk(
|
|||
async function skip() {
|
||||
assertReady(2);
|
||||
const arr = await walkArray(".", { skip: [/x/] });
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "./y");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "./y");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -202,8 +202,8 @@ testWalk(
|
|||
async function skipAny() {
|
||||
assertReady(3);
|
||||
const arr = await walkArray(".", { skip: [/x/, /y/] });
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "./z");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "./z");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -218,19 +218,19 @@ testWalk(
|
|||
async function subDir() {
|
||||
assertReady(3);
|
||||
const arr = await walkArray("b");
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], "b/z");
|
||||
assertEquals(arr.length, 1);
|
||||
assertEquals(arr[0], "b/z");
|
||||
}
|
||||
);
|
||||
|
||||
testWalk(async (d: string) => {}, async function onError() {
|
||||
assertReady(0);
|
||||
const ignored = await walkArray("missing");
|
||||
assertEq(ignored.length, 0);
|
||||
assertEquals(ignored.length, 0);
|
||||
let errors = 0;
|
||||
const arr = await walkArray("missing", { onError: e => (errors += 1) });
|
||||
// It's 2 since walkArray iterates over both sync and async.
|
||||
assertEq(errors, 2);
|
||||
assertEquals(errors, 2);
|
||||
});
|
||||
|
||||
testWalk(
|
||||
|
@ -255,11 +255,11 @@ testWalk(
|
|||
|
||||
assertReady(3);
|
||||
const files = await walkArray("a");
|
||||
assertEq(files.length, 2);
|
||||
assertEquals(files.length, 2);
|
||||
assert(!files.includes("a/bb/z"));
|
||||
|
||||
const arr = await walkArray("a", { followSymlinks: true });
|
||||
assertEq(arr.length, 3);
|
||||
assertEquals(arr.length, 3);
|
||||
assert(arr.some(f => f.endsWith("/b/z")));
|
||||
}
|
||||
);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
const { readFile, run } = Deno;
|
||||
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assert, assertEq } from "../testing/asserts.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import { BufReader } from "../io/bufio.ts";
|
||||
import { TextProtoReader } from "../textproto/mod.ts";
|
||||
|
||||
|
@ -36,12 +36,12 @@ test(async function serveFile() {
|
|||
const res = await fetch("http://localhost:4500/azure-pipelines.yml");
|
||||
assert(res.headers.has("access-control-allow-origin"));
|
||||
assert(res.headers.has("access-control-allow-headers"));
|
||||
assertEq(res.headers.get("content-type"), "text/yaml; charset=utf-8");
|
||||
assertEquals(res.headers.get("content-type"), "text/yaml; charset=utf-8");
|
||||
const downloadedFile = await res.text();
|
||||
const localFile = new TextDecoder().decode(
|
||||
await readFile("./azure-pipelines.yml")
|
||||
);
|
||||
assertEq(downloadedFile, localFile);
|
||||
assertEquals(downloadedFile, localFile);
|
||||
} finally {
|
||||
killFileServer();
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ test(async function serveFallback() {
|
|||
const res = await fetch("http://localhost:4500/badfile.txt");
|
||||
assert(res.headers.has("access-control-allow-origin"));
|
||||
assert(res.headers.has("access-control-allow-headers"));
|
||||
assertEq(res.status, 404);
|
||||
assertEquals(res.status, 404);
|
||||
} finally {
|
||||
killFileServer();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
const { Buffer } = Deno;
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { Response, ServerRequest } from "./server.ts";
|
||||
import { BufReader, BufWriter } from "../io/bufio.ts";
|
||||
|
||||
|
@ -47,7 +47,7 @@ test(async function responseWrite() {
|
|||
request.w = bufw;
|
||||
|
||||
await request.respond(testCase.response);
|
||||
assertEq(buf.toString(), testCase.raw);
|
||||
assertEquals(buf.toString(), testCase.raw);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -59,7 +59,7 @@ test(async function requestBodyWithContentLength() {
|
|||
const buf = new Buffer(enc.encode("Hello"));
|
||||
req.r = new BufReader(buf);
|
||||
const body = dec.decode(await req.body());
|
||||
assertEq(body, "Hello");
|
||||
assertEquals(body, "Hello");
|
||||
}
|
||||
|
||||
// Larger than internal buf
|
||||
|
@ -71,7 +71,7 @@ test(async function requestBodyWithContentLength() {
|
|||
const buf = new Buffer(enc.encode(longText));
|
||||
req.r = new BufReader(buf);
|
||||
const body = dec.decode(await req.body());
|
||||
assertEq(body, longText);
|
||||
assertEquals(body, longText);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -96,7 +96,7 @@ test(async function requestBodyWithTransferEncoding() {
|
|||
const buf = new Buffer(enc.encode(chunksData));
|
||||
req.r = new BufReader(buf);
|
||||
const body = dec.decode(await req.body());
|
||||
assertEq(body, shortText);
|
||||
assertEquals(body, shortText);
|
||||
}
|
||||
|
||||
// Larger than internal buf
|
||||
|
@ -120,7 +120,7 @@ test(async function requestBodyWithTransferEncoding() {
|
|||
const buf = new Buffer(enc.encode(chunksData));
|
||||
req.r = new BufReader(buf);
|
||||
const body = dec.decode(await req.body());
|
||||
assertEq(body, longText);
|
||||
assertEquals(body, longText);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -136,7 +136,7 @@ test(async function requestBodyStreamWithContentLength() {
|
|||
let offset = 0;
|
||||
for await (const chunk of it) {
|
||||
const s = dec.decode(chunk);
|
||||
assertEq(shortText.substr(offset, s.length), s);
|
||||
assertEquals(shortText.substr(offset, s.length), s);
|
||||
offset += s.length;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ test(async function requestBodyStreamWithContentLength() {
|
|||
let offset = 0;
|
||||
for await (const chunk of it) {
|
||||
const s = dec.decode(chunk);
|
||||
assertEq(longText.substr(offset, s.length), s);
|
||||
assertEquals(longText.substr(offset, s.length), s);
|
||||
offset += s.length;
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ test(async function requestBodyStreamWithTransferEncoding() {
|
|||
let offset = 0;
|
||||
for await (const chunk of it) {
|
||||
const s = dec.decode(chunk);
|
||||
assertEq(shortText.substr(offset, s.length), s);
|
||||
assertEquals(shortText.substr(offset, s.length), s);
|
||||
offset += s.length;
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ test(async function requestBodyStreamWithTransferEncoding() {
|
|||
let offset = 0;
|
||||
for await (const chunk of it) {
|
||||
const s = dec.decode(chunk);
|
||||
assertEq(longText.substr(offset, s.length), s);
|
||||
assertEquals(longText.substr(offset, s.length), s);
|
||||
offset += s.length;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
const { Buffer } = Deno;
|
||||
import { Reader, ReadResult } from "deno";
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assert, assertEq } from "../testing/asserts.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import { BufReader, BufWriter } from "./bufio.ts";
|
||||
import * as iotest from "./iotest.ts";
|
||||
import { charCode, copyBytes, stringsReader } from "./util.ts";
|
||||
|
@ -32,7 +32,7 @@ test(async function bufioReaderSimple() {
|
|||
const data = "hello world";
|
||||
const b = new BufReader(stringsReader(data));
|
||||
const s = await readBytes(b);
|
||||
assertEq(s, data);
|
||||
assertEquals(s, data);
|
||||
});
|
||||
|
||||
interface ReadMaker {
|
||||
|
@ -114,7 +114,7 @@ test(async function bufioBufReader() {
|
|||
const debugStr =
|
||||
`reader=${readmaker.name} ` +
|
||||
`fn=${bufreader.name} bufsize=${bufsize} want=${text} got=${s}`;
|
||||
assertEq(s, text, debugStr);
|
||||
assertEquals(s, text, debugStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,12 +129,12 @@ test(async function bufioBufferFull() {
|
|||
|
||||
const decoder = new TextDecoder();
|
||||
let actual = decoder.decode(line);
|
||||
assertEq(err, "BufferFull");
|
||||
assertEq(actual, "And now, hello, ");
|
||||
assertEquals(err, "BufferFull");
|
||||
assertEquals(actual, "And now, hello, ");
|
||||
|
||||
[line, err] = await buf.readSlice(charCode("!"));
|
||||
actual = decoder.decode(line);
|
||||
assertEq(actual, "world!");
|
||||
assertEquals(actual, "world!");
|
||||
assert(err == null);
|
||||
});
|
||||
|
||||
|
@ -178,20 +178,20 @@ async function testReadLine(input: Uint8Array): Promise<void> {
|
|||
if (line.byteLength > 0 && err != null) {
|
||||
throw Error("readLine returned both data and error");
|
||||
}
|
||||
assertEq(isPrefix, false);
|
||||
assertEquals(isPrefix, false);
|
||||
if (err == "EOF") {
|
||||
break;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
let want = testOutput.subarray(done, done + line.byteLength);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
line,
|
||||
want,
|
||||
`Bad line at stride ${stride}: want: ${want} got: ${line}`
|
||||
);
|
||||
done += line.byteLength;
|
||||
}
|
||||
assertEq(
|
||||
assertEquals(
|
||||
done,
|
||||
testOutput.byteLength,
|
||||
`readLine didn't return everything: got: ${done}, ` +
|
||||
|
@ -215,54 +215,54 @@ test(async function bufioPeek() {
|
|||
);
|
||||
|
||||
let [actual, err] = await buf.peek(1);
|
||||
assertEq(decoder.decode(actual), "a");
|
||||
assertEquals(decoder.decode(actual), "a");
|
||||
assert(err == null);
|
||||
|
||||
[actual, err] = await buf.peek(4);
|
||||
assertEq(decoder.decode(actual), "abcd");
|
||||
assertEquals(decoder.decode(actual), "abcd");
|
||||
assert(err == null);
|
||||
|
||||
[actual, err] = await buf.peek(32);
|
||||
assertEq(decoder.decode(actual), "abcdefghijklmnop");
|
||||
assertEq(err, "BufferFull");
|
||||
assertEquals(decoder.decode(actual), "abcdefghijklmnop");
|
||||
assertEquals(err, "BufferFull");
|
||||
|
||||
await buf.read(p.subarray(0, 3));
|
||||
assertEq(decoder.decode(p.subarray(0, 3)), "abc");
|
||||
assertEquals(decoder.decode(p.subarray(0, 3)), "abc");
|
||||
|
||||
[actual, err] = await buf.peek(1);
|
||||
assertEq(decoder.decode(actual), "d");
|
||||
assertEquals(decoder.decode(actual), "d");
|
||||
assert(err == null);
|
||||
|
||||
[actual, err] = await buf.peek(1);
|
||||
assertEq(decoder.decode(actual), "d");
|
||||
assertEquals(decoder.decode(actual), "d");
|
||||
assert(err == null);
|
||||
|
||||
[actual, err] = await buf.peek(1);
|
||||
assertEq(decoder.decode(actual), "d");
|
||||
assertEquals(decoder.decode(actual), "d");
|
||||
assert(err == null);
|
||||
|
||||
[actual, err] = await buf.peek(2);
|
||||
assertEq(decoder.decode(actual), "de");
|
||||
assertEquals(decoder.decode(actual), "de");
|
||||
assert(err == null);
|
||||
|
||||
let { eof } = await buf.read(p.subarray(0, 3));
|
||||
assertEq(decoder.decode(p.subarray(0, 3)), "def");
|
||||
assertEquals(decoder.decode(p.subarray(0, 3)), "def");
|
||||
assert(!eof);
|
||||
assert(err == null);
|
||||
|
||||
[actual, err] = await buf.peek(4);
|
||||
assertEq(decoder.decode(actual), "ghij");
|
||||
assertEquals(decoder.decode(actual), "ghij");
|
||||
assert(err == null);
|
||||
|
||||
await buf.read(p);
|
||||
assertEq(decoder.decode(p), "ghijklmnop");
|
||||
assertEquals(decoder.decode(p), "ghijklmnop");
|
||||
|
||||
[actual, err] = await buf.peek(0);
|
||||
assertEq(decoder.decode(actual), "");
|
||||
assertEquals(decoder.decode(actual), "");
|
||||
assert(err == null);
|
||||
|
||||
[actual, err] = await buf.peek(1);
|
||||
assertEq(decoder.decode(actual), "");
|
||||
assertEquals(decoder.decode(actual), "");
|
||||
assert(err == "EOF");
|
||||
/* TODO
|
||||
// Test for issue 3022, not exposing a reader's error on a successful Peek.
|
||||
|
@ -302,15 +302,15 @@ test(async function bufioWriter() {
|
|||
|
||||
const context = `nwrite=${nwrite} bufsize=${bs}`;
|
||||
const n = await buf.write(data.subarray(0, nwrite));
|
||||
assertEq(n, nwrite, context);
|
||||
assertEquals(n, nwrite, context);
|
||||
|
||||
await buf.flush();
|
||||
|
||||
const written = w.bytes();
|
||||
assertEq(written.byteLength, nwrite);
|
||||
assertEquals(written.byteLength, nwrite);
|
||||
|
||||
for (let l = 0; l < written.byteLength; l++) {
|
||||
assertEq(written[l], data[l]);
|
||||
assertEquals(written[l], data[l]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -325,15 +325,15 @@ test(async function bufReaderReadFull() {
|
|||
{
|
||||
const buf = new Uint8Array(6);
|
||||
const [nread, err] = await bufr.readFull(buf);
|
||||
assertEq(nread, 6);
|
||||
assertEquals(nread, 6);
|
||||
assert(!err);
|
||||
assertEq(dec.decode(buf), "Hello ");
|
||||
assertEquals(dec.decode(buf), "Hello ");
|
||||
}
|
||||
{
|
||||
const buf = new Uint8Array(6);
|
||||
const [nread, err] = await bufr.readFull(buf);
|
||||
assertEq(nread, 5);
|
||||
assertEq(err, "EOF");
|
||||
assertEq(dec.decode(buf.subarray(0, 5)), "World");
|
||||
assertEquals(nread, 5);
|
||||
assertEquals(err, "EOF");
|
||||
assertEquals(dec.decode(buf.subarray(0, 5)), "World");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
const { Buffer } = Deno;
|
||||
import { Reader, ReadResult } from "deno";
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import {
|
||||
copyN,
|
||||
readInt,
|
||||
|
@ -28,13 +28,13 @@ class BinaryReader implements Reader {
|
|||
test(async function testReadShort() {
|
||||
const r = new BinaryReader(new Uint8Array([0x12, 0x34]));
|
||||
const short = await readShort(new BufReader(r));
|
||||
assertEq(short, 0x1234);
|
||||
assertEquals(short, 0x1234);
|
||||
});
|
||||
|
||||
test(async function testReadInt() {
|
||||
const r = new BinaryReader(new Uint8Array([0x12, 0x34, 0x56, 0x78]));
|
||||
const int = await readInt(new BufReader(r));
|
||||
assertEq(int, 0x12345678);
|
||||
assertEquals(int, 0x12345678);
|
||||
});
|
||||
|
||||
test(async function testReadLong() {
|
||||
|
@ -42,7 +42,7 @@ test(async function testReadLong() {
|
|||
new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78])
|
||||
);
|
||||
const long = await readLong(new BufReader(r));
|
||||
assertEq(long, 0x1234567812345678);
|
||||
assertEquals(long, 0x1234567812345678);
|
||||
});
|
||||
|
||||
test(async function testReadLong2() {
|
||||
|
@ -50,7 +50,7 @@ test(async function testReadLong2() {
|
|||
new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78])
|
||||
);
|
||||
const long = await readLong(new BufReader(r));
|
||||
assertEq(long, 0x12345678);
|
||||
assertEquals(long, 0x12345678);
|
||||
});
|
||||
|
||||
test(async function testSliceLongToBytes() {
|
||||
|
@ -63,26 +63,26 @@ test(async function testSliceLongToBytes() {
|
|||
)
|
||||
)
|
||||
);
|
||||
assertEq(actual, expected);
|
||||
assertEquals(actual, expected);
|
||||
});
|
||||
|
||||
test(async function testSliceLongToBytes2() {
|
||||
const arr = sliceLongToBytes(0x12345678);
|
||||
assertEq(arr, [0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]);
|
||||
assertEquals(arr, [0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]);
|
||||
});
|
||||
|
||||
test(async function testCopyN1() {
|
||||
const w = new Buffer();
|
||||
const r = stringsReader("abcdefghij");
|
||||
const n = await copyN(w, r, 3);
|
||||
assertEq(n, 3);
|
||||
assertEq(w.toString(), "abc");
|
||||
assertEquals(n, 3);
|
||||
assertEquals(w.toString(), "abc");
|
||||
});
|
||||
|
||||
test(async function testCopyN2() {
|
||||
const w = new Buffer();
|
||||
const r = stringsReader("abcdefghij");
|
||||
const n = await copyN(w, r, 11);
|
||||
assertEq(n, 10);
|
||||
assertEq(w.toString(), "abcdefghij");
|
||||
assertEquals(n, 10);
|
||||
assertEquals(w.toString(), "abcdefghij");
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { copy } = Deno;
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { MultiReader, StringReader } from "./readers.ts";
|
||||
import { StringWriter } from "./writers.ts";
|
||||
import { copyN } from "./ioutil.ts";
|
||||
|
@ -9,29 +9,29 @@ import { decode } from "../strings/strings.ts";
|
|||
test(async function ioStringReader() {
|
||||
const r = new StringReader("abcdef");
|
||||
const { nread, eof } = await r.read(new Uint8Array(6));
|
||||
assertEq(nread, 6);
|
||||
assertEq(eof, true);
|
||||
assertEquals(nread, 6);
|
||||
assertEquals(eof, true);
|
||||
});
|
||||
|
||||
test(async function ioStringReader() {
|
||||
const r = new StringReader("abcdef");
|
||||
const buf = new Uint8Array(3);
|
||||
let res1 = await r.read(buf);
|
||||
assertEq(res1.nread, 3);
|
||||
assertEq(res1.eof, false);
|
||||
assertEq(decode(buf), "abc");
|
||||
assertEquals(res1.nread, 3);
|
||||
assertEquals(res1.eof, false);
|
||||
assertEquals(decode(buf), "abc");
|
||||
let res2 = await r.read(buf);
|
||||
assertEq(res2.nread, 3);
|
||||
assertEq(res2.eof, true);
|
||||
assertEq(decode(buf), "def");
|
||||
assertEquals(res2.nread, 3);
|
||||
assertEquals(res2.eof, true);
|
||||
assertEquals(decode(buf), "def");
|
||||
});
|
||||
|
||||
test(async function ioMultiReader() {
|
||||
const r = new MultiReader(new StringReader("abc"), new StringReader("def"));
|
||||
const w = new StringWriter();
|
||||
const n = await copyN(w, r, 4);
|
||||
assertEq(n, 4);
|
||||
assertEq(w.toString(), "abcd");
|
||||
assertEquals(n, 4);
|
||||
assertEquals(w.toString(), "abcd");
|
||||
await copy(w, r);
|
||||
assertEq(w.toString(), "abcdef");
|
||||
assertEquals(w.toString(), "abcdef");
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
const { remove } = Deno;
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assert, assertEq } from "../testing/asserts.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import { copyBytes, tempFile } from "./util.ts";
|
||||
import * as path from "../fs/path.ts";
|
||||
|
||||
|
@ -12,31 +12,31 @@ test(function testCopyBytes() {
|
|||
let src = Uint8Array.of(1, 2);
|
||||
let len = copyBytes(dst, src, 0);
|
||||
assert(len === 2);
|
||||
assertEq(dst, Uint8Array.of(1, 2, 0, 0));
|
||||
assertEquals(dst, Uint8Array.of(1, 2, 0, 0));
|
||||
|
||||
dst.fill(0);
|
||||
src = Uint8Array.of(1, 2);
|
||||
len = copyBytes(dst, src, 1);
|
||||
assert(len === 2);
|
||||
assertEq(dst, Uint8Array.of(0, 1, 2, 0));
|
||||
assertEquals(dst, Uint8Array.of(0, 1, 2, 0));
|
||||
|
||||
dst.fill(0);
|
||||
src = Uint8Array.of(1, 2, 3, 4, 5);
|
||||
len = copyBytes(dst, src);
|
||||
assert(len === 4);
|
||||
assertEq(dst, Uint8Array.of(1, 2, 3, 4));
|
||||
assertEquals(dst, Uint8Array.of(1, 2, 3, 4));
|
||||
|
||||
dst.fill(0);
|
||||
src = Uint8Array.of(1, 2);
|
||||
len = copyBytes(dst, src, 100);
|
||||
assert(len === 0);
|
||||
assertEq(dst, Uint8Array.of(0, 0, 0, 0));
|
||||
assertEquals(dst, Uint8Array.of(0, 0, 0, 0));
|
||||
|
||||
dst.fill(0);
|
||||
src = Uint8Array.of(3, 4);
|
||||
len = copyBytes(dst, src, -2);
|
||||
assert(len === 2);
|
||||
assertEq(dst, Uint8Array.of(3, 4, 0, 0));
|
||||
assertEquals(dst, Uint8Array.of(3, 4, 0, 0));
|
||||
});
|
||||
|
||||
test(async function ioTempfile() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { copy } = Deno;
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { StringWriter } from "./writers.ts";
|
||||
import { StringReader } from "./readers.ts";
|
||||
import { copyN } from "./ioutil.ts";
|
||||
|
@ -9,7 +9,7 @@ test(async function ioStringWriter() {
|
|||
const w = new StringWriter("base");
|
||||
const r = new StringReader("0123456789");
|
||||
await copyN(w, r, 4);
|
||||
assertEq(w.toString(), "base0123");
|
||||
assertEquals(w.toString(), "base0123");
|
||||
await copy(w, r);
|
||||
assertEq(w.toString(), "base0123456789");
|
||||
assertEquals(w.toString(), "base0123456789");
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { LogLevel, getLevelName, getLevelByName } from "./levels.ts";
|
||||
import { BaseHandler } from "./handlers.ts";
|
||||
|
||||
|
@ -56,9 +56,9 @@ test(function simpleHandler() {
|
|||
});
|
||||
}
|
||||
|
||||
assertEq(handler.level, testCase);
|
||||
assertEq(handler.levelName, testLevel);
|
||||
assertEq(handler.messages, messages);
|
||||
assertEquals(handler.level, testCase);
|
||||
assertEquals(handler.levelName, testLevel);
|
||||
assertEquals(handler.messages, messages);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -75,7 +75,7 @@ test(function testFormatterAsString() {
|
|||
levelName: "DEBUG"
|
||||
});
|
||||
|
||||
assertEq(handler.messages, ["test DEBUG Hello, world!"]);
|
||||
assertEquals(handler.messages, ["test DEBUG Hello, world!"]);
|
||||
});
|
||||
|
||||
test(function testFormatterAsFunction() {
|
||||
|
@ -92,5 +92,5 @@ test(function testFormatterAsFunction() {
|
|||
levelName: "ERROR"
|
||||
});
|
||||
|
||||
assertEq(handler.messages, ["fn formmatter ERROR Hello, world!"]);
|
||||
assertEquals(handler.messages, ["fn formmatter ERROR Hello, world!"]);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { LogRecord, Logger } from "./logger.ts";
|
||||
import { LogLevel } from "./levels.ts";
|
||||
import { BaseHandler } from "./handlers.ts";
|
||||
|
@ -23,13 +23,13 @@ test(function simpleLogger() {
|
|||
const handler = new TestHandler("DEBUG");
|
||||
let logger = new Logger("DEBUG");
|
||||
|
||||
assertEq(logger.level, LogLevel.DEBUG);
|
||||
assertEq(logger.levelName, "DEBUG");
|
||||
assertEq(logger.handlers, []);
|
||||
assertEquals(logger.level, LogLevel.DEBUG);
|
||||
assertEquals(logger.levelName, "DEBUG");
|
||||
assertEquals(logger.handlers, []);
|
||||
|
||||
logger = new Logger("DEBUG", [handler]);
|
||||
|
||||
assertEq(logger.handlers, [handler]);
|
||||
assertEquals(logger.handlers, [handler]);
|
||||
});
|
||||
|
||||
test(function customHandler() {
|
||||
|
@ -38,7 +38,7 @@ test(function customHandler() {
|
|||
|
||||
logger.debug("foo", 1, 2);
|
||||
|
||||
assertEq(handler.records, [
|
||||
assertEquals(handler.records, [
|
||||
{
|
||||
msg: "foo",
|
||||
args: [1, 2],
|
||||
|
@ -48,7 +48,7 @@ test(function customHandler() {
|
|||
}
|
||||
]);
|
||||
|
||||
assertEq(handler.messages, ["DEBUG foo"]);
|
||||
assertEquals(handler.messages, ["DEBUG foo"]);
|
||||
});
|
||||
|
||||
test(function logFunctions() {
|
||||
|
@ -66,7 +66,7 @@ test(function logFunctions() {
|
|||
|
||||
doLog("DEBUG");
|
||||
|
||||
assertEq(handler.messages, [
|
||||
assertEquals(handler.messages, [
|
||||
"DEBUG foo",
|
||||
"INFO bar",
|
||||
"WARNING baz",
|
||||
|
@ -76,7 +76,7 @@ test(function logFunctions() {
|
|||
|
||||
doLog("INFO");
|
||||
|
||||
assertEq(handler.messages, [
|
||||
assertEquals(handler.messages, [
|
||||
"INFO bar",
|
||||
"WARNING baz",
|
||||
"ERROR boo",
|
||||
|
@ -85,13 +85,13 @@ test(function logFunctions() {
|
|||
|
||||
doLog("WARNING");
|
||||
|
||||
assertEq(handler.messages, ["WARNING baz", "ERROR boo", "CRITICAL doo"]);
|
||||
assertEquals(handler.messages, ["WARNING baz", "ERROR boo", "CRITICAL doo"]);
|
||||
|
||||
doLog("ERROR");
|
||||
|
||||
assertEq(handler.messages, ["ERROR boo", "CRITICAL doo"]);
|
||||
assertEquals(handler.messages, ["ERROR boo", "CRITICAL doo"]);
|
||||
|
||||
doLog("CRITICAL");
|
||||
|
||||
assertEq(handler.messages, ["CRITICAL doo"]);
|
||||
assertEquals(handler.messages, ["CRITICAL doo"]);
|
||||
});
|
||||
|
|
16
log/test.ts
16
log/test.ts
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import * as log from "./mod.ts";
|
||||
import { LogLevel } from "./levels.ts";
|
||||
|
||||
|
@ -55,7 +55,7 @@ test(async function defaultHandlers() {
|
|||
logger("foo");
|
||||
logger("bar", 1, 2);
|
||||
|
||||
assertEq(handler.messages, [`${levelName} foo`, `${levelName} bar`]);
|
||||
assertEquals(handler.messages, [`${levelName} foo`, `${levelName} bar`]);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -76,8 +76,8 @@ test(async function getLogger() {
|
|||
|
||||
const logger = log.getLogger();
|
||||
|
||||
assertEq(logger.levelName, "DEBUG");
|
||||
assertEq(logger.handlers, [handler]);
|
||||
assertEquals(logger.levelName, "DEBUG");
|
||||
assertEquals(logger.handlers, [handler]);
|
||||
});
|
||||
|
||||
test(async function getLoggerWithName() {
|
||||
|
@ -97,8 +97,8 @@ test(async function getLoggerWithName() {
|
|||
|
||||
const logger = log.getLogger("bar");
|
||||
|
||||
assertEq(logger.levelName, "INFO");
|
||||
assertEq(logger.handlers, [fooHandler]);
|
||||
assertEquals(logger.levelName, "INFO");
|
||||
assertEquals(logger.handlers, [fooHandler]);
|
||||
});
|
||||
|
||||
test(async function getLoggerUnknown() {
|
||||
|
@ -109,6 +109,6 @@ test(async function getLoggerUnknown() {
|
|||
|
||||
const logger = log.getLogger("nonexistent");
|
||||
|
||||
assertEq(logger.levelName, "NOTSET");
|
||||
assertEq(logger.handlers, []);
|
||||
assertEquals(logger.levelName, "NOTSET");
|
||||
assertEquals(logger.handlers, []);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import {
|
||||
lookup,
|
||||
contentType,
|
||||
|
@ -12,40 +12,40 @@ import {
|
|||
} from "./mod.ts";
|
||||
|
||||
test(function testLookup() {
|
||||
assertEq(lookup("json"), "application/json");
|
||||
assertEq(lookup(".md"), "text/markdown");
|
||||
assertEq(lookup("folder/file.js"), "application/javascript");
|
||||
assertEq(lookup("folder/.htaccess"), undefined);
|
||||
assertEquals(lookup("json"), "application/json");
|
||||
assertEquals(lookup(".md"), "text/markdown");
|
||||
assertEquals(lookup("folder/file.js"), "application/javascript");
|
||||
assertEquals(lookup("folder/.htaccess"), undefined);
|
||||
});
|
||||
|
||||
test(function testContentType() {
|
||||
assertEq(contentType("markdown"), "text/markdown; charset=utf-8");
|
||||
assertEq(contentType("file.json"), "application/json; charset=utf-8");
|
||||
assertEq(contentType("text/html"), "text/html; charset=utf-8");
|
||||
assertEq(
|
||||
assertEquals(contentType("markdown"), "text/markdown; charset=utf-8");
|
||||
assertEquals(contentType("file.json"), "application/json; charset=utf-8");
|
||||
assertEquals(contentType("text/html"), "text/html; charset=utf-8");
|
||||
assertEquals(
|
||||
contentType("text/html; charset=iso-8859-1"),
|
||||
"text/html; charset=iso-8859-1"
|
||||
);
|
||||
assertEq(contentType(".htaccess"), undefined);
|
||||
assertEquals(contentType(".htaccess"), undefined);
|
||||
});
|
||||
|
||||
test(function testExtension() {
|
||||
assertEq(extension("application/octet-stream"), "bin");
|
||||
assertEq(extension("application/javascript"), "js");
|
||||
assertEq(extension("text/html"), "html");
|
||||
assertEquals(extension("application/octet-stream"), "bin");
|
||||
assertEquals(extension("application/javascript"), "js");
|
||||
assertEquals(extension("text/html"), "html");
|
||||
});
|
||||
|
||||
test(function testCharset() {
|
||||
assertEq(charset("text/markdown"), "UTF-8");
|
||||
assertEq(charset("text/css"), "UTF-8");
|
||||
assertEquals(charset("text/markdown"), "UTF-8");
|
||||
assertEquals(charset("text/css"), "UTF-8");
|
||||
});
|
||||
|
||||
test(function testExtensions() {
|
||||
assertEq(extensions.get("application/javascript"), ["js", "mjs"]);
|
||||
assertEq(extensions.get("foo"), undefined);
|
||||
assertEquals(extensions.get("application/javascript"), ["js", "mjs"]);
|
||||
assertEquals(extensions.get("foo"), undefined);
|
||||
});
|
||||
|
||||
test(function testTypes() {
|
||||
assertEq(types.get("js"), "application/javascript");
|
||||
assertEq(types.get("foo"), undefined);
|
||||
assertEquals(types.get("js"), "application/javascript");
|
||||
assertEquals(types.get("foo"), undefined);
|
||||
});
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { isFormFile } from "./formfile.ts";
|
||||
|
||||
test(function multipartIsFormFile() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
isFormFile({
|
||||
filename: "foo",
|
||||
type: "application/json"
|
||||
}),
|
||||
true
|
||||
);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
isFormFile({
|
||||
filename: "foo"
|
||||
}),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
const { Buffer, copy, open, remove } = Deno;
|
||||
import {
|
||||
assert,
|
||||
assertEq,
|
||||
assertEquals,
|
||||
assertThrows,
|
||||
assertThrowsAsync
|
||||
} from "../testing/asserts.ts";
|
||||
|
@ -32,8 +32,8 @@ test(function multipartScanUntilBoundary1() {
|
|||
0,
|
||||
"EOF"
|
||||
);
|
||||
assertEq(n, 0);
|
||||
assertEq(err, "EOF");
|
||||
assertEquals(n, 0);
|
||||
assertEquals(err, "EOF");
|
||||
});
|
||||
|
||||
test(function multipartScanUntilBoundary2() {
|
||||
|
@ -45,8 +45,8 @@ test(function multipartScanUntilBoundary2() {
|
|||
0,
|
||||
"EOF"
|
||||
);
|
||||
assertEq(n, 3);
|
||||
assertEq(err, "EOF");
|
||||
assertEquals(n, 3);
|
||||
assertEquals(err, "EOF");
|
||||
});
|
||||
|
||||
test(function multipartScanUntilBoundary4() {
|
||||
|
@ -58,8 +58,8 @@ test(function multipartScanUntilBoundary4() {
|
|||
0,
|
||||
null
|
||||
);
|
||||
assertEq(n, 3);
|
||||
assertEq(err, null);
|
||||
assertEquals(n, 3);
|
||||
assertEquals(err, null);
|
||||
});
|
||||
|
||||
test(function multipartScanUntilBoundary3() {
|
||||
|
@ -71,26 +71,26 @@ test(function multipartScanUntilBoundary3() {
|
|||
0,
|
||||
null
|
||||
);
|
||||
assertEq(n, data.length);
|
||||
assertEq(err, null);
|
||||
assertEquals(n, data.length);
|
||||
assertEquals(err, null);
|
||||
});
|
||||
|
||||
test(function multipartMatchAfterPrefix1() {
|
||||
const data = `${boundary}\r`;
|
||||
const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null);
|
||||
assertEq(v, 1);
|
||||
assertEquals(v, 1);
|
||||
});
|
||||
|
||||
test(function multipartMatchAfterPrefix2() {
|
||||
const data = `${boundary}hoge`;
|
||||
const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null);
|
||||
assertEq(v, -1);
|
||||
assertEquals(v, -1);
|
||||
});
|
||||
|
||||
test(function multipartMatchAfterPrefix3() {
|
||||
const data = `${boundary}`;
|
||||
const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null);
|
||||
assertEq(v, 0);
|
||||
assertEquals(v, 0);
|
||||
});
|
||||
|
||||
test(async function multipartMultipartWriter() {
|
||||
|
@ -181,10 +181,10 @@ test(async function multipartMultipartReader() {
|
|||
"--------------------------434049563556637648550474"
|
||||
);
|
||||
const form = await mr.readForm(10 << 20);
|
||||
assertEq(form["foo"], "foo");
|
||||
assertEq(form["bar"], "bar");
|
||||
assertEquals(form["foo"], "foo");
|
||||
assertEquals(form["bar"], "bar");
|
||||
const file = form["file"] as FormFile;
|
||||
assertEq(isFormFile(file), true);
|
||||
assertEquals(isFormFile(file), true);
|
||||
assert(file.content !== void 0);
|
||||
});
|
||||
|
||||
|
@ -196,15 +196,15 @@ test(async function multipartMultipartReader2() {
|
|||
);
|
||||
const form = await mr.readForm(20); //
|
||||
try {
|
||||
assertEq(form["foo"], "foo");
|
||||
assertEq(form["bar"], "bar");
|
||||
assertEquals(form["foo"], "foo");
|
||||
assertEquals(form["bar"], "bar");
|
||||
const file = form["file"] as FormFile;
|
||||
assertEq(file.type, "application/octet-stream");
|
||||
assertEquals(file.type, "application/octet-stream");
|
||||
const f = await open(file.tempfile);
|
||||
const w = new StringWriter();
|
||||
await copy(w, f);
|
||||
const json = JSON.parse(w.toString());
|
||||
assertEq(json["compilerOptions"]["target"], "es2018");
|
||||
assertEquals(json["compilerOptions"]["target"], "es2018");
|
||||
f.close();
|
||||
} finally {
|
||||
const file = form["file"] as FormFile;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { xrun, executableSuffix } from "./util.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
const { readAll } = Deno;
|
||||
|
||||
const decoder = new TextDecoder();
|
||||
|
@ -46,20 +46,20 @@ test(async function testPrettierCheckAndFormatFiles() {
|
|||
const files = [`${testdata}/0.ts`, `${testdata}/1.js`];
|
||||
|
||||
var { code, stdout } = await run([...cmd, "--check", ...files]);
|
||||
assertEq(code, 1);
|
||||
assertEq(normalizeOutput(stdout), "Some files are not formatted");
|
||||
assertEquals(code, 1);
|
||||
assertEquals(normalizeOutput(stdout), "Some files are not formatted");
|
||||
|
||||
var { code, stdout } = await run([...cmd, ...files]);
|
||||
assertEq(code, 0);
|
||||
assertEq(
|
||||
assertEquals(code, 0);
|
||||
assertEquals(
|
||||
normalizeOutput(stdout),
|
||||
`Formatting prettier/testdata/0.ts
|
||||
Formatting prettier/testdata/1.js`
|
||||
);
|
||||
|
||||
var { code, stdout } = await run([...cmd, "--check", ...files]);
|
||||
assertEq(code, 0);
|
||||
assertEq(normalizeOutput(stdout), "Every file is formatted");
|
||||
assertEquals(code, 0);
|
||||
assertEquals(normalizeOutput(stdout), "Every file is formatted");
|
||||
|
||||
await clearTestdataChanges();
|
||||
});
|
||||
|
@ -70,12 +70,12 @@ test(async function testPrettierCheckAndFormatDirs() {
|
|||
const dirs = [`${testdata}/foo`, `${testdata}/bar`];
|
||||
|
||||
var { code, stdout } = await run([...cmd, "--check", ...dirs]);
|
||||
assertEq(code, 1);
|
||||
assertEq(normalizeOutput(stdout), "Some files are not formatted");
|
||||
assertEquals(code, 1);
|
||||
assertEquals(normalizeOutput(stdout), "Some files are not formatted");
|
||||
|
||||
var { code, stdout } = await run([...cmd, ...dirs]);
|
||||
assertEq(code, 0);
|
||||
assertEq(
|
||||
assertEquals(code, 0);
|
||||
assertEquals(
|
||||
normalizeOutput(stdout),
|
||||
`Formatting prettier/testdata/bar/0.ts
|
||||
Formatting prettier/testdata/bar/1.js
|
||||
|
@ -84,8 +84,8 @@ Formatting prettier/testdata/foo/1.js`
|
|||
);
|
||||
|
||||
var { code, stdout } = await run([...cmd, "--check", ...dirs]);
|
||||
assertEq(code, 0);
|
||||
assertEq(normalizeOutput(stdout), "Every file is formatted");
|
||||
assertEquals(code, 0);
|
||||
assertEquals(normalizeOutput(stdout), "Every file is formatted");
|
||||
|
||||
await clearTestdataChanges();
|
||||
});
|
||||
|
|
2
prettier/vendor/parser_typescript.js
vendored
2
prettier/vendor/parser_typescript.js
vendored
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,7 @@ Asserts are exposed in `testing/asserts.ts` module.
|
|||
- `equal` - Deep comparision function, where `actual` and `expected` are
|
||||
compared deeply, and if they vary, `equal` returns `false`.
|
||||
- `assert()` - Expects a boolean value, throws if the value is `false`.
|
||||
- `assertEq()` - Uses the `equal` comparison and throws if the `actual` and
|
||||
- `assertEquals()` - Uses the `equal` comparison and throws if the `actual` and
|
||||
`expected` are not equal.
|
||||
- `assertStrictEq()` - Compares `actual` and `expected` strictly, therefore
|
||||
for non-primitives the values must reference the same instance.
|
||||
|
@ -36,13 +36,13 @@ Basic usage:
|
|||
|
||||
```ts
|
||||
import { runTests, test } from "https://deno.land/std/testing/mod.ts";
|
||||
import { assertEq } from "https://deno.land/std/testing/asserts.ts";
|
||||
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
|
||||
|
||||
test({
|
||||
name: "testing example",
|
||||
fn() {
|
||||
assertEq("world", "world"));
|
||||
assertEq({ hello: "world" }, { hello: "world" }));
|
||||
assertEquals("world", "world"));
|
||||
assertEquals({ hello: "world" }, { hello: "world" }));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -53,8 +53,8 @@ Short syntax (named function instead of object):
|
|||
|
||||
```ts
|
||||
test(function example() {
|
||||
assertEq("world", "world"));
|
||||
assertEq({ hello: "world" }, { hello: "world" }));
|
||||
assertEquals("world", "world"));
|
||||
assertEquals({ hello: "world" }, { hello: "world" }));
|
||||
});
|
||||
```
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { assertEq as prettyAssertEqual } from "./pretty.ts";
|
||||
import { assertEquals as prettyAssertEqual } from "./pretty.ts";
|
||||
|
||||
interface Constructor {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
@ -44,7 +44,7 @@ export function assert(expr: boolean, msg = ""): void {
|
|||
* Make an assertion that `actual` and `expected` are equal, deeply. If not
|
||||
* deeply equal, then throw.
|
||||
*/
|
||||
export function assertEq(
|
||||
export function assertEquals(
|
||||
actual: unknown,
|
||||
expected: unknown,
|
||||
msg?: string
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { assert, equal, assertStrContains, assertMatch } from "./asserts.ts";
|
||||
import { test } from "./mod.ts";
|
||||
// import { assertEq as prettyAssertEqual } from "./pretty.ts";
|
||||
// import { assertEquals as prettyAssertEqual } from "./pretty.ts";
|
||||
// import "./format_test.ts";
|
||||
// import "./diff_test.ts";
|
||||
// import "./pretty_test.ts";
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import diff from "./diff.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { test } from "./mod.ts";
|
||||
|
||||
test({
|
||||
name: "empty",
|
||||
fn() {
|
||||
assertEq(diff([], []), []);
|
||||
assertEquals(diff([], []), []);
|
||||
}
|
||||
});
|
||||
|
||||
test({
|
||||
name: '"a" vs "b"',
|
||||
fn() {
|
||||
assertEq(diff(["a"], ["b"]), [
|
||||
assertEquals(diff(["a"], ["b"]), [
|
||||
{ type: "removed", value: "a" },
|
||||
{ type: "added", value: "b" }
|
||||
]);
|
||||
|
@ -22,28 +22,28 @@ test({
|
|||
test({
|
||||
name: '"a" vs "a"',
|
||||
fn() {
|
||||
assertEq(diff(["a"], ["a"]), [{ type: "common", value: "a" }]);
|
||||
assertEquals(diff(["a"], ["a"]), [{ type: "common", value: "a" }]);
|
||||
}
|
||||
});
|
||||
|
||||
test({
|
||||
name: '"a" vs ""',
|
||||
fn() {
|
||||
assertEq(diff(["a"], []), [{ type: "removed", value: "a" }]);
|
||||
assertEquals(diff(["a"], []), [{ type: "removed", value: "a" }]);
|
||||
}
|
||||
});
|
||||
|
||||
test({
|
||||
name: '"" vs "a"',
|
||||
fn() {
|
||||
assertEq(diff([], ["a"]), [{ type: "added", value: "a" }]);
|
||||
assertEquals(diff([], ["a"]), [{ type: "added", value: "a" }]);
|
||||
}
|
||||
});
|
||||
|
||||
test({
|
||||
name: '"a" vs "a, b"',
|
||||
fn() {
|
||||
assertEq(diff(["a"], ["a", "b"]), [
|
||||
assertEquals(diff(["a"], ["a", "b"]), [
|
||||
{ type: "common", value: "a" },
|
||||
{ type: "added", value: "b" }
|
||||
]);
|
||||
|
@ -53,7 +53,7 @@ test({
|
|||
test({
|
||||
name: '"strength" vs "string"',
|
||||
fn() {
|
||||
assertEq(diff(Array.from("strength"), Array.from("string")), [
|
||||
assertEquals(diff(Array.from("strength"), Array.from("string")), [
|
||||
{ type: "common", value: "s" },
|
||||
{ type: "common", value: "t" },
|
||||
{ type: "common", value: "r" },
|
||||
|
@ -70,7 +70,7 @@ test({
|
|||
test({
|
||||
name: '"strength" vs ""',
|
||||
fn() {
|
||||
assertEq(diff(Array.from("strength"), Array.from("")), [
|
||||
assertEquals(diff(Array.from("strength"), Array.from("")), [
|
||||
{ type: "removed", value: "s" },
|
||||
{ type: "removed", value: "t" },
|
||||
{ type: "removed", value: "r" },
|
||||
|
@ -86,7 +86,7 @@ test({
|
|||
test({
|
||||
name: '"" vs "strength"',
|
||||
fn() {
|
||||
assertEq(diff(Array.from(""), Array.from("strength")), [
|
||||
assertEquals(diff(Array.from(""), Array.from("strength")), [
|
||||
{ type: "added", value: "s" },
|
||||
{ type: "added", value: "t" },
|
||||
{ type: "added", value: "r" },
|
||||
|
@ -102,7 +102,7 @@ test({
|
|||
test({
|
||||
name: '"abc", "c" vs "abc", "bcd", "c"',
|
||||
fn() {
|
||||
assertEq(diff(["abc", "c"], ["abc", "bcd", "c"]), [
|
||||
assertEquals(diff(["abc", "c"], ["abc", "bcd", "c"]), [
|
||||
{ type: "common", value: "abc" },
|
||||
{ type: "added", value: "bcd" },
|
||||
{ type: "common", value: "c" }
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
*/
|
||||
import { test } from "./mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { format } from "./format.ts";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-explicit-any
|
||||
|
@ -55,7 +55,7 @@ test({
|
|||
name: "prints empty arguments",
|
||||
fn() {
|
||||
const val = returnArguments();
|
||||
assertEq(format(val), "Arguments []");
|
||||
assertEquals(format(val), "Arguments []");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -63,7 +63,7 @@ test({
|
|||
name: "prints an empty array",
|
||||
fn() {
|
||||
const val: unknown[] = [];
|
||||
assertEq(format(val), "Array []");
|
||||
assertEquals(format(val), "Array []");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -71,7 +71,7 @@ test({
|
|||
name: "prints an array with items",
|
||||
fn() {
|
||||
const val = [1, 2, 3];
|
||||
assertEq(format(val), "Array [\n 1,\n 2,\n 3,\n]");
|
||||
assertEquals(format(val), "Array [\n 1,\n 2,\n 3,\n]");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -79,7 +79,7 @@ test({
|
|||
name: "prints a empty typed array",
|
||||
fn() {
|
||||
const val = new Uint32Array(0);
|
||||
assertEq(format(val), "Uint32Array []");
|
||||
assertEquals(format(val), "Uint32Array []");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -87,7 +87,7 @@ test({
|
|||
name: "prints a typed array with items",
|
||||
fn() {
|
||||
const val = new Uint32Array(3);
|
||||
assertEq(format(val), "Uint32Array [\n 0,\n 0,\n 0,\n]");
|
||||
assertEquals(format(val), "Uint32Array [\n 0,\n 0,\n 0,\n]");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -95,7 +95,7 @@ test({
|
|||
name: "prints an array buffer",
|
||||
fn() {
|
||||
const val = new ArrayBuffer(3);
|
||||
assertEq(format(val), "ArrayBuffer []");
|
||||
assertEquals(format(val), "ArrayBuffer []");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -103,7 +103,7 @@ test({
|
|||
name: "prints a nested array",
|
||||
fn() {
|
||||
const val = [[1, 2, 3]];
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(val),
|
||||
"Array [\n Array [\n 1,\n 2,\n 3,\n ],\n]"
|
||||
);
|
||||
|
@ -114,7 +114,7 @@ test({
|
|||
name: "prints true",
|
||||
fn() {
|
||||
const val = true;
|
||||
assertEq(format(val), "true");
|
||||
assertEquals(format(val), "true");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -122,7 +122,7 @@ test({
|
|||
name: "prints false",
|
||||
fn() {
|
||||
const val = false;
|
||||
assertEq(format(val), "false");
|
||||
assertEquals(format(val), "false");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -130,7 +130,7 @@ test({
|
|||
name: "prints an error",
|
||||
fn() {
|
||||
const val = new Error();
|
||||
assertEq(format(val), "[Error]");
|
||||
assertEquals(format(val), "[Error]");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -138,7 +138,7 @@ test({
|
|||
name: "prints a typed error with a message",
|
||||
fn() {
|
||||
const val = new TypeError("message");
|
||||
assertEq(format(val), "[TypeError: message]");
|
||||
assertEquals(format(val), "[TypeError: message]");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -147,7 +147,7 @@ test({
|
|||
fn() {
|
||||
// tslint:disable-next-line:function-constructor
|
||||
const val = new Function();
|
||||
assertEq(format(val), "[Function anonymous]");
|
||||
assertEquals(format(val), "[Function anonymous]");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -160,7 +160,7 @@ test({
|
|||
}
|
||||
// tslint:disable-next-line:no-empty
|
||||
f(() => {});
|
||||
assertEq(format(val), "[Function anonymous]");
|
||||
assertEquals(format(val), "[Function anonymous]");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -170,7 +170,7 @@ test({
|
|||
// tslint:disable-next-line:no-empty
|
||||
const val = (): void => {};
|
||||
const formatted = format(val);
|
||||
assertEq(
|
||||
assertEquals(
|
||||
formatted === "[Function anonymous]" || formatted === "[Function val]",
|
||||
true
|
||||
);
|
||||
|
@ -182,7 +182,7 @@ test({
|
|||
fn() {
|
||||
// tslint:disable-next-line:no-empty
|
||||
const val = function named(): void {};
|
||||
assertEq(format(val), "[Function named]");
|
||||
assertEquals(format(val), "[Function named]");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -194,7 +194,7 @@ test({
|
|||
yield 2;
|
||||
yield 3;
|
||||
};
|
||||
assertEq(format(val), "[Function generate]");
|
||||
assertEquals(format(val), "[Function generate]");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -203,7 +203,7 @@ test({
|
|||
fn() {
|
||||
// tslint:disable-next-line:no-empty
|
||||
const val = function named(): void {};
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(val, {
|
||||
printFunctionName: false
|
||||
}),
|
||||
|
@ -216,7 +216,7 @@ test({
|
|||
name: "prints Infinity",
|
||||
fn() {
|
||||
const val = Infinity;
|
||||
assertEq(format(val), "Infinity");
|
||||
assertEquals(format(val), "Infinity");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -224,7 +224,7 @@ test({
|
|||
name: "prints -Infinity",
|
||||
fn() {
|
||||
const val = -Infinity;
|
||||
assertEq(format(val), "-Infinity");
|
||||
assertEquals(format(val), "-Infinity");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -232,7 +232,7 @@ test({
|
|||
name: "prints an empty map",
|
||||
fn() {
|
||||
const val = new Map();
|
||||
assertEq(format(val), "Map {}");
|
||||
assertEquals(format(val), "Map {}");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -242,7 +242,7 @@ test({
|
|||
const val = new Map();
|
||||
val.set("prop1", "value1");
|
||||
val.set("prop2", "value2");
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(val),
|
||||
'Map {\n "prop1" => "value1",\n "prop2" => "value2",\n}'
|
||||
);
|
||||
|
@ -288,7 +288,7 @@ test({
|
|||
' } => "object",',
|
||||
"}"
|
||||
].join("\n");
|
||||
assertEq(format(val), expected);
|
||||
assertEquals(format(val), expected);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -296,7 +296,7 @@ test({
|
|||
name: "prints NaN",
|
||||
fn() {
|
||||
const val = NaN;
|
||||
assertEq(format(val), "NaN");
|
||||
assertEquals(format(val), "NaN");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -304,7 +304,7 @@ test({
|
|||
name: "prints null",
|
||||
fn() {
|
||||
const val = null;
|
||||
assertEq(format(val), "null");
|
||||
assertEquals(format(val), "null");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -312,7 +312,7 @@ test({
|
|||
name: "prints a positive number",
|
||||
fn() {
|
||||
const val = 123;
|
||||
assertEq(format(val), "123");
|
||||
assertEquals(format(val), "123");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -320,7 +320,7 @@ test({
|
|||
name: "prints a negative number",
|
||||
fn() {
|
||||
const val = -123;
|
||||
assertEq(format(val), "-123");
|
||||
assertEquals(format(val), "-123");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -328,7 +328,7 @@ test({
|
|||
name: "prints zero",
|
||||
fn() {
|
||||
const val = 0;
|
||||
assertEq(format(val), "0");
|
||||
assertEquals(format(val), "0");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -336,7 +336,7 @@ test({
|
|||
name: "prints negative zero",
|
||||
fn() {
|
||||
const val = -0;
|
||||
assertEq(format(val), "-0");
|
||||
assertEquals(format(val), "-0");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -344,7 +344,7 @@ test({
|
|||
name: "prints a date",
|
||||
fn() {
|
||||
const val = new Date(10e11);
|
||||
assertEq(format(val), "2001-09-09T01:46:40.000Z");
|
||||
assertEquals(format(val), "2001-09-09T01:46:40.000Z");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -352,7 +352,7 @@ test({
|
|||
name: "prints an invalid date",
|
||||
fn() {
|
||||
const val = new Date(Infinity);
|
||||
assertEq(format(val), "Date { NaN }");
|
||||
assertEquals(format(val), "Date { NaN }");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -360,7 +360,7 @@ test({
|
|||
name: "prints an empty object",
|
||||
fn() {
|
||||
const val = {};
|
||||
assertEq(format(val), "Object {}");
|
||||
assertEquals(format(val), "Object {}");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -368,7 +368,7 @@ test({
|
|||
name: "prints an object with properties",
|
||||
fn() {
|
||||
const val = { prop1: "value1", prop2: "value2" };
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(val),
|
||||
'Object {\n "prop1": "value1",\n "prop2": "value2",\n}'
|
||||
);
|
||||
|
@ -383,7 +383,7 @@ test({
|
|||
val[Symbol("symbol1")] = "value2";
|
||||
val[Symbol("symbol2")] = "value3";
|
||||
val.prop = "value1";
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(val),
|
||||
'Object {\n "prop": "value1",\n Symbol(symbol1): "value2",\n Symbol(symbol2): "value3",\n}'
|
||||
);
|
||||
|
@ -402,7 +402,7 @@ test({
|
|||
enumerable: false,
|
||||
value: false
|
||||
});
|
||||
assertEq(format(val), 'Object {\n "enumerable": true,\n}');
|
||||
assertEquals(format(val), 'Object {\n "enumerable": true,\n}');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -418,7 +418,7 @@ test({
|
|||
enumerable: false,
|
||||
value: false
|
||||
});
|
||||
assertEq(format(val), 'Object {\n "enumerable": true,\n}');
|
||||
assertEquals(format(val), 'Object {\n "enumerable": true,\n}');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -426,7 +426,7 @@ test({
|
|||
name: "prints an object with sorted properties",
|
||||
fn() {
|
||||
const val = { b: 1, a: 2 };
|
||||
assertEq(format(val), 'Object {\n "a": 2,\n "b": 1,\n}');
|
||||
assertEquals(format(val), 'Object {\n "a": 2,\n "b": 1,\n}');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -434,7 +434,7 @@ test({
|
|||
name: "prints regular expressions from constructors",
|
||||
fn() {
|
||||
const val = new RegExp("regexp");
|
||||
assertEq(format(val), "/regexp/");
|
||||
assertEquals(format(val), "/regexp/");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -442,7 +442,7 @@ test({
|
|||
name: "prints regular expressions from literals",
|
||||
fn() {
|
||||
const val = /regexp/gi;
|
||||
assertEq(format(val), "/regexp/gi");
|
||||
assertEquals(format(val), "/regexp/gi");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -450,7 +450,7 @@ test({
|
|||
name: "prints regular expressions {escapeRegex: false}",
|
||||
fn() {
|
||||
const val = /regexp\d/gi;
|
||||
assertEq(format(val), "/regexp\\d/gi");
|
||||
assertEquals(format(val), "/regexp\\d/gi");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -458,7 +458,7 @@ test({
|
|||
name: "prints regular expressions {escapeRegex: true}",
|
||||
fn() {
|
||||
const val = /regexp\d/gi;
|
||||
assertEq(format(val, { escapeRegex: true }), "/regexp\\\\d/gi");
|
||||
assertEquals(format(val, { escapeRegex: true }), "/regexp\\\\d/gi");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -466,7 +466,7 @@ test({
|
|||
name: "escapes regular expressions nested inside object",
|
||||
fn() {
|
||||
const obj = { test: /regexp\d/gi };
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(obj, { escapeRegex: true }),
|
||||
'Object {\n "test": /regexp\\\\d/gi,\n}'
|
||||
);
|
||||
|
@ -477,7 +477,7 @@ test({
|
|||
name: "prints an empty set",
|
||||
fn() {
|
||||
const val = new Set();
|
||||
assertEq(format(val), "Set {}");
|
||||
assertEquals(format(val), "Set {}");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -487,7 +487,7 @@ test({
|
|||
const val = new Set();
|
||||
val.add("value1");
|
||||
val.add("value2");
|
||||
assertEq(format(val), 'Set {\n "value1",\n "value2",\n}');
|
||||
assertEquals(format(val), 'Set {\n "value1",\n "value2",\n}');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -495,7 +495,7 @@ test({
|
|||
name: "prints a string",
|
||||
fn() {
|
||||
const val = "string";
|
||||
assertEq(format(val), '"string"');
|
||||
assertEquals(format(val), '"string"');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -503,7 +503,7 @@ test({
|
|||
name: "prints and escape a string",
|
||||
fn() {
|
||||
const val = "\"'\\";
|
||||
assertEq(format(val), '"\\"\'\\\\"');
|
||||
assertEquals(format(val), '"\\"\'\\\\"');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -511,15 +511,15 @@ test({
|
|||
name: "doesn't escape string with {excapeString: false}",
|
||||
fn() {
|
||||
const val = "\"'\\n";
|
||||
assertEq(format(val, { escapeString: false }), '""\'\\n"');
|
||||
assertEquals(format(val, { escapeString: false }), '""\'\\n"');
|
||||
}
|
||||
});
|
||||
|
||||
test({
|
||||
name: "prints a string with escapes",
|
||||
fn() {
|
||||
assertEq(format('"-"'), '"\\"-\\""');
|
||||
assertEq(format("\\ \\\\"), '"\\\\ \\\\\\\\"');
|
||||
assertEquals(format('"-"'), '"\\"-\\""');
|
||||
assertEquals(format("\\ \\\\"), '"\\\\ \\\\\\\\"');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -527,7 +527,7 @@ test({
|
|||
name: "prints a multiline string",
|
||||
fn() {
|
||||
const val = ["line 1", "line 2", "line 3"].join("\n");
|
||||
assertEq(format(val), '"' + val + '"');
|
||||
assertEquals(format(val), '"' + val + '"');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -547,7 +547,7 @@ test({
|
|||
},
|
||||
type: "svg"
|
||||
};
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(val),
|
||||
[
|
||||
"Object {",
|
||||
|
@ -573,7 +573,7 @@ test({
|
|||
name: "prints a symbol",
|
||||
fn() {
|
||||
const val = Symbol("symbol");
|
||||
assertEq(format(val), "Symbol(symbol)");
|
||||
assertEquals(format(val), "Symbol(symbol)");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -581,7 +581,7 @@ test({
|
|||
name: "prints undefined",
|
||||
fn() {
|
||||
const val = undefined;
|
||||
assertEq(format(val), "undefined");
|
||||
assertEquals(format(val), "undefined");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -589,7 +589,7 @@ test({
|
|||
name: "prints a WeakMap",
|
||||
fn() {
|
||||
const val = new WeakMap();
|
||||
assertEq(format(val), "WeakMap {}");
|
||||
assertEquals(format(val), "WeakMap {}");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -597,7 +597,7 @@ test({
|
|||
name: "prints a WeakSet",
|
||||
fn() {
|
||||
const val = new WeakSet();
|
||||
assertEq(format(val), "WeakSet {}");
|
||||
assertEquals(format(val), "WeakSet {}");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -605,7 +605,7 @@ test({
|
|||
name: "prints deeply nested objects",
|
||||
fn() {
|
||||
const val = { prop: { prop: { prop: "value" } } };
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(val),
|
||||
'Object {\n "prop": Object {\n "prop": Object {\n "prop": "value",\n },\n },\n}'
|
||||
);
|
||||
|
@ -618,7 +618,7 @@ test({
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const val: any = {};
|
||||
val.prop = val;
|
||||
assertEq(format(val), 'Object {\n "prop": [Circular],\n}');
|
||||
assertEquals(format(val), 'Object {\n "prop": [Circular],\n}');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -627,7 +627,7 @@ test({
|
|||
fn() {
|
||||
const inner = {};
|
||||
const val = { prop1: inner, prop2: inner };
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(val),
|
||||
'Object {\n "prop1": Object {},\n "prop2": Object {},\n}'
|
||||
);
|
||||
|
@ -637,14 +637,14 @@ test({
|
|||
test({
|
||||
name: "default implicit: 2 spaces",
|
||||
fn() {
|
||||
assertEq(format(createVal()), createExpected());
|
||||
assertEquals(format(createVal()), createExpected());
|
||||
}
|
||||
});
|
||||
|
||||
test({
|
||||
name: "default explicit: 2 spaces",
|
||||
fn() {
|
||||
assertEq(format(createVal(), { indent: 2 }), createExpected());
|
||||
assertEquals(format(createVal(), { indent: 2 }), createExpected());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -653,7 +653,7 @@ test({
|
|||
name: "non-default: 0 spaces",
|
||||
fn() {
|
||||
const indent = 0;
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(createVal(), { indent }),
|
||||
createExpected().replace(/ {2}/g, " ".repeat(indent))
|
||||
);
|
||||
|
@ -664,7 +664,7 @@ test({
|
|||
name: "non-default: 4 spaces",
|
||||
fn() {
|
||||
const indent = 4;
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(createVal(), { indent }),
|
||||
createExpected().replace(/ {2}/g, " ".repeat(indent))
|
||||
);
|
||||
|
@ -692,7 +692,7 @@ test({
|
|||
"set non-empty": new Set(["value"])
|
||||
}
|
||||
];
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format(v, { maxDepth: 2 }),
|
||||
[
|
||||
"Array [",
|
||||
|
@ -720,7 +720,7 @@ test({
|
|||
test({
|
||||
name: "prints objects with no constructor",
|
||||
fn() {
|
||||
assertEq(format(Object.create(null)), "Object {}");
|
||||
assertEquals(format(Object.create(null)), "Object {}");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -734,14 +734,14 @@ test({
|
|||
' "constructor": "constructor",',
|
||||
"}"
|
||||
].join("\n");
|
||||
assertEq(format(obj), expected);
|
||||
assertEquals(format(obj), expected);
|
||||
}
|
||||
});
|
||||
|
||||
test({
|
||||
name: "calls toJSON and prints its return value",
|
||||
fn() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format({
|
||||
toJSON: () => ({ value: false }),
|
||||
value: true
|
||||
|
@ -754,7 +754,7 @@ test({
|
|||
test({
|
||||
name: "calls toJSON and prints an internal representation.",
|
||||
fn() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format({
|
||||
toJSON: () => "[Internal Object]",
|
||||
value: true
|
||||
|
@ -767,7 +767,7 @@ test({
|
|||
test({
|
||||
name: "calls toJSON only on functions",
|
||||
fn() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format({
|
||||
toJSON: false,
|
||||
value: true
|
||||
|
@ -780,7 +780,7 @@ test({
|
|||
test({
|
||||
name: "does not call toJSON recursively",
|
||||
fn() {
|
||||
assertEq(
|
||||
assertEquals(
|
||||
format({
|
||||
toJSON: () => ({ toJSON: () => ({ value: true }) }),
|
||||
value: false
|
||||
|
@ -796,6 +796,6 @@ test({
|
|||
const set = new Set([1]);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(set as any).toJSON = () => "map";
|
||||
assertEq(format(set), '"map"');
|
||||
assertEquals(format(set), '"map"');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -55,7 +55,7 @@ function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>): string[] {
|
|||
return messages;
|
||||
}
|
||||
|
||||
export function assertEq(
|
||||
export function assertEquals(
|
||||
actual: unknown,
|
||||
expected: unknown,
|
||||
msg?: string
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { test } from "./mod.ts";
|
||||
import { red, green, white, gray, bold } from "../colors/mod.ts";
|
||||
import { assertEq } from "./pretty.ts";
|
||||
import { assertEquals } from "./pretty.ts";
|
||||
import { assertThrows } from "./asserts.ts";
|
||||
|
||||
const createHeader = (): string[] => [
|
||||
|
@ -19,11 +19,11 @@ const removed: (s: string) => string = (s: string): string => red(bold(s));
|
|||
test({
|
||||
name: "pass case",
|
||||
fn() {
|
||||
assertEq({ a: 10 }, { a: 10 });
|
||||
assertEq(true, true);
|
||||
assertEq(10, 10);
|
||||
assertEq("abc", "abc");
|
||||
assertEq({ a: 10, b: { c: "1" } }, { a: 10, b: { c: "1" } });
|
||||
assertEquals({ a: 10 }, { a: 10 });
|
||||
assertEquals(true, true);
|
||||
assertEquals(10, 10);
|
||||
assertEquals("abc", "abc");
|
||||
assertEquals({ a: 10, b: { c: "1" } }, { a: 10, b: { c: "1" } });
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -31,7 +31,7 @@ test({
|
|||
name: "failed with number",
|
||||
fn() {
|
||||
assertThrows(
|
||||
() => assertEq(1, 2),
|
||||
() => assertEquals(1, 2),
|
||||
Error,
|
||||
[...createHeader(), removed(`- 1`), added(`+ 2`), ""].join("\n")
|
||||
);
|
||||
|
@ -42,7 +42,7 @@ test({
|
|||
name: "failed with number vs string",
|
||||
fn() {
|
||||
assertThrows(
|
||||
() => assertEq(1, "1"),
|
||||
() => assertEquals(1, "1"),
|
||||
Error,
|
||||
[...createHeader(), removed(`- 1`), added(`+ "1"`)].join("\n")
|
||||
);
|
||||
|
@ -53,7 +53,7 @@ test({
|
|||
name: "failed with array",
|
||||
fn() {
|
||||
assertThrows(
|
||||
() => assertEq([1, "2", 3], ["1", "2", 3]),
|
||||
() => assertEquals([1, "2", 3], ["1", "2", 3]),
|
||||
Error,
|
||||
[
|
||||
...createHeader(),
|
||||
|
@ -73,7 +73,7 @@ test({
|
|||
name: "failed with object",
|
||||
fn() {
|
||||
assertThrows(
|
||||
() => assertEq({ a: 1, b: "2", c: 3 }, { a: 1, b: 2, c: [3] }),
|
||||
() => assertEquals({ a: 1, b: "2", c: 3 }, { a: 1, b: 2, c: [3] }),
|
||||
Error,
|
||||
[
|
||||
...createHeader(),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { test, runIfMain } from "./mod.ts";
|
||||
import {
|
||||
assert,
|
||||
assertEq,
|
||||
assertEquals,
|
||||
assertStrictEq,
|
||||
assertThrows,
|
||||
assertThrowsAsync,
|
||||
|
@ -28,7 +28,7 @@ test(function testingAssertEqualActualUncoercable() {
|
|||
let didThrow = false;
|
||||
const a = Object.create(null);
|
||||
try {
|
||||
assertEq(a, "bar");
|
||||
assertEquals(a, "bar");
|
||||
} catch (e) {
|
||||
didThrow = true;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { BufReader } from "../io/bufio.ts";
|
||||
import { TextProtoReader, append } from "./mod.ts";
|
||||
import { stringsReader } from "../io/util.ts";
|
||||
import { assert, assertEq } from "../testing/asserts.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import { test } from "../testing/mod.ts";
|
||||
|
||||
function reader(s: string): TextProtoReader {
|
||||
|
@ -16,15 +16,15 @@ function reader(s: string): TextProtoReader {
|
|||
test(async function textprotoReader() {
|
||||
let r = reader("line1\nline2\n");
|
||||
let [s, err] = await r.readLine();
|
||||
assertEq(s, "line1");
|
||||
assertEquals(s, "line1");
|
||||
assert(err == null);
|
||||
|
||||
[s, err] = await r.readLine();
|
||||
assertEq(s, "line2");
|
||||
assertEquals(s, "line2");
|
||||
assert(err == null);
|
||||
|
||||
[s, err] = await r.readLine();
|
||||
assertEq(s, "");
|
||||
assertEquals(s, "");
|
||||
assert(err == "EOF");
|
||||
});
|
||||
|
||||
|
@ -47,7 +47,7 @@ test(async function textprotoReadMIMEHeader() {
|
|||
test(async function textprotoReadMIMEHeaderSingle() {
|
||||
let r = reader("Foo: bar\n\n");
|
||||
let [m, err] = await r.readMIMEHeader();
|
||||
assertEq(m.get("Foo"), "bar");
|
||||
assertEquals(m.get("Foo"), "bar");
|
||||
assert(!err);
|
||||
});
|
||||
|
||||
|
@ -88,12 +88,12 @@ test(async function textprotoAppend() {
|
|||
const u1 = enc.encode("Hello ");
|
||||
const u2 = enc.encode("World");
|
||||
const joined = append(u1, u2);
|
||||
assertEq(dec.decode(joined), "Hello World");
|
||||
assertEquals(dec.decode(joined), "Hello World");
|
||||
});
|
||||
|
||||
test(async function textprotoReadEmpty() {
|
||||
let r = reader("");
|
||||
let [, err] = await r.readMIMEHeader();
|
||||
// Should not crash!
|
||||
assertEq(err, "EOF");
|
||||
assertEquals(err, "EOF");
|
||||
});
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEq } from "../testing/asserts.ts";
|
||||
import { assertEquals } from "../testing/asserts.ts";
|
||||
import { Sha1 } from "./sha1.ts";
|
||||
|
||||
test(function testSha1() {
|
||||
const sha1 = new Sha1();
|
||||
sha1.update("abcde");
|
||||
assertEq(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
|
||||
assertEquals(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
|
||||
});
|
||||
|
||||
test(function testSha1WithArray() {
|
||||
const data = Uint8Array.of(0x61, 0x62, 0x63, 0x64, 0x65);
|
||||
const sha1 = new Sha1();
|
||||
sha1.update(data);
|
||||
assertEq(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
|
||||
assertEquals(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
|
||||
});
|
||||
|
||||
test(function testSha1WithBuffer() {
|
||||
const data = Uint8Array.of(0x61, 0x62, 0x63, 0x64, 0x65);
|
||||
const sha1 = new Sha1();
|
||||
sha1.update(data.buffer);
|
||||
assertEq(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
|
||||
assertEquals(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
|
||||
});
|
||||
|
|
62
ws/test.ts
62
ws/test.ts
|
@ -3,7 +3,7 @@ import "./sha1_test.ts";
|
|||
|
||||
const { Buffer } = Deno;
|
||||
import { BufReader } from "../io/bufio.ts";
|
||||
import { assert, assertEq } from "../testing/asserts.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import { test } from "../testing/mod.ts";
|
||||
import {
|
||||
acceptable,
|
||||
|
@ -19,10 +19,10 @@ test(async function testReadUnmaskedTextFrame() {
|
|||
new Buffer(new Uint8Array([0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f]))
|
||||
);
|
||||
const frame = await readFrame(buf);
|
||||
assertEq(frame.opcode, OpCode.TextFrame);
|
||||
assertEq(frame.mask, undefined);
|
||||
assertEq(new Buffer(frame.payload).toString(), "Hello");
|
||||
assertEq(frame.isLastFrame, true);
|
||||
assertEquals(frame.opcode, OpCode.TextFrame);
|
||||
assertEquals(frame.mask, undefined);
|
||||
assertEquals(new Buffer(frame.payload).toString(), "Hello");
|
||||
assertEquals(frame.isLastFrame, true);
|
||||
});
|
||||
|
||||
test(async function testReadMakedTextFrame() {
|
||||
|
@ -46,10 +46,10 @@ test(async function testReadMakedTextFrame() {
|
|||
);
|
||||
const frame = await readFrame(buf);
|
||||
console.dir(frame);
|
||||
assertEq(frame.opcode, OpCode.TextFrame);
|
||||
assertEquals(frame.opcode, OpCode.TextFrame);
|
||||
unmask(frame.payload, frame.mask);
|
||||
assertEq(new Buffer(frame.payload).toString(), "Hello");
|
||||
assertEq(frame.isLastFrame, true);
|
||||
assertEquals(new Buffer(frame.payload).toString(), "Hello");
|
||||
assertEquals(frame.isLastFrame, true);
|
||||
});
|
||||
|
||||
test(async function testReadUnmaskedSplittedTextFrames() {
|
||||
|
@ -60,15 +60,15 @@ test(async function testReadUnmaskedSplittedTextFrames() {
|
|||
new Buffer(new Uint8Array([0x80, 0x02, 0x6c, 0x6f]))
|
||||
);
|
||||
const [f1, f2] = await Promise.all([readFrame(buf1), readFrame(buf2)]);
|
||||
assertEq(f1.isLastFrame, false);
|
||||
assertEq(f1.mask, undefined);
|
||||
assertEq(f1.opcode, OpCode.TextFrame);
|
||||
assertEq(new Buffer(f1.payload).toString(), "Hel");
|
||||
assertEquals(f1.isLastFrame, false);
|
||||
assertEquals(f1.mask, undefined);
|
||||
assertEquals(f1.opcode, OpCode.TextFrame);
|
||||
assertEquals(new Buffer(f1.payload).toString(), "Hel");
|
||||
|
||||
assertEq(f2.isLastFrame, true);
|
||||
assertEq(f2.mask, undefined);
|
||||
assertEq(f2.opcode, OpCode.Continue);
|
||||
assertEq(new Buffer(f2.payload).toString(), "lo");
|
||||
assertEquals(f2.isLastFrame, true);
|
||||
assertEquals(f2.mask, undefined);
|
||||
assertEquals(f2.opcode, OpCode.Continue);
|
||||
assertEquals(new Buffer(f2.payload).toString(), "lo");
|
||||
});
|
||||
|
||||
test(async function testReadUnmaksedPingPongFrame() {
|
||||
|
@ -77,8 +77,8 @@ test(async function testReadUnmaksedPingPongFrame() {
|
|||
new Buffer(new Uint8Array([0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f]))
|
||||
);
|
||||
const ping = await readFrame(buf);
|
||||
assertEq(ping.opcode, OpCode.Ping);
|
||||
assertEq(new Buffer(ping.payload).toString(), "Hello");
|
||||
assertEquals(ping.opcode, OpCode.Ping);
|
||||
assertEquals(new Buffer(ping.payload).toString(), "Hello");
|
||||
|
||||
const buf2 = new BufReader(
|
||||
new Buffer(
|
||||
|
@ -98,10 +98,10 @@ test(async function testReadUnmaksedPingPongFrame() {
|
|||
)
|
||||
);
|
||||
const pong = await readFrame(buf2);
|
||||
assertEq(pong.opcode, OpCode.Pong);
|
||||
assertEquals(pong.opcode, OpCode.Pong);
|
||||
assert(pong.mask !== undefined);
|
||||
unmask(pong.payload, pong.mask);
|
||||
assertEq(new Buffer(pong.payload).toString(), "Hello");
|
||||
assertEquals(new Buffer(pong.payload).toString(), "Hello");
|
||||
});
|
||||
|
||||
test(async function testReadUnmaksedBigBinaryFrame() {
|
||||
|
@ -111,10 +111,10 @@ test(async function testReadUnmaksedBigBinaryFrame() {
|
|||
}
|
||||
const buf = new BufReader(new Buffer(new Uint8Array(a)));
|
||||
const bin = await readFrame(buf);
|
||||
assertEq(bin.opcode, OpCode.BinaryFrame);
|
||||
assertEq(bin.isLastFrame, true);
|
||||
assertEq(bin.mask, undefined);
|
||||
assertEq(bin.payload.length, 256);
|
||||
assertEquals(bin.opcode, OpCode.BinaryFrame);
|
||||
assertEquals(bin.isLastFrame, true);
|
||||
assertEquals(bin.mask, undefined);
|
||||
assertEquals(bin.payload.length, 256);
|
||||
});
|
||||
|
||||
test(async function testReadUnmaskedBigBigBinaryFrame() {
|
||||
|
@ -124,16 +124,16 @@ test(async function testReadUnmaskedBigBigBinaryFrame() {
|
|||
}
|
||||
const buf = new BufReader(new Buffer(new Uint8Array(a)));
|
||||
const bin = await readFrame(buf);
|
||||
assertEq(bin.opcode, OpCode.BinaryFrame);
|
||||
assertEq(bin.isLastFrame, true);
|
||||
assertEq(bin.mask, undefined);
|
||||
assertEq(bin.payload.length, 0xffff + 1);
|
||||
assertEquals(bin.opcode, OpCode.BinaryFrame);
|
||||
assertEquals(bin.isLastFrame, true);
|
||||
assertEquals(bin.mask, undefined);
|
||||
assertEquals(bin.payload.length, 0xffff + 1);
|
||||
});
|
||||
|
||||
test(async function testCreateSecAccept() {
|
||||
const nonce = "dGhlIHNhbXBsZSBub25jZQ==";
|
||||
const d = createSecAccept(nonce);
|
||||
assertEq(d, "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=");
|
||||
assertEquals(d, "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=");
|
||||
});
|
||||
|
||||
test(function testAcceptable() {
|
||||
|
@ -143,7 +143,7 @@ test(function testAcceptable() {
|
|||
"sec-websocket-key": "aaa"
|
||||
})
|
||||
});
|
||||
assertEq(ret, true);
|
||||
assertEquals(ret, true);
|
||||
});
|
||||
|
||||
const invalidHeaders = [
|
||||
|
@ -158,6 +158,6 @@ test(function testAcceptableInvalid() {
|
|||
const ret = acceptable({
|
||||
headers: new Headers(pat)
|
||||
});
|
||||
assertEq(ret, false);
|
||||
assertEquals(ret, false);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue