1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 00:21:05 -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:
Ryan Dahl 2019-03-06 19:42:24 -05:00 committed by GitHub
parent e36edfdb3f
commit caa383a583
55 changed files with 720 additions and 714 deletions

View file

@ -5,14 +5,14 @@ import {
bytesHasPrefix bytesHasPrefix
} from "./bytes.ts"; } from "./bytes.ts";
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
test(function bytesBytesFindIndex() { test(function bytesBytesFindIndex() {
const i = bytesFindIndex( const i = bytesFindIndex(
new Uint8Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 3]), new Uint8Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 3]),
new Uint8Array([0, 1, 2]) new Uint8Array([0, 1, 2])
); );
assertEq(i, 2); assertEquals(i, 2);
}); });
test(function bytesBytesFindLastIndex1() { 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, 0, 1, 2, 0, 1, 3]),
new Uint8Array([0, 1, 2]) new Uint8Array([0, 1, 2])
); );
assertEq(i, 3); assertEquals(i, 3);
}); });
test(function bytesBytesBytesEqual() { test(function bytesBytesBytesEqual() {
@ -28,10 +28,10 @@ test(function bytesBytesBytesEqual() {
new Uint8Array([0, 1, 2, 3]), new Uint8Array([0, 1, 2, 3]),
new Uint8Array([0, 1, 2, 3]) new Uint8Array([0, 1, 2, 3])
); );
assertEq(v, true); assertEquals(v, true);
}); });
test(function bytesBytesHasPrefix() { test(function bytesBytesHasPrefix() {
const v = bytesHasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([0, 1])); const v = bytesHasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([0, 1]));
assertEq(v, true); assertEquals(v, true);
}); });

View file

@ -1,25 +1,25 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; 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 { red, bgBlue, setEnabled, getEnabled } from "./mod.ts";
import "./example.ts"; import "./example.ts";
test(function singleColor() { test(function singleColor() {
assertEq(red("Hello world"), "Hello world"); assertEquals(red("Hello world"), "Hello world");
}); });
test(function doubleColor() { test(function doubleColor() {
assertEq(bgBlue(red("Hello world")), "Hello world"); assertEquals(bgBlue(red("Hello world")), "Hello world");
}); });
test(function replacesCloseCharacters() { test(function replacesCloseCharacters() {
assertEq(red("Hello"), "Hello"); assertEquals(red("Hello"), "Hello");
}); });
test(function enablingColors() { test(function enablingColors() {
assertEq(getEnabled(), true); assertEquals(getEnabled(), true);
setEnabled(false); setEnabled(false);
assertEq(bgBlue(red("Hello world")), "Hello world"); assertEquals(bgBlue(red("Hello world")), "Hello world");
setEnabled(true); setEnabled(true);
assertEq(red("Hello world"), "Hello world"); assertEquals(red("Hello world"), "Hello world");
}); });

View file

@ -1,30 +1,30 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; 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"; import * as datetime from "./mod.ts";
test(function parseDateTime() { test(function parseDateTime() {
assertEq( assertEquals(
datetime.parseDateTime("01-03-2019 16:34", "mm-dd-yyyy hh:mm"), datetime.parseDateTime("01-03-2019 16:34", "mm-dd-yyyy hh:mm"),
new Date(2019, 1, 3, 16, 34) new Date(2019, 1, 3, 16, 34)
); );
assertEq( assertEquals(
datetime.parseDateTime("03-01-2019 16:34", "dd-mm-yyyy hh:mm"), datetime.parseDateTime("03-01-2019 16:34", "dd-mm-yyyy hh:mm"),
new Date(2019, 1, 3, 16, 34) new Date(2019, 1, 3, 16, 34)
); );
assertEq( assertEquals(
datetime.parseDateTime("2019-01-03 16:34", "yyyy-mm-dd hh:mm"), datetime.parseDateTime("2019-01-03 16:34", "yyyy-mm-dd hh:mm"),
new Date(2019, 1, 3, 16, 34) new Date(2019, 1, 3, 16, 34)
); );
assertEq( assertEquals(
datetime.parseDateTime("16:34 01-03-2019", "hh:mm mm-dd-yyyy"), datetime.parseDateTime("16:34 01-03-2019", "hh:mm mm-dd-yyyy"),
new Date(2019, 1, 3, 16, 34) new Date(2019, 1, 3, 16, 34)
); );
assertEq( assertEquals(
datetime.parseDateTime("16:34 03-01-2019", "hh:mm dd-mm-yyyy"), datetime.parseDateTime("16:34 03-01-2019", "hh:mm dd-mm-yyyy"),
new Date(2019, 1, 3, 16, 34) new Date(2019, 1, 3, 16, 34)
); );
assertEq( assertEquals(
datetime.parseDateTime("16:34 2019-01-03", "hh:mm yyyy-mm-dd"), datetime.parseDateTime("16:34 2019-01-03", "hh:mm yyyy-mm-dd"),
new Date(2019, 1, 3, 16, 34) 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"); (datetime as any).parseDateTime("2019-01-01 00:00", "x-y-z");
assert(false, "no exception was thrown"); assert(false, "no exception was thrown");
} catch (e) { } catch (e) {
assertEq(e.message, "Invalid datetime format!"); assertEquals(e.message, "Invalid datetime format!");
} }
}); });
test(function parseDate() { test(function parseDate() {
assertEq( assertEquals(
datetime.parseDate("01-03-2019", "mm-dd-yyyy"), datetime.parseDate("01-03-2019", "mm-dd-yyyy"),
new Date(2019, 1, 3) new Date(2019, 1, 3)
); );
assertEq( assertEquals(
datetime.parseDate("03-01-2019", "dd-mm-yyyy"), datetime.parseDate("03-01-2019", "dd-mm-yyyy"),
new Date(2019, 1, 3) new Date(2019, 1, 3)
); );
assertEq( assertEquals(
datetime.parseDate("2019-01-03", "yyyy-mm-dd"), datetime.parseDate("2019-01-03", "yyyy-mm-dd"),
new Date(2019, 1, 3) new Date(2019, 1, 3)
); );
@ -61,12 +61,12 @@ test(function invalidParseDateFormatThrows() {
(datetime as any).parseDate("2019-01-01", "x-y-z"); (datetime as any).parseDate("2019-01-01", "x-y-z");
assert(false, "no exception was thrown"); assert(false, "no exception was thrown");
} catch (e) { } catch (e) {
assertEq(e.message, "Invalid date format!"); assertEquals(e.message, "Invalid date format!");
} }
}); });
test(function currentDayOfYear() { test(function currentDayOfYear() {
assertEq( assertEquals(
datetime.currentDayOfYear(), datetime.currentDayOfYear(),
Math.ceil(new Date().getTime() / 86400000) - Math.ceil(new Date().getTime() / 86400000) -
Math.floor( Math.floor(

View file

@ -1,15 +1,15 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { run } = Deno; const { run } = Deno;
import { test } from "../testing/mod.ts"; 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 */ /** Example of how to do basic tests */
test(function t1() { test(function t1() {
assertEq("hello", "hello"); assertEquals("hello", "hello");
}); });
test(function t2() { test(function t2() {
assertEq("world", "world"); assertEquals("world", "world");
}); });
/** A more complicated test that runs a subprocess. */ /** A more complicated test that runs a subprocess. */
@ -19,5 +19,5 @@ test(async function catSmoke() {
stdout: "piped" stdout: "piped"
}); });
const s = await p.status(); const s = await p.status();
assertEq(s.code, 0); assertEquals(s.code, 0);
}); });

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
// flag boolean true (default all --args to boolean) // flag boolean true (default all --args to boolean)
@ -9,12 +9,12 @@ test(function flagBooleanTrue() {
boolean: true boolean: true
}); });
assertEq(argv, { assertEquals(argv, {
honk: true, honk: true,
_: ["moo", "cow"] _: ["moo", "cow"]
}); });
assertEq(typeof argv.honk, "boolean"); assertEquals(typeof argv.honk, "boolean");
}); });
// flag boolean true only affects double hyphen arguments without equals signs // flag boolean true only affects double hyphen arguments without equals signs
@ -23,12 +23,12 @@ test(function flagBooleanTrueOnlyAffectsDoubleDash() {
boolean: true boolean: true
}); });
assertEq(argv, { assertEquals(argv, {
honk: true, honk: true,
tacos: "good", tacos: "good",
p: 55, p: 55,
_: ["moo", "cow"] _: ["moo", "cow"]
}); });
assertEq(typeof argv.honk, "boolean"); assertEquals(typeof argv.honk, "boolean");
}); });

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function flagBooleanDefaultFalse() { test(function flagBooleanDefaultFalse() {
@ -9,14 +9,14 @@ test(function flagBooleanDefaultFalse() {
default: { verbose: false, t: false } default: { verbose: false, t: false }
}); });
assertEq(argv, { assertEquals(argv, {
verbose: false, verbose: false,
t: false, t: false,
_: ["moo"] _: ["moo"]
}); });
assertEq(typeof argv.verbose, "boolean"); assertEquals(typeof argv.verbose, "boolean");
assertEq(typeof argv.t, "boolean"); assertEquals(typeof argv.t, "boolean");
}); });
test(function booleanGroups() { test(function booleanGroups() {
@ -24,16 +24,16 @@ test(function booleanGroups() {
boolean: ["x", "y", "z"] boolean: ["x", "y", "z"]
}); });
assertEq(argv, { assertEquals(argv, {
x: true, x: true,
y: false, y: false,
z: true, z: true,
_: ["one", "two", "three"] _: ["one", "two", "three"]
}); });
assertEq(typeof argv.x, "boolean"); assertEquals(typeof argv.x, "boolean");
assertEq(typeof argv.y, "boolean"); assertEquals(typeof argv.y, "boolean");
assertEq(typeof argv.z, "boolean"); assertEquals(typeof argv.z, "boolean");
}); });
test(function booleanAndAliasWithChainableApi() { test(function booleanAndAliasWithChainableApi() {
@ -56,8 +56,8 @@ test(function booleanAndAliasWithChainableApi() {
_: ["derp"] _: ["derp"]
}; };
assertEq(aliasedArgv, expected); assertEquals(aliasedArgv, expected);
assertEq(propertyArgv, expected); assertEquals(propertyArgv, expected);
}); });
test(function booleanAndAliasWithOptionsHash() { test(function booleanAndAliasWithOptionsHash() {
@ -74,8 +74,8 @@ test(function booleanAndAliasWithOptionsHash() {
h: true, h: true,
_: ["derp"] _: ["derp"]
}; };
assertEq(aliasedArgv, expected); assertEquals(aliasedArgv, expected);
assertEq(propertyArgv, expected); assertEquals(propertyArgv, expected);
}); });
test(function booleanAndAliasArrayWithOptionsHash() { test(function booleanAndAliasArrayWithOptionsHash() {
@ -95,9 +95,9 @@ test(function booleanAndAliasArrayWithOptionsHash() {
h: true, h: true,
_: ["derp"] _: ["derp"]
}; };
assertEq(aliasedArgv, expected); assertEquals(aliasedArgv, expected);
assertEq(propertyArgv, expected); assertEquals(propertyArgv, expected);
assertEq(altPropertyArgv, expected); assertEquals(altPropertyArgv, expected);
}); });
test(function booleanAndAliasUsingExplicitTrue() { test(function booleanAndAliasUsingExplicitTrue() {
@ -115,8 +115,8 @@ test(function booleanAndAliasUsingExplicitTrue() {
_: [] _: []
}; };
assertEq(aliasedArgv, expected); assertEquals(aliasedArgv, expected);
assertEq(propertyArgv, expected); assertEquals(propertyArgv, expected);
}); });
// regression, see https://github.com/substack/node-optimist/issues/71 // regression, see https://github.com/substack/node-optimist/issues/71
@ -126,15 +126,15 @@ test(function booleanAndNonBoolean() {
boolean: "boool" boolean: "boool"
}); });
assertEq(parsed.boool, true); assertEquals(parsed.boool, true);
assertEq(parsed.other, "true"); assertEquals(parsed.other, "true");
const parsed2 = parse(["--boool", "--other=false"], { const parsed2 = parse(["--boool", "--other=false"], {
boolean: "boool" boolean: "boool"
}); });
assertEq(parsed2.boool, true); assertEquals(parsed2.boool, true);
assertEq(parsed2.other, "false"); assertEquals(parsed2.other, "false");
}); });
test(function booleanParsingTrue() { test(function booleanParsingTrue() {
@ -145,7 +145,7 @@ test(function booleanParsingTrue() {
boolean: ["boool"] boolean: ["boool"]
}); });
assertEq(parsed.boool, true); assertEquals(parsed.boool, true);
}); });
test(function booleanParsingFalse() { test(function booleanParsingFalse() {
@ -156,5 +156,5 @@ test(function booleanParsingFalse() {
boolean: ["boool"] boolean: ["boool"]
}); });
assertEq(parsed.boool, false); assertEquals(parsed.boool, false);
}); });

View file

@ -1,26 +1,29 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function hyphen() { test(function hyphen() {
assertEq(parse(["-n", "-"]), { n: "-", _: [] }); assertEquals(parse(["-n", "-"]), { n: "-", _: [] });
assertEq(parse(["-"]), { _: ["-"] }); assertEquals(parse(["-"]), { _: ["-"] });
assertEq(parse(["-f-"]), { f: "-", _: [] }); assertEquals(parse(["-f-"]), { f: "-", _: [] });
assertEq(parse(["-b", "-"], { boolean: "b" }), { b: true, _: ["-"] }); assertEquals(parse(["-b", "-"], { boolean: "b" }), { b: true, _: ["-"] });
assertEq(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] }); assertEquals(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] });
}); });
test(function doubleDash() { test(function doubleDash() {
assertEq(parse(["-a", "--", "b"]), { a: true, _: ["b"] }); assertEquals(parse(["-a", "--", "b"]), { a: true, _: ["b"] });
assertEq(parse(["--a", "--", "b"]), { a: true, _: ["b"] }); assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
assertEq(parse(["--a", "--", "b"]), { a: true, _: ["b"] }); assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
}); });
test(function moveArgsAfterDoubleDashIntoOwnArray() { test(function moveArgsAfterDoubleDashIntoOwnArray() {
assertEq(parse(["--name", "John", "before", "--", "after"], { "--": true }), { assertEquals(
name: "John", parse(["--name", "John", "before", "--", "after"], { "--": true }),
_: ["before"], {
"--": ["after"] name: "John",
}); _: ["before"],
"--": ["after"]
}
);
}); });

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function booleanDefaultTrue() { test(function booleanDefaultTrue() {
@ -8,7 +8,7 @@ test(function booleanDefaultTrue() {
boolean: "sometrue", boolean: "sometrue",
default: { sometrue: true } default: { sometrue: true }
}); });
assertEq(argv.sometrue, true); assertEquals(argv.sometrue, true);
}); });
test(function booleanDefaultFalse() { test(function booleanDefaultFalse() {
@ -16,7 +16,7 @@ test(function booleanDefaultFalse() {
boolean: "somefalse", boolean: "somefalse",
default: { somefalse: false } default: { somefalse: false }
}); });
assertEq(argv.somefalse, false); assertEquals(argv.somefalse, false);
}); });
test(function booleanDefaultNull() { test(function booleanDefaultNull() {
@ -24,10 +24,10 @@ test(function booleanDefaultNull() {
boolean: "maybe", boolean: "maybe",
default: { maybe: null } default: { maybe: null }
}); });
assertEq(argv.maybe, null); assertEquals(argv.maybe, null);
const argv2 = parse(["--maybe"], { const argv2 = parse(["--maybe"], {
boolean: "maybe", boolean: "maybe",
default: { maybe: null } default: { maybe: null }
}); });
assertEq(argv2.maybe, true); assertEquals(argv2.maybe, true);
}); });

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function dottedAlias() { test(function dottedAlias() {
@ -8,17 +8,17 @@ test(function dottedAlias() {
default: { "a.b": 11 }, default: { "a.b": 11 },
alias: { "a.b": "aa.bb" } alias: { "a.b": "aa.bb" }
}); });
assertEq(argv.a.b, 22); assertEquals(argv.a.b, 22);
assertEq(argv.aa.bb, 22); assertEquals(argv.aa.bb, 22);
}); });
test(function dottedDefault() { test(function dottedDefault() {
const argv = parse("", { default: { "a.b": 11 }, alias: { "a.b": "aa.bb" } }); const argv = parse("", { default: { "a.b": 11 }, alias: { "a.b": "aa.bb" } });
assertEq(argv.a.b, 11); assertEquals(argv.a.b, 11);
assertEq(argv.aa.bb, 11); assertEquals(argv.aa.bb, 11);
}); });
test(function dottedDefaultWithNoAlias() { test(function dottedDefaultWithNoAlias() {
const argv = parse("", { default: { "a.b": 11 } }); const argv = parse("", { default: { "a.b": 11 } });
assertEq(argv.a.b, 11); assertEquals(argv.a.b, 11);
}); });

View file

@ -1,14 +1,14 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function short() { test(function short() {
const argv = parse(["-b=123"]); const argv = parse(["-b=123"]);
assertEq(argv, { b: 123, _: [] }); assertEquals(argv, { b: 123, _: [] });
}); });
test(function multiShort() { test(function multiShort() {
const argv = parse(["-a=whatever", "-b=robots"]); const argv = parse(["-a=whatever", "-b=robots"]);
assertEq(argv, { a: "whatever", b: "robots", _: [] }); assertEquals(argv, { a: "whatever", b: "robots", _: [] });
}); });

View file

@ -1,18 +1,18 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function longOpts() { test(function longOpts() {
assertEq(parse(["--bool"]), { bool: true, _: [] }); assertEquals(parse(["--bool"]), { bool: true, _: [] });
assertEq(parse(["--pow", "xixxle"]), { pow: "xixxle", _: [] }); assertEquals(parse(["--pow", "xixxle"]), { pow: "xixxle", _: [] });
assertEq(parse(["--pow=xixxle"]), { pow: "xixxle", _: [] }); assertEquals(parse(["--pow=xixxle"]), { pow: "xixxle", _: [] });
assertEq(parse(["--host", "localhost", "--port", "555"]), { assertEquals(parse(["--host", "localhost", "--port", "555"]), {
host: "localhost", host: "localhost",
port: 555, port: 555,
_: [] _: []
}); });
assertEq(parse(["--host=localhost", "--port=555"]), { assertEquals(parse(["--host=localhost", "--port=555"]), {
host: "localhost", host: "localhost",
port: 555, port: 555,
_: [] _: []

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function nums() { test(function nums() {
@ -17,7 +17,7 @@ test(function nums() {
"0xdeadbeef", "0xdeadbeef",
"789" "789"
]); ]);
assertEq(argv, { assertEquals(argv, {
x: 1234, x: 1234,
y: 5.67, y: 5.67,
z: 1e7, z: 1e7,
@ -25,17 +25,17 @@ test(function nums() {
hex: 0xdeadbeef, hex: 0xdeadbeef,
_: [789] _: [789]
}); });
assertEq(typeof argv.x, "number"); assertEquals(typeof argv.x, "number");
assertEq(typeof argv.y, "number"); assertEquals(typeof argv.y, "number");
assertEq(typeof argv.z, "number"); assertEquals(typeof argv.z, "number");
assertEq(typeof argv.w, "string"); assertEquals(typeof argv.w, "string");
assertEq(typeof argv.hex, "number"); assertEquals(typeof argv.hex, "number");
assertEq(typeof argv._[0], "number"); assertEquals(typeof argv._[0], "number");
}); });
test(function alreadyNumber() { test(function alreadyNumber() {
const argv = parse(["-x", 1234, 789]); const argv = parse(["-x", 1234, 789]);
assertEq(argv, { x: 1234, _: [789] }); assertEquals(argv, { x: 1234, _: [789] });
assertEq(typeof argv.x, "number"); assertEquals(typeof argv.x, "number");
assertEq(typeof argv._[0], "number"); assertEquals(typeof argv._[0], "number");
}); });

View file

@ -1,18 +1,18 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function _arseArgs() { test(function _arseArgs() {
assertEq(parse(["--no-moo"]), { moo: false, _: [] }); assertEquals(parse(["--no-moo"]), { moo: false, _: [] });
assertEq(parse(["-v", "a", "-v", "b", "-v", "c"]), { assertEquals(parse(["-v", "a", "-v", "b", "-v", "c"]), {
v: ["a", "b", "c"], v: ["a", "b", "c"],
_: [] _: []
}); });
}); });
test(function comprehensive() { test(function comprehensive() {
assertEq( assertEquals(
parse([ parse([
"--name=meowmers", "--name=meowmers",
"bare", "bare",
@ -50,8 +50,8 @@ test(function comprehensive() {
test(function flagBoolean() { test(function flagBoolean() {
const argv = parse(["-t", "moo"], { boolean: "t" }); const argv = parse(["-t", "moo"], { boolean: "t" });
assertEq(argv, { t: true, _: ["moo"] }); assertEquals(argv, { t: true, _: ["moo"] });
assertEq(typeof argv.t, "boolean"); assertEquals(typeof argv.t, "boolean");
}); });
test(function flagBooleanValue() { test(function flagBooleanValue() {
@ -60,63 +60,63 @@ test(function flagBooleanValue() {
default: { verbose: true } default: { verbose: true }
}); });
assertEq(argv, { assertEquals(argv, {
verbose: false, verbose: false,
t: true, t: true,
_: ["moo"] _: ["moo"]
}); });
assertEq(typeof argv.verbose, "boolean"); assertEquals(typeof argv.verbose, "boolean");
assertEq(typeof argv.t, "boolean"); assertEquals(typeof argv.t, "boolean");
}); });
test(function newlinesInParams() { test(function newlinesInParams() {
const args = parse(["-s", "X\nX"]); const args = parse(["-s", "X\nX"]);
assertEq(args, { _: [], s: "X\nX" }); assertEquals(args, { _: [], s: "X\nX" });
// reproduce in bash: // reproduce in bash:
// VALUE="new // VALUE="new
// line" // line"
// deno program.js --s="$VALUE" // deno program.js --s="$VALUE"
const args2 = parse(["--s=X\nX"]); const args2 = parse(["--s=X\nX"]);
assertEq(args2, { _: [], s: "X\nX" }); assertEquals(args2, { _: [], s: "X\nX" });
}); });
test(function strings() { test(function strings() {
const s = parse(["-s", "0001234"], { string: "s" }).s; const s = parse(["-s", "0001234"], { string: "s" }).s;
assertEq(s, "0001234"); assertEquals(s, "0001234");
assertEq(typeof s, "string"); assertEquals(typeof s, "string");
const x = parse(["-x", "56"], { string: "x" }).x; const x = parse(["-x", "56"], { string: "x" }).x;
assertEq(x, "56"); assertEquals(x, "56");
assertEq(typeof x, "string"); assertEquals(typeof x, "string");
}); });
test(function stringArgs() { test(function stringArgs() {
const s = parse([" ", " "], { string: "_" })._; const s = parse([" ", " "], { string: "_" })._;
assertEq(s.length, 2); assertEquals(s.length, 2);
assertEq(typeof s[0], "string"); assertEquals(typeof s[0], "string");
assertEq(s[0], " "); assertEquals(s[0], " ");
assertEq(typeof s[1], "string"); assertEquals(typeof s[1], "string");
assertEq(s[1], " "); assertEquals(s[1], " ");
}); });
test(function emptyStrings() { test(function emptyStrings() {
const s = parse(["-s"], { string: "s" }).s; const s = parse(["-s"], { string: "s" }).s;
assertEq(s, ""); assertEquals(s, "");
assertEq(typeof s, "string"); assertEquals(typeof s, "string");
const str = parse(["--str"], { string: "str" }).str; const str = parse(["--str"], { string: "str" }).str;
assertEq(str, ""); assertEquals(str, "");
assertEq(typeof str, "string"); assertEquals(typeof str, "string");
const letters = parse(["-art"], { const letters = parse(["-art"], {
string: ["a", "t"] string: ["a", "t"]
}); });
assertEq(letters.a, ""); assertEquals(letters.a, "");
assertEq(letters.r, true); assertEquals(letters.r, true);
assertEq(letters.t, ""); assertEquals(letters.t, "");
}); });
test(function stringAndAlias() { test(function stringAndAlias() {
@ -125,25 +125,25 @@ test(function stringAndAlias() {
alias: { s: "str" } alias: { s: "str" }
}); });
assertEq(x.str, "000123"); assertEquals(x.str, "000123");
assertEq(typeof x.str, "string"); assertEquals(typeof x.str, "string");
assertEq(x.s, "000123"); assertEquals(x.s, "000123");
assertEq(typeof x.s, "string"); assertEquals(typeof x.s, "string");
const y = parse(["-s", "000123"], { const y = parse(["-s", "000123"], {
string: "str", string: "str",
alias: { str: "s" } alias: { str: "s" }
}); });
assertEq(y.str, "000123"); assertEquals(y.str, "000123");
assertEq(typeof y.str, "string"); assertEquals(typeof y.str, "string");
assertEq(y.s, "000123"); assertEquals(y.s, "000123");
assertEq(typeof y.s, "string"); assertEquals(typeof y.s, "string");
}); });
test(function slashBreak() { test(function slashBreak() {
assertEq(parse(["-I/foo/bar/baz"]), { I: "/foo/bar/baz", _: [] }); assertEquals(parse(["-I/foo/bar/baz"]), { I: "/foo/bar/baz", _: [] });
assertEq(parse(["-xyz/foo/bar/baz"]), { assertEquals(parse(["-xyz/foo/bar/baz"]), {
x: true, x: true,
y: true, y: true,
z: "/foo/bar/baz", z: "/foo/bar/baz",
@ -155,19 +155,19 @@ test(function alias() {
const argv = parse(["-f", "11", "--zoom", "55"], { const argv = parse(["-f", "11", "--zoom", "55"], {
alias: { z: "zoom" } alias: { z: "zoom" }
}); });
assertEq(argv.zoom, 55); assertEquals(argv.zoom, 55);
assertEq(argv.z, argv.zoom); assertEquals(argv.z, argv.zoom);
assertEq(argv.f, 11); assertEquals(argv.f, 11);
}); });
test(function multiAlias() { test(function multiAlias() {
const argv = parse(["-f", "11", "--zoom", "55"], { const argv = parse(["-f", "11", "--zoom", "55"], {
alias: { z: ["zm", "zoom"] } alias: { z: ["zm", "zoom"] }
}); });
assertEq(argv.zoom, 55); assertEquals(argv.zoom, 55);
assertEq(argv.z, argv.zoom); assertEquals(argv.z, argv.zoom);
assertEq(argv.z, argv.zm); assertEquals(argv.z, argv.zm);
assertEq(argv.f, 11); assertEquals(argv.f, 11);
}); });
test(function nestedDottedObjects() { test(function nestedDottedObjects() {
@ -182,7 +182,7 @@ test(function nestedDottedObjects() {
"--beep.boop" "--beep.boop"
]); ]);
assertEq(argv.foo, { assertEquals(argv.foo, {
bar: 3, bar: 3,
baz: 4, baz: 4,
quux: { quux: {
@ -190,5 +190,5 @@ test(function nestedDottedObjects() {
o_O: true o_O: true
} }
}); });
assertEq(argv.beep, { boop: true }); assertEquals(argv.beep, { boop: true });
}); });

View file

@ -1,26 +1,26 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function numbericShortArgs() { test(function numbericShortArgs() {
assertEq(parse(["-n123"]), { n: 123, _: [] }); assertEquals(parse(["-n123"]), { n: 123, _: [] });
assertEq(parse(["-123", "456"]), { 1: true, 2: true, 3: 456, _: [] }); assertEquals(parse(["-123", "456"]), { 1: true, 2: true, 3: 456, _: [] });
}); });
test(function short() { test(function short() {
assertEq(parse(["-b"]), { b: true, _: [] }); assertEquals(parse(["-b"]), { b: true, _: [] });
assertEq(parse(["foo", "bar", "baz"]), { _: ["foo", "bar", "baz"] }); assertEquals(parse(["foo", "bar", "baz"]), { _: ["foo", "bar", "baz"] });
assertEq(parse(["-cats"]), { c: true, a: true, t: true, s: true, _: [] }); assertEquals(parse(["-cats"]), { c: true, a: true, t: true, s: true, _: [] });
assertEq(parse(["-cats", "meow"]), { assertEquals(parse(["-cats", "meow"]), {
c: true, c: true,
a: true, a: true,
t: true, t: true,
s: "meow", s: "meow",
_: [] _: []
}); });
assertEq(parse(["-h", "localhost"]), { h: "localhost", _: [] }); assertEquals(parse(["-h", "localhost"]), { h: "localhost", _: [] });
assertEq(parse(["-h", "localhost", "-p", "555"]), { assertEquals(parse(["-h", "localhost", "-p", "555"]), {
h: "localhost", h: "localhost",
p: 555, p: 555,
_: [] _: []
@ -28,7 +28,7 @@ test(function short() {
}); });
test(function mixedShortBoolAndCapture() { test(function mixedShortBoolAndCapture() {
assertEq(parse(["-h", "localhost", "-fp", "555", "script.js"]), { assertEquals(parse(["-h", "localhost", "-fp", "555", "script.js"]), {
f: true, f: true,
p: 555, p: 555,
h: "localhost", h: "localhost",
@ -37,7 +37,7 @@ test(function mixedShortBoolAndCapture() {
}); });
test(function shortAndLong() { test(function shortAndLong() {
assertEq(parse(["-h", "localhost", "-fp", "555", "script.js"]), { assertEquals(parse(["-h", "localhost", "-fp", "555", "script.js"]), {
f: true, f: true,
p: 555, p: 555,
h: "localhost", h: "localhost",

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
// stops parsing on the first non-option when stopEarly is set // stops parsing on the first non-option when stopEarly is set
@ -9,7 +9,7 @@ test(function stopParsing() {
stopEarly: true stopEarly: true
}); });
assertEq(argv, { assertEquals(argv, {
aaa: "bbb", aaa: "bbb",
_: ["ccc", "--ddd"] _: ["ccc", "--ddd"]
}); });

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function booleanAndAliasIsNotUnknown() { test(function booleanAndAliasIsNotUnknown() {
@ -19,7 +19,7 @@ test(function booleanAndAliasIsNotUnknown() {
const aliasedArgv = parse(aliased, opts); const aliasedArgv = parse(aliased, opts);
const propertyArgv = parse(regular, opts); const propertyArgv = parse(regular, opts);
assertEq(unknown, ["--derp", "-d"]); assertEquals(unknown, ["--derp", "-d"]);
}); });
test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown() { test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown() {
@ -32,8 +32,8 @@ test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown() {
boolean: true, boolean: true,
unknown: unknownFn unknown: unknownFn
}); });
assertEq(unknown, ["--tacos=good", "cow", "-p"]); assertEquals(unknown, ["--tacos=good", "cow", "-p"]);
assertEq(argv, { assertEquals(argv, {
honk: true, honk: true,
_: [] _: []
}); });
@ -55,7 +55,7 @@ test(function stringAndAliasIsNotUnkown() {
const aliasedArgv = parse(aliased, opts); const aliasedArgv = parse(aliased, opts);
const propertyArgv = parse(regular, opts); const propertyArgv = parse(regular, opts);
assertEq(unknown, ["--derp", "-d"]); assertEquals(unknown, ["--derp", "-d"]);
}); });
test(function defaultAndAliasIsNotUnknown() { test(function defaultAndAliasIsNotUnknown() {
@ -74,7 +74,7 @@ test(function defaultAndAliasIsNotUnknown() {
const aliasedArgv = parse(aliased, opts); const aliasedArgv = parse(aliased, opts);
const propertyArgv = parse(regular, opts); const propertyArgv = parse(regular, opts);
assertEq(unknown, []); assertEquals(unknown, []);
}); });
test(function valueFollowingDoubleHyphenIsNotUnknown() { test(function valueFollowingDoubleHyphenIsNotUnknown() {
@ -90,8 +90,8 @@ test(function valueFollowingDoubleHyphenIsNotUnknown() {
}; };
const argv = parse(aliased, opts); const argv = parse(aliased, opts);
assertEq(unknown, ["--bad"]); assertEquals(unknown, ["--bad"]);
assertEq(argv, { assertEquals(argv, {
"--": ["good", "arg"], "--": ["good", "arg"],
_: [] _: []
}); });

View file

@ -1,8 +1,8 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts"; import { parse } from "../mod.ts";
test(function whitespaceShouldBeWhitespace() { test(function whitespaceShouldBeWhitespace() {
assertEq(parse(["-x", "\t"]).x, "\t"); assertEquals(parse(["-x", "\t"]).x, "\t");
}); });

View file

@ -1,7 +1,7 @@
const { mkdir, open } = Deno; const { mkdir, open } = Deno;
import { FileInfo } from "deno"; import { FileInfo } from "deno";
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { glob } from "./glob.ts"; import { glob } from "./glob.ts";
import { join } from "./path.ts"; import { join } from "./path.ts";
import { testWalk } from "./walk_test.ts"; import { testWalk } from "./walk_test.ts";
@ -23,43 +23,43 @@ async function walkArray(
const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) => const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) =>
f.path.replace(/\\/g, "/") f.path.replace(/\\/g, "/")
).sort(); ).sort();
assertEq(arr, arr_sync); assertEquals(arr, arr_sync);
return arr; return arr;
} }
test({ test({
name: "glob: glob to regex", name: "glob: glob to regex",
fn() { fn() {
assertEq(glob("unicorn.*") instanceof RegExp, true); assertEquals(glob("unicorn.*") instanceof RegExp, true);
assertEq(glob("unicorn.*").test("poney.ts"), false); assertEquals(glob("unicorn.*").test("poney.ts"), false);
assertEq(glob("unicorn.*").test("unicorn.py"), true); assertEquals(glob("unicorn.*").test("unicorn.py"), true);
assertEq(glob("*.ts").test("poney.ts"), true); assertEquals(glob("*.ts").test("poney.ts"), true);
assertEq(glob("*.ts").test("unicorn.js"), false); assertEquals(glob("*.ts").test("unicorn.js"), false);
assertEq( assertEquals(
glob(join("unicorn", "**", "cathedral.ts")).test( glob(join("unicorn", "**", "cathedral.ts")).test(
join("unicorn", "in", "the", "cathedral.ts") join("unicorn", "in", "the", "cathedral.ts")
), ),
true true
); );
assertEq( assertEquals(
glob(join("unicorn", "**", "cathedral.ts")).test( glob(join("unicorn", "**", "cathedral.ts")).test(
join("unicorn", "in", "the", "kitchen.ts") join("unicorn", "in", "the", "kitchen.ts")
), ),
false false
); );
assertEq( assertEquals(
glob(join("unicorn", "**", "bathroom.*")).test( glob(join("unicorn", "**", "bathroom.*")).test(
join("unicorn", "sleeping", "in", "bathroom.py") join("unicorn", "sleeping", "in", "bathroom.py")
), ),
true true
); );
assertEq( assertEquals(
glob(join("unicorn", "!(sleeping)", "bathroom.ts"), { glob(join("unicorn", "!(sleeping)", "bathroom.ts"), {
extended: true extended: true
}).test(join("unicorn", "flying", "bathroom.ts")), }).test(join("unicorn", "flying", "bathroom.ts")),
true true
); );
assertEq( assertEquals(
glob(join("unicorn", "(!sleeping)", "bathroom.ts"), { glob(join("unicorn", "(!sleeping)", "bathroom.ts"), {
extended: true extended: true
}).test(join("unicorn", "sleeping", "bathroom.ts")), }).test(join("unicorn", "sleeping", "bathroom.ts")),
@ -75,8 +75,8 @@ testWalk(
}, },
async function globInWalk() { async function globInWalk() {
const arr = await walkArray(".", { match: [glob("*.ts")] }); const arr = await walkArray(".", { match: [glob("*.ts")] });
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "./a/x.ts"); assertEquals(arr[0], "./a/x.ts");
} }
); );
@ -90,9 +90,9 @@ testWalk(
}, },
async function globInWalkWildcardFiles() { async function globInWalkWildcardFiles() {
const arr = await walkArray(".", { match: [glob("*.ts")] }); const arr = await walkArray(".", { match: [glob("*.ts")] });
assertEq(arr.length, 2); assertEquals(arr.length, 2);
assertEq(arr[0], "./a/x.ts"); assertEquals(arr[0], "./a/x.ts");
assertEq(arr[1], "./b/z.ts"); assertEquals(arr[1], "./b/z.ts");
} }
); );
@ -111,8 +111,8 @@ testWalk(
}) })
] ]
}); });
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "./a/yo/x.ts"); assertEquals(arr[0], "./a/yo/x.ts");
} }
); );
@ -135,9 +135,9 @@ testWalk(
}) })
] ]
}); });
assertEq(arr.length, 2); assertEquals(arr.length, 2);
assertEq(arr[0], "./a/deno/x.ts"); assertEquals(arr[0], "./a/deno/x.ts");
assertEq(arr[1], "./a/raptor/x.ts"); assertEquals(arr[1], "./a/raptor/x.ts");
} }
); );
@ -152,8 +152,8 @@ testWalk(
match: [glob("x.*", { flags: "g", globstar: true })] match: [glob("x.*", { flags: "g", globstar: true })]
}); });
console.log(arr); console.log(arr);
assertEq(arr.length, 2); assertEquals(arr.length, 2);
assertEq(arr[0], "./x.js"); assertEquals(arr[0], "./x.js");
assertEq(arr[1], "./x.ts"); assertEquals(arr[1], "./x.ts");
} }
); );

View file

@ -4,11 +4,11 @@
import * as deno from "deno"; import * as deno from "deno";
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { globrex } from "./globrex.ts"; import { globrex } from "./globrex.ts";
const isWin = deno.platform.os === "win"; const isWin = deno.platform.os === "win";
const t = { equal: assertEq, is: assertEq }; const t = { equal: assertEquals, is: assertEquals };
function match(glob, strUnix, strWin?, opts = {}) { function match(glob, strUnix, strWin?, opts = {}) {
if (typeof strWin === "object") { if (typeof strWin === "object") {

View file

@ -2,72 +2,75 @@
// Ported from https://github.com/browserify/path-browserify/ // Ported from https://github.com/browserify/path-browserify/
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
test(function basename() { test(function basename() {
assertEq(path.basename(".js", ".js"), ""); assertEquals(path.basename(".js", ".js"), "");
assertEq(path.basename(""), ""); assertEquals(path.basename(""), "");
assertEq(path.basename("/dir/basename.ext"), "basename.ext"); assertEquals(path.basename("/dir/basename.ext"), "basename.ext");
assertEq(path.basename("/basename.ext"), "basename.ext"); assertEquals(path.basename("/basename.ext"), "basename.ext");
assertEq(path.basename("basename.ext"), "basename.ext"); assertEquals(path.basename("basename.ext"), "basename.ext");
assertEq(path.basename("basename.ext/"), "basename.ext"); assertEquals(path.basename("basename.ext/"), "basename.ext");
assertEq(path.basename("basename.ext//"), "basename.ext"); assertEquals(path.basename("basename.ext//"), "basename.ext");
assertEq(path.basename("aaa/bbb", "/bbb"), "bbb"); assertEquals(path.basename("aaa/bbb", "/bbb"), "bbb");
assertEq(path.basename("aaa/bbb", "a/bbb"), "bbb"); assertEquals(path.basename("aaa/bbb", "a/bbb"), "bbb");
assertEq(path.basename("aaa/bbb", "bbb"), "bbb"); assertEquals(path.basename("aaa/bbb", "bbb"), "bbb");
assertEq(path.basename("aaa/bbb//", "bbb"), "bbb"); assertEquals(path.basename("aaa/bbb//", "bbb"), "bbb");
assertEq(path.basename("aaa/bbb", "bb"), "b"); assertEquals(path.basename("aaa/bbb", "bb"), "b");
assertEq(path.basename("aaa/bbb", "b"), "bb"); assertEquals(path.basename("aaa/bbb", "b"), "bb");
assertEq(path.basename("/aaa/bbb", "/bbb"), "bbb"); assertEquals(path.basename("/aaa/bbb", "/bbb"), "bbb");
assertEq(path.basename("/aaa/bbb", "a/bbb"), "bbb"); assertEquals(path.basename("/aaa/bbb", "a/bbb"), "bbb");
assertEq(path.basename("/aaa/bbb", "bbb"), "bbb"); assertEquals(path.basename("/aaa/bbb", "bbb"), "bbb");
assertEq(path.basename("/aaa/bbb//", "bbb"), "bbb"); assertEquals(path.basename("/aaa/bbb//", "bbb"), "bbb");
assertEq(path.basename("/aaa/bbb", "bb"), "b"); assertEquals(path.basename("/aaa/bbb", "bb"), "b");
assertEq(path.basename("/aaa/bbb", "b"), "bb"); assertEquals(path.basename("/aaa/bbb", "b"), "bb");
assertEq(path.basename("/aaa/bbb"), "bbb"); assertEquals(path.basename("/aaa/bbb"), "bbb");
assertEq(path.basename("/aaa/"), "aaa"); assertEquals(path.basename("/aaa/"), "aaa");
assertEq(path.basename("/aaa/b"), "b"); assertEquals(path.basename("/aaa/b"), "b");
assertEq(path.basename("/a/b"), "b"); assertEquals(path.basename("/a/b"), "b");
assertEq(path.basename("//a"), "a"); assertEquals(path.basename("//a"), "a");
// On unix a backslash is just treated as any other character. // On unix a backslash is just treated as any other character.
assertEq(path.posix.basename("\\dir\\basename.ext"), "\\dir\\basename.ext"); assertEquals(
assertEq(path.posix.basename("\\basename.ext"), "\\basename.ext"); path.posix.basename("\\dir\\basename.ext"),
assertEq(path.posix.basename("basename.ext"), "basename.ext"); "\\dir\\basename.ext"
assertEq(path.posix.basename("basename.ext\\"), "basename.ext\\"); );
assertEq(path.posix.basename("basename.ext\\\\"), "basename.ext\\\\"); assertEquals(path.posix.basename("\\basename.ext"), "\\basename.ext");
assertEq(path.posix.basename("foo"), "foo"); 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 // POSIX filenames may include control characters
const controlCharFilename = "Icon" + String.fromCharCode(13); const controlCharFilename = "Icon" + String.fromCharCode(13);
assertEq( assertEquals(
path.posix.basename("/a/b/" + controlCharFilename), path.posix.basename("/a/b/" + controlCharFilename),
controlCharFilename controlCharFilename
); );
}); });
test(function basenameWin32() { test(function basenameWin32() {
assertEq(path.win32.basename("\\dir\\basename.ext"), "basename.ext"); assertEquals(path.win32.basename("\\dir\\basename.ext"), "basename.ext");
assertEq(path.win32.basename("\\basename.ext"), "basename.ext"); assertEquals(path.win32.basename("\\basename.ext"), "basename.ext");
assertEq(path.win32.basename("basename.ext"), "basename.ext"); assertEquals(path.win32.basename("basename.ext"), "basename.ext");
assertEq(path.win32.basename("basename.ext\\"), "basename.ext"); assertEquals(path.win32.basename("basename.ext\\"), "basename.ext");
assertEq(path.win32.basename("basename.ext\\\\"), "basename.ext"); assertEquals(path.win32.basename("basename.ext\\\\"), "basename.ext");
assertEq(path.win32.basename("foo"), "foo"); assertEquals(path.win32.basename("foo"), "foo");
assertEq(path.win32.basename("aaa\\bbb", "\\bbb"), "bbb"); assertEquals(path.win32.basename("aaa\\bbb", "\\bbb"), "bbb");
assertEq(path.win32.basename("aaa\\bbb", "a\\bbb"), "bbb"); assertEquals(path.win32.basename("aaa\\bbb", "a\\bbb"), "bbb");
assertEq(path.win32.basename("aaa\\bbb", "bbb"), "bbb"); assertEquals(path.win32.basename("aaa\\bbb", "bbb"), "bbb");
assertEq(path.win32.basename("aaa\\bbb\\\\\\\\", "bbb"), "bbb"); assertEquals(path.win32.basename("aaa\\bbb\\\\\\\\", "bbb"), "bbb");
assertEq(path.win32.basename("aaa\\bbb", "bb"), "b"); assertEquals(path.win32.basename("aaa\\bbb", "bb"), "b");
assertEq(path.win32.basename("aaa\\bbb", "b"), "bb"); assertEquals(path.win32.basename("aaa\\bbb", "b"), "bb");
assertEq(path.win32.basename("C:"), ""); assertEquals(path.win32.basename("C:"), "");
assertEq(path.win32.basename("C:."), "."); assertEquals(path.win32.basename("C:."), ".");
assertEq(path.win32.basename("C:\\"), ""); assertEquals(path.win32.basename("C:\\"), "");
assertEq(path.win32.basename("C:\\dir\\base.ext"), "base.ext"); assertEquals(path.win32.basename("C:\\dir\\base.ext"), "base.ext");
assertEq(path.win32.basename("C:\\basename.ext"), "basename.ext"); assertEquals(path.win32.basename("C:\\basename.ext"), "basename.ext");
assertEq(path.win32.basename("C:basename.ext"), "basename.ext"); assertEquals(path.win32.basename("C:basename.ext"), "basename.ext");
assertEq(path.win32.basename("C:basename.ext\\"), "basename.ext"); assertEquals(path.win32.basename("C:basename.ext\\"), "basename.ext");
assertEq(path.win32.basename("C:basename.ext\\\\"), "basename.ext"); assertEquals(path.win32.basename("C:basename.ext\\\\"), "basename.ext");
assertEq(path.win32.basename("C:foo"), "foo"); assertEquals(path.win32.basename("C:foo"), "foo");
assertEq(path.win32.basename("file:stream"), "file:stream"); assertEquals(path.win32.basename("file:stream"), "file:stream");
}); });

View file

@ -2,61 +2,61 @@
// Ported from https://github.com/browserify/path-browserify/ // Ported from https://github.com/browserify/path-browserify/
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
test(function dirname() { test(function dirname() {
assertEq(path.posix.dirname("/a/b/"), "/a"); assertEquals(path.posix.dirname("/a/b/"), "/a");
assertEq(path.posix.dirname("/a/b"), "/a"); assertEquals(path.posix.dirname("/a/b"), "/a");
assertEq(path.posix.dirname("/a"), "/"); assertEquals(path.posix.dirname("/a"), "/");
assertEq(path.posix.dirname(""), "."); assertEquals(path.posix.dirname(""), ".");
assertEq(path.posix.dirname("/"), "/"); assertEquals(path.posix.dirname("/"), "/");
assertEq(path.posix.dirname("////"), "/"); assertEquals(path.posix.dirname("////"), "/");
assertEq(path.posix.dirname("//a"), "//"); assertEquals(path.posix.dirname("//a"), "//");
assertEq(path.posix.dirname("foo"), "."); assertEquals(path.posix.dirname("foo"), ".");
}); });
test(function dirnameWin32() { test(function dirnameWin32() {
assertEq(path.win32.dirname("c:\\"), "c:\\"); assertEquals(path.win32.dirname("c:\\"), "c:\\");
assertEq(path.win32.dirname("c:\\foo"), "c:\\"); assertEquals(path.win32.dirname("c:\\foo"), "c:\\");
assertEq(path.win32.dirname("c:\\foo\\"), "c:\\"); assertEquals(path.win32.dirname("c:\\foo\\"), "c:\\");
assertEq(path.win32.dirname("c:\\foo\\bar"), "c:\\foo"); assertEquals(path.win32.dirname("c:\\foo\\bar"), "c:\\foo");
assertEq(path.win32.dirname("c:\\foo\\bar\\"), "c:\\foo"); assertEquals(path.win32.dirname("c:\\foo\\bar\\"), "c:\\foo");
assertEq(path.win32.dirname("c:\\foo\\bar\\baz"), "c:\\foo\\bar"); assertEquals(path.win32.dirname("c:\\foo\\bar\\baz"), "c:\\foo\\bar");
assertEq(path.win32.dirname("\\"), "\\"); assertEquals(path.win32.dirname("\\"), "\\");
assertEq(path.win32.dirname("\\foo"), "\\"); assertEquals(path.win32.dirname("\\foo"), "\\");
assertEq(path.win32.dirname("\\foo\\"), "\\"); assertEquals(path.win32.dirname("\\foo\\"), "\\");
assertEq(path.win32.dirname("\\foo\\bar"), "\\foo"); assertEquals(path.win32.dirname("\\foo\\bar"), "\\foo");
assertEq(path.win32.dirname("\\foo\\bar\\"), "\\foo"); assertEquals(path.win32.dirname("\\foo\\bar\\"), "\\foo");
assertEq(path.win32.dirname("\\foo\\bar\\baz"), "\\foo\\bar"); assertEquals(path.win32.dirname("\\foo\\bar\\baz"), "\\foo\\bar");
assertEq(path.win32.dirname("c:"), "c:"); assertEquals(path.win32.dirname("c:"), "c:");
assertEq(path.win32.dirname("c:foo"), "c:"); assertEquals(path.win32.dirname("c:foo"), "c:");
assertEq(path.win32.dirname("c:foo\\"), "c:"); assertEquals(path.win32.dirname("c:foo\\"), "c:");
assertEq(path.win32.dirname("c:foo\\bar"), "c:foo"); assertEquals(path.win32.dirname("c:foo\\bar"), "c:foo");
assertEq(path.win32.dirname("c:foo\\bar\\"), "c:foo"); assertEquals(path.win32.dirname("c:foo\\bar\\"), "c:foo");
assertEq(path.win32.dirname("c:foo\\bar\\baz"), "c:foo\\bar"); assertEquals(path.win32.dirname("c:foo\\bar\\baz"), "c:foo\\bar");
assertEq(path.win32.dirname("file:stream"), "."); assertEquals(path.win32.dirname("file:stream"), ".");
assertEq(path.win32.dirname("dir\\file:stream"), "dir"); assertEquals(path.win32.dirname("dir\\file:stream"), "dir");
assertEq(path.win32.dirname("\\\\unc\\share"), "\\\\unc\\share"); assertEquals(path.win32.dirname("\\\\unc\\share"), "\\\\unc\\share");
assertEq(path.win32.dirname("\\\\unc\\share\\foo"), "\\\\unc\\share\\"); assertEquals(path.win32.dirname("\\\\unc\\share\\foo"), "\\\\unc\\share\\");
assertEq(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\"); assertEquals(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\");
assertEq( assertEquals(
path.win32.dirname("\\\\unc\\share\\foo\\bar"), path.win32.dirname("\\\\unc\\share\\foo\\bar"),
"\\\\unc\\share\\foo" "\\\\unc\\share\\foo"
); );
assertEq( assertEquals(
path.win32.dirname("\\\\unc\\share\\foo\\bar\\"), path.win32.dirname("\\\\unc\\share\\foo\\bar\\"),
"\\\\unc\\share\\foo" "\\\\unc\\share\\foo"
); );
assertEq( assertEquals(
path.win32.dirname("\\\\unc\\share\\foo\\bar\\baz"), path.win32.dirname("\\\\unc\\share\\foo\\bar\\baz"),
"\\\\unc\\share\\foo\\bar" "\\\\unc\\share\\foo\\bar"
); );
assertEq(path.win32.dirname("/a/b/"), "/a"); assertEquals(path.win32.dirname("/a/b/"), "/a");
assertEq(path.win32.dirname("/a/b"), "/a"); assertEquals(path.win32.dirname("/a/b"), "/a");
assertEq(path.win32.dirname("/a"), "/"); assertEquals(path.win32.dirname("/a"), "/");
assertEq(path.win32.dirname(""), "."); assertEquals(path.win32.dirname(""), ".");
assertEq(path.win32.dirname("/"), "/"); assertEquals(path.win32.dirname("/"), "/");
assertEq(path.win32.dirname("////"), "/"); assertEquals(path.win32.dirname("////"), "/");
assertEq(path.win32.dirname("foo"), "."); assertEquals(path.win32.dirname("foo"), ".");
}); });

View file

@ -2,7 +2,7 @@
// Ported from https://github.com/browserify/path-browserify/ // Ported from https://github.com/browserify/path-browserify/
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
const slashRE = /\//g; const slashRE = /\//g;
@ -56,35 +56,35 @@ test(function extname() {
pairs.forEach(function(p) { pairs.forEach(function(p) {
const input = p[0]; const input = p[0];
const expected = p[1]; 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. // On *nix, backslash is a valid name component like any other character.
assertEq(path.posix.extname(".\\"), ""); assertEquals(path.posix.extname(".\\"), "");
assertEq(path.posix.extname("..\\"), ".\\"); assertEquals(path.posix.extname("..\\"), ".\\");
assertEq(path.posix.extname("file.ext\\"), ".ext\\"); assertEquals(path.posix.extname("file.ext\\"), ".ext\\");
assertEq(path.posix.extname("file.ext\\\\"), ".ext\\\\"); assertEquals(path.posix.extname("file.ext\\\\"), ".ext\\\\");
assertEq(path.posix.extname("file\\"), ""); assertEquals(path.posix.extname("file\\"), "");
assertEq(path.posix.extname("file\\\\"), ""); assertEquals(path.posix.extname("file\\\\"), "");
assertEq(path.posix.extname("file.\\"), ".\\"); assertEquals(path.posix.extname("file.\\"), ".\\");
assertEq(path.posix.extname("file.\\\\"), ".\\\\"); assertEquals(path.posix.extname("file.\\\\"), ".\\\\");
}); });
test(function extnameWin32() { test(function extnameWin32() {
pairs.forEach(function(p) { pairs.forEach(function(p) {
const input = p[0].replace(slashRE, "\\"); const input = p[0].replace(slashRE, "\\");
const expected = p[1]; const expected = p[1];
assertEq(expected, path.win32.extname(input)); assertEquals(expected, path.win32.extname(input));
assertEq(expected, path.win32.extname("C:" + input)); assertEquals(expected, path.win32.extname("C:" + input));
}); });
// On Windows, backslash is a path separator. // On Windows, backslash is a path separator.
assertEq(path.win32.extname(".\\"), ""); assertEquals(path.win32.extname(".\\"), "");
assertEq(path.win32.extname("..\\"), ""); assertEquals(path.win32.extname("..\\"), "");
assertEq(path.win32.extname("file.ext\\"), ".ext"); assertEquals(path.win32.extname("file.ext\\"), ".ext");
assertEq(path.win32.extname("file.ext\\\\"), ".ext"); assertEquals(path.win32.extname("file.ext\\\\"), ".ext");
assertEq(path.win32.extname("file\\"), ""); assertEquals(path.win32.extname("file\\"), "");
assertEq(path.win32.extname("file\\\\"), ""); assertEquals(path.win32.extname("file\\\\"), "");
assertEq(path.win32.extname("file.\\"), "."); assertEquals(path.win32.extname("file.\\"), ".");
assertEq(path.win32.extname("file.\\\\"), "."); assertEquals(path.win32.extname("file.\\\\"), ".");
}); });

View file

@ -2,33 +2,33 @@
// Ported from https://github.com/browserify/path-browserify/ // Ported from https://github.com/browserify/path-browserify/
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
test(function isAbsolute() { test(function isAbsolute() {
assertEq(path.posix.isAbsolute("/home/foo"), true); assertEquals(path.posix.isAbsolute("/home/foo"), true);
assertEq(path.posix.isAbsolute("/home/foo/.."), true); assertEquals(path.posix.isAbsolute("/home/foo/.."), true);
assertEq(path.posix.isAbsolute("bar/"), false); assertEquals(path.posix.isAbsolute("bar/"), false);
assertEq(path.posix.isAbsolute("./baz"), false); assertEquals(path.posix.isAbsolute("./baz"), false);
}); });
test(function isAbsoluteWin32() { test(function isAbsoluteWin32() {
assertEq(path.win32.isAbsolute("/"), true); assertEquals(path.win32.isAbsolute("/"), true);
assertEq(path.win32.isAbsolute("//"), true); assertEquals(path.win32.isAbsolute("//"), true);
assertEq(path.win32.isAbsolute("//server"), true); assertEquals(path.win32.isAbsolute("//server"), true);
assertEq(path.win32.isAbsolute("//server/file"), true); assertEquals(path.win32.isAbsolute("//server/file"), true);
assertEq(path.win32.isAbsolute("\\\\server\\file"), true); assertEquals(path.win32.isAbsolute("\\\\server\\file"), true);
assertEq(path.win32.isAbsolute("\\\\server"), true); assertEquals(path.win32.isAbsolute("\\\\server"), true);
assertEq(path.win32.isAbsolute("\\\\"), true); assertEquals(path.win32.isAbsolute("\\\\"), true);
assertEq(path.win32.isAbsolute("c"), false); assertEquals(path.win32.isAbsolute("c"), false);
assertEq(path.win32.isAbsolute("c:"), false); assertEquals(path.win32.isAbsolute("c:"), false);
assertEq(path.win32.isAbsolute("c:\\"), true); assertEquals(path.win32.isAbsolute("c:\\"), true);
assertEq(path.win32.isAbsolute("c:/"), true); assertEquals(path.win32.isAbsolute("c:/"), true);
assertEq(path.win32.isAbsolute("c://"), true); assertEquals(path.win32.isAbsolute("c://"), true);
assertEq(path.win32.isAbsolute("C:/Users/"), true); assertEquals(path.win32.isAbsolute("C:/Users/"), true);
assertEq(path.win32.isAbsolute("C:\\Users\\"), true); assertEquals(path.win32.isAbsolute("C:\\Users\\"), true);
assertEq(path.win32.isAbsolute("C:cwd/another"), false); assertEquals(path.win32.isAbsolute("C:cwd/another"), false);
assertEq(path.win32.isAbsolute("C:cwd\\another"), false); assertEquals(path.win32.isAbsolute("C:cwd\\another"), false);
assertEq(path.win32.isAbsolute("directory/directory"), false); assertEquals(path.win32.isAbsolute("directory/directory"), false);
assertEq(path.win32.isAbsolute("directory\\directory"), false); assertEquals(path.win32.isAbsolute("directory\\directory"), false);
}); });

View file

@ -1,5 +1,5 @@
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
const backslashRE = /\\/g; const backslashRE = /\\/g;
@ -109,17 +109,17 @@ const windowsJoinTests = [
test(function join() { test(function join() {
joinTests.forEach(function(p) { joinTests.forEach(function(p) {
const actual = path.posix.join.apply(null, p[0]); const actual = path.posix.join.apply(null, p[0]);
assertEq(actual, p[1]); assertEquals(actual, p[1]);
}); });
}); });
test(function joinWin32() { test(function joinWin32() {
joinTests.forEach(function(p) { joinTests.forEach(function(p) {
const actual = path.win32.join.apply(null, p[0]).replace(backslashRE, "/"); const actual = path.win32.join.apply(null, p[0]).replace(backslashRE, "/");
assertEq(actual, p[1]); assertEquals(actual, p[1]);
}); });
windowsJoinTests.forEach(function(p) { windowsJoinTests.forEach(function(p) {
const actual = path.win32.join.apply(null, p[0]); const actual = path.win32.join.apply(null, p[0]);
assertEq(actual, p[1]); assertEquals(actual, p[1]);
}); });
}); });

View file

@ -2,7 +2,7 @@
// Ported from https://github.com/browserify/path-browserify/ // Ported from https://github.com/browserify/path-browserify/
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
const winPaths = [ const winPaths = [
@ -131,15 +131,15 @@ function checkParseFormat(path, paths) {
paths.forEach(function(p) { paths.forEach(function(p) {
const element = p[0]; const element = p[0];
const output = path.parse(element); const output = path.parse(element);
assertEq(typeof output.root, "string"); assertEquals(typeof output.root, "string");
assertEq(typeof output.dir, "string"); assertEquals(typeof output.dir, "string");
assertEq(typeof output.base, "string"); assertEquals(typeof output.base, "string");
assertEq(typeof output.ext, "string"); assertEquals(typeof output.ext, "string");
assertEq(typeof output.name, "string"); assertEquals(typeof output.name, "string");
assertEq(path.format(output), element); assertEquals(path.format(output), element);
assertEq(output.rooroot, undefined); assertEquals(output.rooroot, undefined);
assertEq(output.dir, output.dir ? path.dirname(element) : ""); assertEquals(output.dir, output.dir ? path.dirname(element) : "");
assertEq(output.base, path.basename(element)); assertEquals(output.base, path.basename(element));
}); });
} }
@ -149,14 +149,14 @@ function checkSpecialCaseParseFormat(path, testCases) {
const expect = testCase[1]; const expect = testCase[1];
const output = path.parse(element); const output = path.parse(element);
Object.keys(expect).forEach(function(key) { Object.keys(expect).forEach(function(key) {
assertEq(output[key], expect[key]); assertEquals(output[key], expect[key]);
}); });
}); });
} }
function checkFormat(path, testCases) { function checkFormat(path, testCases) {
testCases.forEach(function(testCase) { 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) { windowsTrailingTests.forEach(function(p) {
const actual = path.win32.parse(p[0] as string); const actual = path.win32.parse(p[0] as string);
const expected = p[1]; const expected = p[1];
assertEq(actual, expected); assertEquals(actual, expected);
}); });
}); });
@ -172,6 +172,6 @@ test(function parseTrailing() {
posixTrailingTests.forEach(function(p) { posixTrailingTests.forEach(function(p) {
const actual = path.posix.parse(p[0] as string); const actual = path.posix.parse(p[0] as string);
const expected = p[1]; const expected = p[1];
assertEq(actual, expected); assertEquals(actual, expected);
}); });
}); });

View file

@ -2,7 +2,7 @@
// Ported from https://github.com/browserify/path-browserify/ // Ported from https://github.com/browserify/path-browserify/
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
const relativeTests = { const relativeTests = {
@ -60,7 +60,7 @@ test(function relative() {
relativeTests.posix.forEach(function(p) { relativeTests.posix.forEach(function(p) {
const expected = p[2]; const expected = p[2];
const actual = path.posix.relative(p[0], p[1]); 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) { relativeTests.win32.forEach(function(p) {
const expected = p[2]; const expected = p[2];
const actual = path.win32.relative(p[0], p[1]); const actual = path.win32.relative(p[0], p[1]);
assertEq(actual, expected); assertEquals(actual, expected);
}); });
}); });

View file

@ -3,7 +3,7 @@
const { cwd } = Deno; const { cwd } = Deno;
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
const windowsTests = const windowsTests =
@ -38,13 +38,13 @@ const posixTests =
test(function resolve() { test(function resolve() {
posixTests.forEach(function(p) { posixTests.forEach(function(p) {
const actual = path.posix.resolve.apply(null, p[0]); const actual = path.posix.resolve.apply(null, p[0]);
assertEq(actual, p[1]); assertEquals(actual, p[1]);
}); });
}); });
test(function resolveWin32() { test(function resolveWin32() {
windowsTests.forEach(function(p) { windowsTests.forEach(function(p) {
const actual = path.win32.resolve.apply(null, p[0]); const actual = path.win32.resolve.apply(null, p[0]);
assertEq(actual, p[1]); assertEquals(actual, p[1]);
}); });
}); });

View file

@ -3,7 +3,7 @@
const { cwd } = Deno; const { cwd } = Deno;
import { test } from "../../testing/mod.ts"; import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts"; import { assertEquals } from "../../testing/asserts.ts";
import * as path from "./mod.ts"; import * as path from "./mod.ts";
const pwd = cwd(); const pwd = cwd();
@ -11,37 +11,37 @@ const pwd = cwd();
test(function joinZeroLength() { test(function joinZeroLength() {
// join will internally ignore all the zero-length strings and it will return // join will internally ignore all the zero-length strings and it will return
// '.' if the joined string is a zero-length string. // '.' if the joined string is a zero-length string.
assertEq(path.posix.join(""), "."); assertEquals(path.posix.join(""), ".");
assertEq(path.posix.join("", ""), "."); assertEquals(path.posix.join("", ""), ".");
if (path.win32) assertEq(path.win32.join(""), "."); if (path.win32) assertEquals(path.win32.join(""), ".");
if (path.win32) assertEq(path.win32.join("", ""), "."); if (path.win32) assertEquals(path.win32.join("", ""), ".");
assertEq(path.join(pwd), pwd); assertEquals(path.join(pwd), pwd);
assertEq(path.join(pwd, ""), pwd); assertEquals(path.join(pwd, ""), pwd);
}); });
test(function normalizeZeroLength() { test(function normalizeZeroLength() {
// normalize will return '.' if the input is a zero-length string // normalize will return '.' if the input is a zero-length string
assertEq(path.posix.normalize(""), "."); assertEquals(path.posix.normalize(""), ".");
if (path.win32) assertEq(path.win32.normalize(""), "."); if (path.win32) assertEquals(path.win32.normalize(""), ".");
assertEq(path.normalize(pwd), pwd); assertEquals(path.normalize(pwd), pwd);
}); });
test(function isAbsoluteZeroLength() { test(function isAbsoluteZeroLength() {
// Since '' is not a valid path in any of the common environments, return false // Since '' is not a valid path in any of the common environments, return false
assertEq(path.posix.isAbsolute(""), false); assertEquals(path.posix.isAbsolute(""), false);
if (path.win32) assertEq(path.win32.isAbsolute(""), false); if (path.win32) assertEquals(path.win32.isAbsolute(""), false);
}); });
test(function resolveZeroLength() { test(function resolveZeroLength() {
// resolve, internally ignores all the zero-length strings and returns the // resolve, internally ignores all the zero-length strings and returns the
// current working directory // current working directory
assertEq(path.resolve(""), pwd); assertEquals(path.resolve(""), pwd);
assertEq(path.resolve("", ""), pwd); assertEquals(path.resolve("", ""), pwd);
}); });
test(function relativeZeroLength() { test(function relativeZeroLength() {
// relative, internally calls resolve. So, '' is actually the current directory // relative, internally calls resolve. So, '' is actually the current directory
assertEq(path.relative("", pwd), ""); assertEquals(path.relative("", pwd), "");
assertEq(path.relative(pwd, ""), ""); assertEquals(path.relative(pwd, ""), "");
assertEq(path.relative(pwd, pwd), ""); assertEquals(path.relative(pwd, pwd), "");
}); });

View file

@ -11,7 +11,7 @@ const {
import { FileInfo } from "deno"; import { FileInfo } from "deno";
import { walk, walkSync, WalkOptions } from "./walk.ts"; import { walk, walkSync, WalkOptions } from "./walk.ts";
import { test, TestFunction } from "../testing/mod.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"; const isWindows = platform.os === "win";
@ -47,7 +47,7 @@ async function walkArray(
const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) => const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) =>
f.path.replace(/\\/g, "/") f.path.replace(/\\/g, "/")
).sort(); ).sort();
assertEq(arr, arr_sync); assertEquals(arr, arr_sync);
return arr; return arr;
} }
@ -56,7 +56,7 @@ async function touch(path: string): Promise<void> {
} }
function assertReady(expectedLength: number) { function assertReady(expectedLength: number) {
const arr = Array.from(walkSync(), (f: FileInfo) => f.path); const arr = Array.from(walkSync(), (f: FileInfo) => f.path);
assertEq(arr.length, expectedLength); assertEquals(arr.length, expectedLength);
} }
testWalk( testWalk(
@ -65,7 +65,7 @@ testWalk(
}, },
async function emptyDir() { async function emptyDir() {
const arr = await walkArray(); const arr = await walkArray();
assertEq(arr.length, 0); assertEquals(arr.length, 0);
} }
); );
@ -75,8 +75,8 @@ testWalk(
}, },
async function singleFile() { async function singleFile() {
const arr = await walkArray(); const arr = await walkArray();
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "./x"); assertEquals(arr[0], "./x");
} }
); );
@ -89,11 +89,11 @@ testWalk(
for (const f of walkSync()) { for (const f of walkSync()) {
count += 1; count += 1;
} }
assertEq(count, 1); assertEquals(count, 1);
for await (const f of walk()) { for await (const f of walk()) {
count += 1; count += 1;
} }
assertEq(count, 2); assertEquals(count, 2);
} }
); );
@ -104,8 +104,8 @@ testWalk(
}, },
async function nestedSingleFile() { async function nestedSingleFile() {
const arr = await walkArray(); const arr = await walkArray();
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "./a/x"); assertEquals(arr[0], "./a/x");
} }
); );
@ -117,10 +117,10 @@ testWalk(
async function depth() { async function depth() {
assertReady(1); assertReady(1);
const arr_3 = await walkArray(".", { maxDepth: 3 }); const arr_3 = await walkArray(".", { maxDepth: 3 });
assertEq(arr_3.length, 0); assertEquals(arr_3.length, 0);
const arr_5 = await walkArray(".", { maxDepth: 5 }); const arr_5 = await walkArray(".", { maxDepth: 5 });
assertEq(arr_5.length, 1); assertEquals(arr_5.length, 1);
assertEq(arr_5[0], "./a/b/c/d/x"); assertEquals(arr_5[0], "./a/b/c/d/x");
} }
); );
@ -132,8 +132,8 @@ testWalk(
async function ext() { async function ext() {
assertReady(2); assertReady(2);
const arr = await walkArray(".", { exts: [".ts"] }); const arr = await walkArray(".", { exts: [".ts"] });
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "./x.ts"); assertEquals(arr[0], "./x.ts");
} }
); );
@ -146,9 +146,9 @@ testWalk(
async function extAny() { async function extAny() {
assertReady(3); assertReady(3);
const arr = await walkArray(".", { exts: [".rs", ".ts"] }); const arr = await walkArray(".", { exts: [".rs", ".ts"] });
assertEq(arr.length, 2); assertEquals(arr.length, 2);
assertEq(arr[0], "./x.ts"); assertEquals(arr[0], "./x.ts");
assertEq(arr[1], "./y.rs"); assertEquals(arr[1], "./y.rs");
} }
); );
@ -160,8 +160,8 @@ testWalk(
async function match() { async function match() {
assertReady(2); assertReady(2);
const arr = await walkArray(".", { match: [/x/] }); const arr = await walkArray(".", { match: [/x/] });
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "./x"); assertEquals(arr[0], "./x");
} }
); );
@ -174,9 +174,9 @@ testWalk(
async function matchAny() { async function matchAny() {
assertReady(3); assertReady(3);
const arr = await walkArray(".", { match: [/x/, /y/] }); const arr = await walkArray(".", { match: [/x/, /y/] });
assertEq(arr.length, 2); assertEquals(arr.length, 2);
assertEq(arr[0], "./x"); assertEquals(arr[0], "./x");
assertEq(arr[1], "./y"); assertEquals(arr[1], "./y");
} }
); );
@ -188,8 +188,8 @@ testWalk(
async function skip() { async function skip() {
assertReady(2); assertReady(2);
const arr = await walkArray(".", { skip: [/x/] }); const arr = await walkArray(".", { skip: [/x/] });
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "./y"); assertEquals(arr[0], "./y");
} }
); );
@ -202,8 +202,8 @@ testWalk(
async function skipAny() { async function skipAny() {
assertReady(3); assertReady(3);
const arr = await walkArray(".", { skip: [/x/, /y/] }); const arr = await walkArray(".", { skip: [/x/, /y/] });
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "./z"); assertEquals(arr[0], "./z");
} }
); );
@ -218,19 +218,19 @@ testWalk(
async function subDir() { async function subDir() {
assertReady(3); assertReady(3);
const arr = await walkArray("b"); const arr = await walkArray("b");
assertEq(arr.length, 1); assertEquals(arr.length, 1);
assertEq(arr[0], "b/z"); assertEquals(arr[0], "b/z");
} }
); );
testWalk(async (d: string) => {}, async function onError() { testWalk(async (d: string) => {}, async function onError() {
assertReady(0); assertReady(0);
const ignored = await walkArray("missing"); const ignored = await walkArray("missing");
assertEq(ignored.length, 0); assertEquals(ignored.length, 0);
let errors = 0; let errors = 0;
const arr = await walkArray("missing", { onError: e => (errors += 1) }); const arr = await walkArray("missing", { onError: e => (errors += 1) });
// It's 2 since walkArray iterates over both sync and async. // It's 2 since walkArray iterates over both sync and async.
assertEq(errors, 2); assertEquals(errors, 2);
}); });
testWalk( testWalk(
@ -255,11 +255,11 @@ testWalk(
assertReady(3); assertReady(3);
const files = await walkArray("a"); const files = await walkArray("a");
assertEq(files.length, 2); assertEquals(files.length, 2);
assert(!files.includes("a/bb/z")); assert(!files.includes("a/bb/z"));
const arr = await walkArray("a", { followSymlinks: true }); const arr = await walkArray("a", { followSymlinks: true });
assertEq(arr.length, 3); assertEquals(arr.length, 3);
assert(arr.some(f => f.endsWith("/b/z"))); assert(arr.some(f => f.endsWith("/b/z")));
} }
); );

View file

@ -2,7 +2,7 @@
const { readFile, run } = Deno; const { readFile, run } = Deno;
import { test } from "../testing/mod.ts"; 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 { BufReader } from "../io/bufio.ts";
import { TextProtoReader } from "../textproto/mod.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"); 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-origin"));
assert(res.headers.has("access-control-allow-headers")); 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 downloadedFile = await res.text();
const localFile = new TextDecoder().decode( const localFile = new TextDecoder().decode(
await readFile("./azure-pipelines.yml") await readFile("./azure-pipelines.yml")
); );
assertEq(downloadedFile, localFile); assertEquals(downloadedFile, localFile);
} finally { } finally {
killFileServer(); killFileServer();
} }
@ -66,7 +66,7 @@ test(async function serveFallback() {
const res = await fetch("http://localhost:4500/badfile.txt"); const res = await fetch("http://localhost:4500/badfile.txt");
assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-origin"));
assert(res.headers.has("access-control-allow-headers")); assert(res.headers.has("access-control-allow-headers"));
assertEq(res.status, 404); assertEquals(res.status, 404);
} finally { } finally {
killFileServer(); killFileServer();
} }

View file

@ -7,7 +7,7 @@
const { Buffer } = Deno; const { Buffer } = Deno;
import { test } from "../testing/mod.ts"; 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 { Response, ServerRequest } from "./server.ts";
import { BufReader, BufWriter } from "../io/bufio.ts"; import { BufReader, BufWriter } from "../io/bufio.ts";
@ -47,7 +47,7 @@ test(async function responseWrite() {
request.w = bufw; request.w = bufw;
await request.respond(testCase.response); 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")); const buf = new Buffer(enc.encode("Hello"));
req.r = new BufReader(buf); req.r = new BufReader(buf);
const body = dec.decode(await req.body()); const body = dec.decode(await req.body());
assertEq(body, "Hello"); assertEquals(body, "Hello");
} }
// Larger than internal buf // Larger than internal buf
@ -71,7 +71,7 @@ test(async function requestBodyWithContentLength() {
const buf = new Buffer(enc.encode(longText)); const buf = new Buffer(enc.encode(longText));
req.r = new BufReader(buf); req.r = new BufReader(buf);
const body = dec.decode(await req.body()); 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)); const buf = new Buffer(enc.encode(chunksData));
req.r = new BufReader(buf); req.r = new BufReader(buf);
const body = dec.decode(await req.body()); const body = dec.decode(await req.body());
assertEq(body, shortText); assertEquals(body, shortText);
} }
// Larger than internal buf // Larger than internal buf
@ -120,7 +120,7 @@ test(async function requestBodyWithTransferEncoding() {
const buf = new Buffer(enc.encode(chunksData)); const buf = new Buffer(enc.encode(chunksData));
req.r = new BufReader(buf); req.r = new BufReader(buf);
const body = dec.decode(await req.body()); const body = dec.decode(await req.body());
assertEq(body, longText); assertEquals(body, longText);
} }
}); });
@ -136,7 +136,7 @@ test(async function requestBodyStreamWithContentLength() {
let offset = 0; let offset = 0;
for await (const chunk of it) { for await (const chunk of it) {
const s = dec.decode(chunk); const s = dec.decode(chunk);
assertEq(shortText.substr(offset, s.length), s); assertEquals(shortText.substr(offset, s.length), s);
offset += s.length; offset += s.length;
} }
} }
@ -153,7 +153,7 @@ test(async function requestBodyStreamWithContentLength() {
let offset = 0; let offset = 0;
for await (const chunk of it) { for await (const chunk of it) {
const s = dec.decode(chunk); const s = dec.decode(chunk);
assertEq(longText.substr(offset, s.length), s); assertEquals(longText.substr(offset, s.length), s);
offset += s.length; offset += s.length;
} }
} }
@ -183,7 +183,7 @@ test(async function requestBodyStreamWithTransferEncoding() {
let offset = 0; let offset = 0;
for await (const chunk of it) { for await (const chunk of it) {
const s = dec.decode(chunk); const s = dec.decode(chunk);
assertEq(shortText.substr(offset, s.length), s); assertEquals(shortText.substr(offset, s.length), s);
offset += s.length; offset += s.length;
} }
} }
@ -212,7 +212,7 @@ test(async function requestBodyStreamWithTransferEncoding() {
let offset = 0; let offset = 0;
for await (const chunk of it) { for await (const chunk of it) {
const s = dec.decode(chunk); const s = dec.decode(chunk);
assertEq(longText.substr(offset, s.length), s); assertEquals(longText.substr(offset, s.length), s);
offset += s.length; offset += s.length;
} }
} }

View file

@ -6,7 +6,7 @@
const { Buffer } = Deno; const { Buffer } = Deno;
import { Reader, ReadResult } from "deno"; import { Reader, ReadResult } from "deno";
import { test } from "../testing/mod.ts"; 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 { BufReader, BufWriter } from "./bufio.ts";
import * as iotest from "./iotest.ts"; import * as iotest from "./iotest.ts";
import { charCode, copyBytes, stringsReader } from "./util.ts"; import { charCode, copyBytes, stringsReader } from "./util.ts";
@ -32,7 +32,7 @@ test(async function bufioReaderSimple() {
const data = "hello world"; const data = "hello world";
const b = new BufReader(stringsReader(data)); const b = new BufReader(stringsReader(data));
const s = await readBytes(b); const s = await readBytes(b);
assertEq(s, data); assertEquals(s, data);
}); });
interface ReadMaker { interface ReadMaker {
@ -114,7 +114,7 @@ test(async function bufioBufReader() {
const debugStr = const debugStr =
`reader=${readmaker.name} ` + `reader=${readmaker.name} ` +
`fn=${bufreader.name} bufsize=${bufsize} want=${text} got=${s}`; `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(); const decoder = new TextDecoder();
let actual = decoder.decode(line); let actual = decoder.decode(line);
assertEq(err, "BufferFull"); assertEquals(err, "BufferFull");
assertEq(actual, "And now, hello, "); assertEquals(actual, "And now, hello, ");
[line, err] = await buf.readSlice(charCode("!")); [line, err] = await buf.readSlice(charCode("!"));
actual = decoder.decode(line); actual = decoder.decode(line);
assertEq(actual, "world!"); assertEquals(actual, "world!");
assert(err == null); assert(err == null);
}); });
@ -178,20 +178,20 @@ async function testReadLine(input: Uint8Array): Promise<void> {
if (line.byteLength > 0 && err != null) { if (line.byteLength > 0 && err != null) {
throw Error("readLine returned both data and error"); throw Error("readLine returned both data and error");
} }
assertEq(isPrefix, false); assertEquals(isPrefix, false);
if (err == "EOF") { if (err == "EOF") {
break; break;
} }
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
let want = testOutput.subarray(done, done + line.byteLength); let want = testOutput.subarray(done, done + line.byteLength);
assertEq( assertEquals(
line, line,
want, want,
`Bad line at stride ${stride}: want: ${want} got: ${line}` `Bad line at stride ${stride}: want: ${want} got: ${line}`
); );
done += line.byteLength; done += line.byteLength;
} }
assertEq( assertEquals(
done, done,
testOutput.byteLength, testOutput.byteLength,
`readLine didn't return everything: got: ${done}, ` + `readLine didn't return everything: got: ${done}, ` +
@ -215,54 +215,54 @@ test(async function bufioPeek() {
); );
let [actual, err] = await buf.peek(1); let [actual, err] = await buf.peek(1);
assertEq(decoder.decode(actual), "a"); assertEquals(decoder.decode(actual), "a");
assert(err == null); assert(err == null);
[actual, err] = await buf.peek(4); [actual, err] = await buf.peek(4);
assertEq(decoder.decode(actual), "abcd"); assertEquals(decoder.decode(actual), "abcd");
assert(err == null); assert(err == null);
[actual, err] = await buf.peek(32); [actual, err] = await buf.peek(32);
assertEq(decoder.decode(actual), "abcdefghijklmnop"); assertEquals(decoder.decode(actual), "abcdefghijklmnop");
assertEq(err, "BufferFull"); assertEquals(err, "BufferFull");
await buf.read(p.subarray(0, 3)); 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); [actual, err] = await buf.peek(1);
assertEq(decoder.decode(actual), "d"); assertEquals(decoder.decode(actual), "d");
assert(err == null); assert(err == null);
[actual, err] = await buf.peek(1); [actual, err] = await buf.peek(1);
assertEq(decoder.decode(actual), "d"); assertEquals(decoder.decode(actual), "d");
assert(err == null); assert(err == null);
[actual, err] = await buf.peek(1); [actual, err] = await buf.peek(1);
assertEq(decoder.decode(actual), "d"); assertEquals(decoder.decode(actual), "d");
assert(err == null); assert(err == null);
[actual, err] = await buf.peek(2); [actual, err] = await buf.peek(2);
assertEq(decoder.decode(actual), "de"); assertEquals(decoder.decode(actual), "de");
assert(err == null); assert(err == null);
let { eof } = await buf.read(p.subarray(0, 3)); 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(!eof);
assert(err == null); assert(err == null);
[actual, err] = await buf.peek(4); [actual, err] = await buf.peek(4);
assertEq(decoder.decode(actual), "ghij"); assertEquals(decoder.decode(actual), "ghij");
assert(err == null); assert(err == null);
await buf.read(p); await buf.read(p);
assertEq(decoder.decode(p), "ghijklmnop"); assertEquals(decoder.decode(p), "ghijklmnop");
[actual, err] = await buf.peek(0); [actual, err] = await buf.peek(0);
assertEq(decoder.decode(actual), ""); assertEquals(decoder.decode(actual), "");
assert(err == null); assert(err == null);
[actual, err] = await buf.peek(1); [actual, err] = await buf.peek(1);
assertEq(decoder.decode(actual), ""); assertEquals(decoder.decode(actual), "");
assert(err == "EOF"); assert(err == "EOF");
/* TODO /* TODO
// Test for issue 3022, not exposing a reader's error on a successful Peek. // 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 context = `nwrite=${nwrite} bufsize=${bs}`;
const n = await buf.write(data.subarray(0, nwrite)); const n = await buf.write(data.subarray(0, nwrite));
assertEq(n, nwrite, context); assertEquals(n, nwrite, context);
await buf.flush(); await buf.flush();
const written = w.bytes(); const written = w.bytes();
assertEq(written.byteLength, nwrite); assertEquals(written.byteLength, nwrite);
for (let l = 0; l < written.byteLength; l++) { 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 buf = new Uint8Array(6);
const [nread, err] = await bufr.readFull(buf); const [nread, err] = await bufr.readFull(buf);
assertEq(nread, 6); assertEquals(nread, 6);
assert(!err); assert(!err);
assertEq(dec.decode(buf), "Hello "); assertEquals(dec.decode(buf), "Hello ");
} }
{ {
const buf = new Uint8Array(6); const buf = new Uint8Array(6);
const [nread, err] = await bufr.readFull(buf); const [nread, err] = await bufr.readFull(buf);
assertEq(nread, 5); assertEquals(nread, 5);
assertEq(err, "EOF"); assertEquals(err, "EOF");
assertEq(dec.decode(buf.subarray(0, 5)), "World"); assertEquals(dec.decode(buf.subarray(0, 5)), "World");
} }
}); });

View file

@ -2,7 +2,7 @@
const { Buffer } = Deno; const { Buffer } = Deno;
import { Reader, ReadResult } from "deno"; import { Reader, ReadResult } from "deno";
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { import {
copyN, copyN,
readInt, readInt,
@ -28,13 +28,13 @@ class BinaryReader implements Reader {
test(async function testReadShort() { test(async function testReadShort() {
const r = new BinaryReader(new Uint8Array([0x12, 0x34])); const r = new BinaryReader(new Uint8Array([0x12, 0x34]));
const short = await readShort(new BufReader(r)); const short = await readShort(new BufReader(r));
assertEq(short, 0x1234); assertEquals(short, 0x1234);
}); });
test(async function testReadInt() { test(async function testReadInt() {
const r = new BinaryReader(new Uint8Array([0x12, 0x34, 0x56, 0x78])); const r = new BinaryReader(new Uint8Array([0x12, 0x34, 0x56, 0x78]));
const int = await readInt(new BufReader(r)); const int = await readInt(new BufReader(r));
assertEq(int, 0x12345678); assertEquals(int, 0x12345678);
}); });
test(async function testReadLong() { test(async function testReadLong() {
@ -42,7 +42,7 @@ test(async function testReadLong() {
new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78]) new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78])
); );
const long = await readLong(new BufReader(r)); const long = await readLong(new BufReader(r));
assertEq(long, 0x1234567812345678); assertEquals(long, 0x1234567812345678);
}); });
test(async function testReadLong2() { test(async function testReadLong2() {
@ -50,7 +50,7 @@ test(async function testReadLong2() {
new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]) new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78])
); );
const long = await readLong(new BufReader(r)); const long = await readLong(new BufReader(r));
assertEq(long, 0x12345678); assertEquals(long, 0x12345678);
}); });
test(async function testSliceLongToBytes() { test(async function testSliceLongToBytes() {
@ -63,26 +63,26 @@ test(async function testSliceLongToBytes() {
) )
) )
); );
assertEq(actual, expected); assertEquals(actual, expected);
}); });
test(async function testSliceLongToBytes2() { test(async function testSliceLongToBytes2() {
const arr = sliceLongToBytes(0x12345678); 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() { test(async function testCopyN1() {
const w = new Buffer(); const w = new Buffer();
const r = stringsReader("abcdefghij"); const r = stringsReader("abcdefghij");
const n = await copyN(w, r, 3); const n = await copyN(w, r, 3);
assertEq(n, 3); assertEquals(n, 3);
assertEq(w.toString(), "abc"); assertEquals(w.toString(), "abc");
}); });
test(async function testCopyN2() { test(async function testCopyN2() {
const w = new Buffer(); const w = new Buffer();
const r = stringsReader("abcdefghij"); const r = stringsReader("abcdefghij");
const n = await copyN(w, r, 11); const n = await copyN(w, r, 11);
assertEq(n, 10); assertEquals(n, 10);
assertEq(w.toString(), "abcdefghij"); assertEquals(w.toString(), "abcdefghij");
}); });

View file

@ -1,6 +1,6 @@
const { copy } = Deno; const { copy } = Deno;
import { test } from "../testing/mod.ts"; 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 { MultiReader, StringReader } from "./readers.ts";
import { StringWriter } from "./writers.ts"; import { StringWriter } from "./writers.ts";
import { copyN } from "./ioutil.ts"; import { copyN } from "./ioutil.ts";
@ -9,29 +9,29 @@ import { decode } from "../strings/strings.ts";
test(async function ioStringReader() { test(async function ioStringReader() {
const r = new StringReader("abcdef"); const r = new StringReader("abcdef");
const { nread, eof } = await r.read(new Uint8Array(6)); const { nread, eof } = await r.read(new Uint8Array(6));
assertEq(nread, 6); assertEquals(nread, 6);
assertEq(eof, true); assertEquals(eof, true);
}); });
test(async function ioStringReader() { test(async function ioStringReader() {
const r = new StringReader("abcdef"); const r = new StringReader("abcdef");
const buf = new Uint8Array(3); const buf = new Uint8Array(3);
let res1 = await r.read(buf); let res1 = await r.read(buf);
assertEq(res1.nread, 3); assertEquals(res1.nread, 3);
assertEq(res1.eof, false); assertEquals(res1.eof, false);
assertEq(decode(buf), "abc"); assertEquals(decode(buf), "abc");
let res2 = await r.read(buf); let res2 = await r.read(buf);
assertEq(res2.nread, 3); assertEquals(res2.nread, 3);
assertEq(res2.eof, true); assertEquals(res2.eof, true);
assertEq(decode(buf), "def"); assertEquals(decode(buf), "def");
}); });
test(async function ioMultiReader() { test(async function ioMultiReader() {
const r = new MultiReader(new StringReader("abc"), new StringReader("def")); const r = new MultiReader(new StringReader("abc"), new StringReader("def"));
const w = new StringWriter(); const w = new StringWriter();
const n = await copyN(w, r, 4); const n = await copyN(w, r, 4);
assertEq(n, 4); assertEquals(n, 4);
assertEq(w.toString(), "abcd"); assertEquals(w.toString(), "abcd");
await copy(w, r); await copy(w, r);
assertEq(w.toString(), "abcdef"); assertEquals(w.toString(), "abcdef");
}); });

View file

@ -1,7 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { remove } = Deno; const { remove } = Deno;
import { test } from "../testing/mod.ts"; 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 { copyBytes, tempFile } from "./util.ts";
import * as path from "../fs/path.ts"; import * as path from "../fs/path.ts";
@ -12,31 +12,31 @@ test(function testCopyBytes() {
let src = Uint8Array.of(1, 2); let src = Uint8Array.of(1, 2);
let len = copyBytes(dst, src, 0); let len = copyBytes(dst, src, 0);
assert(len === 2); assert(len === 2);
assertEq(dst, Uint8Array.of(1, 2, 0, 0)); assertEquals(dst, Uint8Array.of(1, 2, 0, 0));
dst.fill(0); dst.fill(0);
src = Uint8Array.of(1, 2); src = Uint8Array.of(1, 2);
len = copyBytes(dst, src, 1); len = copyBytes(dst, src, 1);
assert(len === 2); assert(len === 2);
assertEq(dst, Uint8Array.of(0, 1, 2, 0)); assertEquals(dst, Uint8Array.of(0, 1, 2, 0));
dst.fill(0); dst.fill(0);
src = Uint8Array.of(1, 2, 3, 4, 5); src = Uint8Array.of(1, 2, 3, 4, 5);
len = copyBytes(dst, src); len = copyBytes(dst, src);
assert(len === 4); assert(len === 4);
assertEq(dst, Uint8Array.of(1, 2, 3, 4)); assertEquals(dst, Uint8Array.of(1, 2, 3, 4));
dst.fill(0); dst.fill(0);
src = Uint8Array.of(1, 2); src = Uint8Array.of(1, 2);
len = copyBytes(dst, src, 100); len = copyBytes(dst, src, 100);
assert(len === 0); assert(len === 0);
assertEq(dst, Uint8Array.of(0, 0, 0, 0)); assertEquals(dst, Uint8Array.of(0, 0, 0, 0));
dst.fill(0); dst.fill(0);
src = Uint8Array.of(3, 4); src = Uint8Array.of(3, 4);
len = copyBytes(dst, src, -2); len = copyBytes(dst, src, -2);
assert(len === 2); assert(len === 2);
assertEq(dst, Uint8Array.of(3, 4, 0, 0)); assertEquals(dst, Uint8Array.of(3, 4, 0, 0));
}); });
test(async function ioTempfile() { test(async function ioTempfile() {

View file

@ -1,6 +1,6 @@
const { copy } = Deno; const { copy } = Deno;
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { StringWriter } from "./writers.ts"; import { StringWriter } from "./writers.ts";
import { StringReader } from "./readers.ts"; import { StringReader } from "./readers.ts";
import { copyN } from "./ioutil.ts"; import { copyN } from "./ioutil.ts";
@ -9,7 +9,7 @@ test(async function ioStringWriter() {
const w = new StringWriter("base"); const w = new StringWriter("base");
const r = new StringReader("0123456789"); const r = new StringReader("0123456789");
await copyN(w, r, 4); await copyN(w, r, 4);
assertEq(w.toString(), "base0123"); assertEquals(w.toString(), "base0123");
await copy(w, r); await copy(w, r);
assertEq(w.toString(), "base0123456789"); assertEquals(w.toString(), "base0123456789");
}); });

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; 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 { LogLevel, getLevelName, getLevelByName } from "./levels.ts";
import { BaseHandler } from "./handlers.ts"; import { BaseHandler } from "./handlers.ts";
@ -56,9 +56,9 @@ test(function simpleHandler() {
}); });
} }
assertEq(handler.level, testCase); assertEquals(handler.level, testCase);
assertEq(handler.levelName, testLevel); assertEquals(handler.levelName, testLevel);
assertEq(handler.messages, messages); assertEquals(handler.messages, messages);
} }
}); });
@ -75,7 +75,7 @@ test(function testFormatterAsString() {
levelName: "DEBUG" levelName: "DEBUG"
}); });
assertEq(handler.messages, ["test DEBUG Hello, world!"]); assertEquals(handler.messages, ["test DEBUG Hello, world!"]);
}); });
test(function testFormatterAsFunction() { test(function testFormatterAsFunction() {
@ -92,5 +92,5 @@ test(function testFormatterAsFunction() {
levelName: "ERROR" levelName: "ERROR"
}); });
assertEq(handler.messages, ["fn formmatter ERROR Hello, world!"]); assertEquals(handler.messages, ["fn formmatter ERROR Hello, world!"]);
}); });

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; 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 { LogRecord, Logger } from "./logger.ts";
import { LogLevel } from "./levels.ts"; import { LogLevel } from "./levels.ts";
import { BaseHandler } from "./handlers.ts"; import { BaseHandler } from "./handlers.ts";
@ -23,13 +23,13 @@ test(function simpleLogger() {
const handler = new TestHandler("DEBUG"); const handler = new TestHandler("DEBUG");
let logger = new Logger("DEBUG"); let logger = new Logger("DEBUG");
assertEq(logger.level, LogLevel.DEBUG); assertEquals(logger.level, LogLevel.DEBUG);
assertEq(logger.levelName, "DEBUG"); assertEquals(logger.levelName, "DEBUG");
assertEq(logger.handlers, []); assertEquals(logger.handlers, []);
logger = new Logger("DEBUG", [handler]); logger = new Logger("DEBUG", [handler]);
assertEq(logger.handlers, [handler]); assertEquals(logger.handlers, [handler]);
}); });
test(function customHandler() { test(function customHandler() {
@ -38,7 +38,7 @@ test(function customHandler() {
logger.debug("foo", 1, 2); logger.debug("foo", 1, 2);
assertEq(handler.records, [ assertEquals(handler.records, [
{ {
msg: "foo", msg: "foo",
args: [1, 2], args: [1, 2],
@ -48,7 +48,7 @@ test(function customHandler() {
} }
]); ]);
assertEq(handler.messages, ["DEBUG foo"]); assertEquals(handler.messages, ["DEBUG foo"]);
}); });
test(function logFunctions() { test(function logFunctions() {
@ -66,7 +66,7 @@ test(function logFunctions() {
doLog("DEBUG"); doLog("DEBUG");
assertEq(handler.messages, [ assertEquals(handler.messages, [
"DEBUG foo", "DEBUG foo",
"INFO bar", "INFO bar",
"WARNING baz", "WARNING baz",
@ -76,7 +76,7 @@ test(function logFunctions() {
doLog("INFO"); doLog("INFO");
assertEq(handler.messages, [ assertEquals(handler.messages, [
"INFO bar", "INFO bar",
"WARNING baz", "WARNING baz",
"ERROR boo", "ERROR boo",
@ -85,13 +85,13 @@ test(function logFunctions() {
doLog("WARNING"); doLog("WARNING");
assertEq(handler.messages, ["WARNING baz", "ERROR boo", "CRITICAL doo"]); assertEquals(handler.messages, ["WARNING baz", "ERROR boo", "CRITICAL doo"]);
doLog("ERROR"); doLog("ERROR");
assertEq(handler.messages, ["ERROR boo", "CRITICAL doo"]); assertEquals(handler.messages, ["ERROR boo", "CRITICAL doo"]);
doLog("CRITICAL"); doLog("CRITICAL");
assertEq(handler.messages, ["CRITICAL doo"]); assertEquals(handler.messages, ["CRITICAL doo"]);
}); });

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; 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 * as log from "./mod.ts";
import { LogLevel } from "./levels.ts"; import { LogLevel } from "./levels.ts";
@ -55,7 +55,7 @@ test(async function defaultHandlers() {
logger("foo"); logger("foo");
logger("bar", 1, 2); 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(); const logger = log.getLogger();
assertEq(logger.levelName, "DEBUG"); assertEquals(logger.levelName, "DEBUG");
assertEq(logger.handlers, [handler]); assertEquals(logger.handlers, [handler]);
}); });
test(async function getLoggerWithName() { test(async function getLoggerWithName() {
@ -97,8 +97,8 @@ test(async function getLoggerWithName() {
const logger = log.getLogger("bar"); const logger = log.getLogger("bar");
assertEq(logger.levelName, "INFO"); assertEquals(logger.levelName, "INFO");
assertEq(logger.handlers, [fooHandler]); assertEquals(logger.handlers, [fooHandler]);
}); });
test(async function getLoggerUnknown() { test(async function getLoggerUnknown() {
@ -109,6 +109,6 @@ test(async function getLoggerUnknown() {
const logger = log.getLogger("nonexistent"); const logger = log.getLogger("nonexistent");
assertEq(logger.levelName, "NOTSET"); assertEquals(logger.levelName, "NOTSET");
assertEq(logger.handlers, []); assertEquals(logger.handlers, []);
}); });

View file

@ -1,7 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { import {
lookup, lookup,
contentType, contentType,
@ -12,40 +12,40 @@ import {
} from "./mod.ts"; } from "./mod.ts";
test(function testLookup() { test(function testLookup() {
assertEq(lookup("json"), "application/json"); assertEquals(lookup("json"), "application/json");
assertEq(lookup(".md"), "text/markdown"); assertEquals(lookup(".md"), "text/markdown");
assertEq(lookup("folder/file.js"), "application/javascript"); assertEquals(lookup("folder/file.js"), "application/javascript");
assertEq(lookup("folder/.htaccess"), undefined); assertEquals(lookup("folder/.htaccess"), undefined);
}); });
test(function testContentType() { test(function testContentType() {
assertEq(contentType("markdown"), "text/markdown; charset=utf-8"); assertEquals(contentType("markdown"), "text/markdown; charset=utf-8");
assertEq(contentType("file.json"), "application/json; charset=utf-8"); assertEquals(contentType("file.json"), "application/json; charset=utf-8");
assertEq(contentType("text/html"), "text/html; charset=utf-8"); assertEquals(contentType("text/html"), "text/html; charset=utf-8");
assertEq( assertEquals(
contentType("text/html; charset=iso-8859-1"), contentType("text/html; charset=iso-8859-1"),
"text/html; charset=iso-8859-1" "text/html; charset=iso-8859-1"
); );
assertEq(contentType(".htaccess"), undefined); assertEquals(contentType(".htaccess"), undefined);
}); });
test(function testExtension() { test(function testExtension() {
assertEq(extension("application/octet-stream"), "bin"); assertEquals(extension("application/octet-stream"), "bin");
assertEq(extension("application/javascript"), "js"); assertEquals(extension("application/javascript"), "js");
assertEq(extension("text/html"), "html"); assertEquals(extension("text/html"), "html");
}); });
test(function testCharset() { test(function testCharset() {
assertEq(charset("text/markdown"), "UTF-8"); assertEquals(charset("text/markdown"), "UTF-8");
assertEq(charset("text/css"), "UTF-8"); assertEquals(charset("text/css"), "UTF-8");
}); });
test(function testExtensions() { test(function testExtensions() {
assertEq(extensions.get("application/javascript"), ["js", "mjs"]); assertEquals(extensions.get("application/javascript"), ["js", "mjs"]);
assertEq(extensions.get("foo"), undefined); assertEquals(extensions.get("foo"), undefined);
}); });
test(function testTypes() { test(function testTypes() {
assertEq(types.get("js"), "application/javascript"); assertEquals(types.get("js"), "application/javascript");
assertEq(types.get("foo"), undefined); assertEquals(types.get("foo"), undefined);
}); });

View file

@ -1,17 +1,17 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { isFormFile } from "./formfile.ts"; import { isFormFile } from "./formfile.ts";
test(function multipartIsFormFile() { test(function multipartIsFormFile() {
assertEq( assertEquals(
isFormFile({ isFormFile({
filename: "foo", filename: "foo",
type: "application/json" type: "application/json"
}), }),
true true
); );
assertEq( assertEquals(
isFormFile({ isFormFile({
filename: "foo" filename: "foo"
}), }),

View file

@ -3,7 +3,7 @@
const { Buffer, copy, open, remove } = Deno; const { Buffer, copy, open, remove } = Deno;
import { import {
assert, assert,
assertEq, assertEquals,
assertThrows, assertThrows,
assertThrowsAsync assertThrowsAsync
} from "../testing/asserts.ts"; } from "../testing/asserts.ts";
@ -32,8 +32,8 @@ test(function multipartScanUntilBoundary1() {
0, 0,
"EOF" "EOF"
); );
assertEq(n, 0); assertEquals(n, 0);
assertEq(err, "EOF"); assertEquals(err, "EOF");
}); });
test(function multipartScanUntilBoundary2() { test(function multipartScanUntilBoundary2() {
@ -45,8 +45,8 @@ test(function multipartScanUntilBoundary2() {
0, 0,
"EOF" "EOF"
); );
assertEq(n, 3); assertEquals(n, 3);
assertEq(err, "EOF"); assertEquals(err, "EOF");
}); });
test(function multipartScanUntilBoundary4() { test(function multipartScanUntilBoundary4() {
@ -58,8 +58,8 @@ test(function multipartScanUntilBoundary4() {
0, 0,
null null
); );
assertEq(n, 3); assertEquals(n, 3);
assertEq(err, null); assertEquals(err, null);
}); });
test(function multipartScanUntilBoundary3() { test(function multipartScanUntilBoundary3() {
@ -71,26 +71,26 @@ test(function multipartScanUntilBoundary3() {
0, 0,
null null
); );
assertEq(n, data.length); assertEquals(n, data.length);
assertEq(err, null); assertEquals(err, null);
}); });
test(function multipartMatchAfterPrefix1() { test(function multipartMatchAfterPrefix1() {
const data = `${boundary}\r`; const data = `${boundary}\r`;
const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null); const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null);
assertEq(v, 1); assertEquals(v, 1);
}); });
test(function multipartMatchAfterPrefix2() { test(function multipartMatchAfterPrefix2() {
const data = `${boundary}hoge`; const data = `${boundary}hoge`;
const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null); const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null);
assertEq(v, -1); assertEquals(v, -1);
}); });
test(function multipartMatchAfterPrefix3() { test(function multipartMatchAfterPrefix3() {
const data = `${boundary}`; const data = `${boundary}`;
const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null); const v = matchAfterPrefix(e.encode(data), e.encode(boundary), null);
assertEq(v, 0); assertEquals(v, 0);
}); });
test(async function multipartMultipartWriter() { test(async function multipartMultipartWriter() {
@ -181,10 +181,10 @@ test(async function multipartMultipartReader() {
"--------------------------434049563556637648550474" "--------------------------434049563556637648550474"
); );
const form = await mr.readForm(10 << 20); const form = await mr.readForm(10 << 20);
assertEq(form["foo"], "foo"); assertEquals(form["foo"], "foo");
assertEq(form["bar"], "bar"); assertEquals(form["bar"], "bar");
const file = form["file"] as FormFile; const file = form["file"] as FormFile;
assertEq(isFormFile(file), true); assertEquals(isFormFile(file), true);
assert(file.content !== void 0); assert(file.content !== void 0);
}); });
@ -196,15 +196,15 @@ test(async function multipartMultipartReader2() {
); );
const form = await mr.readForm(20); // const form = await mr.readForm(20); //
try { try {
assertEq(form["foo"], "foo"); assertEquals(form["foo"], "foo");
assertEq(form["bar"], "bar"); assertEquals(form["bar"], "bar");
const file = form["file"] as FormFile; 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 f = await open(file.tempfile);
const w = new StringWriter(); const w = new StringWriter();
await copy(w, f); await copy(w, f);
const json = JSON.parse(w.toString()); const json = JSON.parse(w.toString());
assertEq(json["compilerOptions"]["target"], "es2018"); assertEquals(json["compilerOptions"]["target"], "es2018");
f.close(); f.close();
} finally { } finally {
const file = form["file"] as FormFile; const file = form["file"] as FormFile;

View file

@ -1,7 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { xrun, executableSuffix } from "./util.ts"; import { xrun, executableSuffix } from "./util.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
const { readAll } = Deno; const { readAll } = Deno;
const decoder = new TextDecoder(); const decoder = new TextDecoder();
@ -46,20 +46,20 @@ test(async function testPrettierCheckAndFormatFiles() {
const files = [`${testdata}/0.ts`, `${testdata}/1.js`]; const files = [`${testdata}/0.ts`, `${testdata}/1.js`];
var { code, stdout } = await run([...cmd, "--check", ...files]); var { code, stdout } = await run([...cmd, "--check", ...files]);
assertEq(code, 1); assertEquals(code, 1);
assertEq(normalizeOutput(stdout), "Some files are not formatted"); assertEquals(normalizeOutput(stdout), "Some files are not formatted");
var { code, stdout } = await run([...cmd, ...files]); var { code, stdout } = await run([...cmd, ...files]);
assertEq(code, 0); assertEquals(code, 0);
assertEq( assertEquals(
normalizeOutput(stdout), normalizeOutput(stdout),
`Formatting prettier/testdata/0.ts `Formatting prettier/testdata/0.ts
Formatting prettier/testdata/1.js` Formatting prettier/testdata/1.js`
); );
var { code, stdout } = await run([...cmd, "--check", ...files]); var { code, stdout } = await run([...cmd, "--check", ...files]);
assertEq(code, 0); assertEquals(code, 0);
assertEq(normalizeOutput(stdout), "Every file is formatted"); assertEquals(normalizeOutput(stdout), "Every file is formatted");
await clearTestdataChanges(); await clearTestdataChanges();
}); });
@ -70,12 +70,12 @@ test(async function testPrettierCheckAndFormatDirs() {
const dirs = [`${testdata}/foo`, `${testdata}/bar`]; const dirs = [`${testdata}/foo`, `${testdata}/bar`];
var { code, stdout } = await run([...cmd, "--check", ...dirs]); var { code, stdout } = await run([...cmd, "--check", ...dirs]);
assertEq(code, 1); assertEquals(code, 1);
assertEq(normalizeOutput(stdout), "Some files are not formatted"); assertEquals(normalizeOutput(stdout), "Some files are not formatted");
var { code, stdout } = await run([...cmd, ...dirs]); var { code, stdout } = await run([...cmd, ...dirs]);
assertEq(code, 0); assertEquals(code, 0);
assertEq( assertEquals(
normalizeOutput(stdout), normalizeOutput(stdout),
`Formatting prettier/testdata/bar/0.ts `Formatting prettier/testdata/bar/0.ts
Formatting prettier/testdata/bar/1.js Formatting prettier/testdata/bar/1.js
@ -84,8 +84,8 @@ Formatting prettier/testdata/foo/1.js`
); );
var { code, stdout } = await run([...cmd, "--check", ...dirs]); var { code, stdout } = await run([...cmd, "--check", ...dirs]);
assertEq(code, 0); assertEquals(code, 0);
assertEq(normalizeOutput(stdout), "Every file is formatted"); assertEquals(normalizeOutput(stdout), "Every file is formatted");
await clearTestdataChanges(); await clearTestdataChanges();
}); });

File diff suppressed because one or more lines are too long

View file

@ -16,7 +16,7 @@ Asserts are exposed in `testing/asserts.ts` module.
- `equal` - Deep comparision function, where `actual` and `expected` are - `equal` - Deep comparision function, where `actual` and `expected` are
compared deeply, and if they vary, `equal` returns `false`. compared deeply, and if they vary, `equal` returns `false`.
- `assert()` - Expects a boolean value, throws if the value is `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. `expected` are not equal.
- `assertStrictEq()` - Compares `actual` and `expected` strictly, therefore - `assertStrictEq()` - Compares `actual` and `expected` strictly, therefore
for non-primitives the values must reference the same instance. for non-primitives the values must reference the same instance.
@ -36,13 +36,13 @@ Basic usage:
```ts ```ts
import { runTests, test } from "https://deno.land/std/testing/mod.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({ test({
name: "testing example", name: "testing example",
fn() { fn() {
assertEq("world", "world")); assertEquals("world", "world"));
assertEq({ hello: "world" }, { hello: "world" })); assertEquals({ hello: "world" }, { hello: "world" }));
} }
}); });
@ -53,8 +53,8 @@ Short syntax (named function instead of object):
```ts ```ts
test(function example() { test(function example() {
assertEq("world", "world")); assertEquals("world", "world"));
assertEq({ hello: "world" }, { hello: "world" })); assertEquals({ hello: "world" }, { hello: "world" }));
}); });
``` ```

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // 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 { interface Constructor {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // 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 * Make an assertion that `actual` and `expected` are equal, deeply. If not
* deeply equal, then throw. * deeply equal, then throw.
*/ */
export function assertEq( export function assertEquals(
actual: unknown, actual: unknown,
expected: unknown, expected: unknown,
msg?: string msg?: string

View file

@ -2,7 +2,7 @@
import { assert, equal, assertStrContains, assertMatch } from "./asserts.ts"; import { assert, equal, assertStrContains, assertMatch } from "./asserts.ts";
import { test } from "./mod.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 "./format_test.ts";
// import "./diff_test.ts"; // import "./diff_test.ts";
// import "./pretty_test.ts"; // import "./pretty_test.ts";

View file

@ -1,18 +1,18 @@
import diff from "./diff.ts"; import diff from "./diff.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { test } from "./mod.ts"; import { test } from "./mod.ts";
test({ test({
name: "empty", name: "empty",
fn() { fn() {
assertEq(diff([], []), []); assertEquals(diff([], []), []);
} }
}); });
test({ test({
name: '"a" vs "b"', name: '"a" vs "b"',
fn() { fn() {
assertEq(diff(["a"], ["b"]), [ assertEquals(diff(["a"], ["b"]), [
{ type: "removed", value: "a" }, { type: "removed", value: "a" },
{ type: "added", value: "b" } { type: "added", value: "b" }
]); ]);
@ -22,28 +22,28 @@ test({
test({ test({
name: '"a" vs "a"', name: '"a" vs "a"',
fn() { fn() {
assertEq(diff(["a"], ["a"]), [{ type: "common", value: "a" }]); assertEquals(diff(["a"], ["a"]), [{ type: "common", value: "a" }]);
} }
}); });
test({ test({
name: '"a" vs ""', name: '"a" vs ""',
fn() { fn() {
assertEq(diff(["a"], []), [{ type: "removed", value: "a" }]); assertEquals(diff(["a"], []), [{ type: "removed", value: "a" }]);
} }
}); });
test({ test({
name: '"" vs "a"', name: '"" vs "a"',
fn() { fn() {
assertEq(diff([], ["a"]), [{ type: "added", value: "a" }]); assertEquals(diff([], ["a"]), [{ type: "added", value: "a" }]);
} }
}); });
test({ test({
name: '"a" vs "a, b"', name: '"a" vs "a, b"',
fn() { fn() {
assertEq(diff(["a"], ["a", "b"]), [ assertEquals(diff(["a"], ["a", "b"]), [
{ type: "common", value: "a" }, { type: "common", value: "a" },
{ type: "added", value: "b" } { type: "added", value: "b" }
]); ]);
@ -53,7 +53,7 @@ test({
test({ test({
name: '"strength" vs "string"', name: '"strength" vs "string"',
fn() { fn() {
assertEq(diff(Array.from("strength"), Array.from("string")), [ assertEquals(diff(Array.from("strength"), Array.from("string")), [
{ type: "common", value: "s" }, { type: "common", value: "s" },
{ type: "common", value: "t" }, { type: "common", value: "t" },
{ type: "common", value: "r" }, { type: "common", value: "r" },
@ -70,7 +70,7 @@ test({
test({ test({
name: '"strength" vs ""', name: '"strength" vs ""',
fn() { fn() {
assertEq(diff(Array.from("strength"), Array.from("")), [ assertEquals(diff(Array.from("strength"), Array.from("")), [
{ type: "removed", value: "s" }, { type: "removed", value: "s" },
{ type: "removed", value: "t" }, { type: "removed", value: "t" },
{ type: "removed", value: "r" }, { type: "removed", value: "r" },
@ -86,7 +86,7 @@ test({
test({ test({
name: '"" vs "strength"', name: '"" vs "strength"',
fn() { fn() {
assertEq(diff(Array.from(""), Array.from("strength")), [ assertEquals(diff(Array.from(""), Array.from("strength")), [
{ type: "added", value: "s" }, { type: "added", value: "s" },
{ type: "added", value: "t" }, { type: "added", value: "t" },
{ type: "added", value: "r" }, { type: "added", value: "r" },
@ -102,7 +102,7 @@ test({
test({ test({
name: '"abc", "c" vs "abc", "bcd", "c"', name: '"abc", "c" vs "abc", "bcd", "c"',
fn() { fn() {
assertEq(diff(["abc", "c"], ["abc", "bcd", "c"]), [ assertEquals(diff(["abc", "c"], ["abc", "bcd", "c"]), [
{ type: "common", value: "abc" }, { type: "common", value: "abc" },
{ type: "added", value: "bcd" }, { type: "added", value: "bcd" },
{ type: "common", value: "c" } { type: "common", value: "c" }

View file

@ -7,7 +7,7 @@
* *
*/ */
import { test } from "./mod.ts"; import { test } from "./mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { format } from "./format.ts"; import { format } from "./format.ts";
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-explicit-any
@ -55,7 +55,7 @@ test({
name: "prints empty arguments", name: "prints empty arguments",
fn() { fn() {
const val = returnArguments(); const val = returnArguments();
assertEq(format(val), "Arguments []"); assertEquals(format(val), "Arguments []");
} }
}); });
@ -63,7 +63,7 @@ test({
name: "prints an empty array", name: "prints an empty array",
fn() { fn() {
const val: unknown[] = []; const val: unknown[] = [];
assertEq(format(val), "Array []"); assertEquals(format(val), "Array []");
} }
}); });
@ -71,7 +71,7 @@ test({
name: "prints an array with items", name: "prints an array with items",
fn() { fn() {
const val = [1, 2, 3]; 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", name: "prints a empty typed array",
fn() { fn() {
const val = new Uint32Array(0); 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", name: "prints a typed array with items",
fn() { fn() {
const val = new Uint32Array(3); 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", name: "prints an array buffer",
fn() { fn() {
const val = new ArrayBuffer(3); const val = new ArrayBuffer(3);
assertEq(format(val), "ArrayBuffer []"); assertEquals(format(val), "ArrayBuffer []");
} }
}); });
@ -103,7 +103,7 @@ test({
name: "prints a nested array", name: "prints a nested array",
fn() { fn() {
const val = [[1, 2, 3]]; const val = [[1, 2, 3]];
assertEq( assertEquals(
format(val), format(val),
"Array [\n Array [\n 1,\n 2,\n 3,\n ],\n]" "Array [\n Array [\n 1,\n 2,\n 3,\n ],\n]"
); );
@ -114,7 +114,7 @@ test({
name: "prints true", name: "prints true",
fn() { fn() {
const val = true; const val = true;
assertEq(format(val), "true"); assertEquals(format(val), "true");
} }
}); });
@ -122,7 +122,7 @@ test({
name: "prints false", name: "prints false",
fn() { fn() {
const val = false; const val = false;
assertEq(format(val), "false"); assertEquals(format(val), "false");
} }
}); });
@ -130,7 +130,7 @@ test({
name: "prints an error", name: "prints an error",
fn() { fn() {
const val = new Error(); 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", name: "prints a typed error with a message",
fn() { fn() {
const val = new TypeError("message"); const val = new TypeError("message");
assertEq(format(val), "[TypeError: message]"); assertEquals(format(val), "[TypeError: message]");
} }
}); });
@ -147,7 +147,7 @@ test({
fn() { fn() {
// tslint:disable-next-line:function-constructor // tslint:disable-next-line:function-constructor
const val = new Function(); 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 // tslint:disable-next-line:no-empty
f(() => {}); f(() => {});
assertEq(format(val), "[Function anonymous]"); assertEquals(format(val), "[Function anonymous]");
} }
}); });
@ -170,7 +170,7 @@ test({
// tslint:disable-next-line:no-empty // tslint:disable-next-line:no-empty
const val = (): void => {}; const val = (): void => {};
const formatted = format(val); const formatted = format(val);
assertEq( assertEquals(
formatted === "[Function anonymous]" || formatted === "[Function val]", formatted === "[Function anonymous]" || formatted === "[Function val]",
true true
); );
@ -182,7 +182,7 @@ test({
fn() { fn() {
// tslint:disable-next-line:no-empty // tslint:disable-next-line:no-empty
const val = function named(): void {}; const val = function named(): void {};
assertEq(format(val), "[Function named]"); assertEquals(format(val), "[Function named]");
} }
}); });
@ -194,7 +194,7 @@ test({
yield 2; yield 2;
yield 3; yield 3;
}; };
assertEq(format(val), "[Function generate]"); assertEquals(format(val), "[Function generate]");
} }
}); });
@ -203,7 +203,7 @@ test({
fn() { fn() {
// tslint:disable-next-line:no-empty // tslint:disable-next-line:no-empty
const val = function named(): void {}; const val = function named(): void {};
assertEq( assertEquals(
format(val, { format(val, {
printFunctionName: false printFunctionName: false
}), }),
@ -216,7 +216,7 @@ test({
name: "prints Infinity", name: "prints Infinity",
fn() { fn() {
const val = Infinity; const val = Infinity;
assertEq(format(val), "Infinity"); assertEquals(format(val), "Infinity");
} }
}); });
@ -224,7 +224,7 @@ test({
name: "prints -Infinity", name: "prints -Infinity",
fn() { fn() {
const val = -Infinity; const val = -Infinity;
assertEq(format(val), "-Infinity"); assertEquals(format(val), "-Infinity");
} }
}); });
@ -232,7 +232,7 @@ test({
name: "prints an empty map", name: "prints an empty map",
fn() { fn() {
const val = new Map(); const val = new Map();
assertEq(format(val), "Map {}"); assertEquals(format(val), "Map {}");
} }
}); });
@ -242,7 +242,7 @@ test({
const val = new Map(); const val = new Map();
val.set("prop1", "value1"); val.set("prop1", "value1");
val.set("prop2", "value2"); val.set("prop2", "value2");
assertEq( assertEquals(
format(val), format(val),
'Map {\n "prop1" => "value1",\n "prop2" => "value2",\n}' 'Map {\n "prop1" => "value1",\n "prop2" => "value2",\n}'
); );
@ -288,7 +288,7 @@ test({
' } => "object",', ' } => "object",',
"}" "}"
].join("\n"); ].join("\n");
assertEq(format(val), expected); assertEquals(format(val), expected);
} }
}); });
@ -296,7 +296,7 @@ test({
name: "prints NaN", name: "prints NaN",
fn() { fn() {
const val = NaN; const val = NaN;
assertEq(format(val), "NaN"); assertEquals(format(val), "NaN");
} }
}); });
@ -304,7 +304,7 @@ test({
name: "prints null", name: "prints null",
fn() { fn() {
const val = null; const val = null;
assertEq(format(val), "null"); assertEquals(format(val), "null");
} }
}); });
@ -312,7 +312,7 @@ test({
name: "prints a positive number", name: "prints a positive number",
fn() { fn() {
const val = 123; const val = 123;
assertEq(format(val), "123"); assertEquals(format(val), "123");
} }
}); });
@ -320,7 +320,7 @@ test({
name: "prints a negative number", name: "prints a negative number",
fn() { fn() {
const val = -123; const val = -123;
assertEq(format(val), "-123"); assertEquals(format(val), "-123");
} }
}); });
@ -328,7 +328,7 @@ test({
name: "prints zero", name: "prints zero",
fn() { fn() {
const val = 0; const val = 0;
assertEq(format(val), "0"); assertEquals(format(val), "0");
} }
}); });
@ -336,7 +336,7 @@ test({
name: "prints negative zero", name: "prints negative zero",
fn() { fn() {
const val = -0; const val = -0;
assertEq(format(val), "-0"); assertEquals(format(val), "-0");
} }
}); });
@ -344,7 +344,7 @@ test({
name: "prints a date", name: "prints a date",
fn() { fn() {
const val = new Date(10e11); 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", name: "prints an invalid date",
fn() { fn() {
const val = new Date(Infinity); 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", name: "prints an empty object",
fn() { fn() {
const val = {}; const val = {};
assertEq(format(val), "Object {}"); assertEquals(format(val), "Object {}");
} }
}); });
@ -368,7 +368,7 @@ test({
name: "prints an object with properties", name: "prints an object with properties",
fn() { fn() {
const val = { prop1: "value1", prop2: "value2" }; const val = { prop1: "value1", prop2: "value2" };
assertEq( assertEquals(
format(val), format(val),
'Object {\n "prop1": "value1",\n "prop2": "value2",\n}' 'Object {\n "prop1": "value1",\n "prop2": "value2",\n}'
); );
@ -383,7 +383,7 @@ test({
val[Symbol("symbol1")] = "value2"; val[Symbol("symbol1")] = "value2";
val[Symbol("symbol2")] = "value3"; val[Symbol("symbol2")] = "value3";
val.prop = "value1"; val.prop = "value1";
assertEq( assertEquals(
format(val), format(val),
'Object {\n "prop": "value1",\n Symbol(symbol1): "value2",\n Symbol(symbol2): "value3",\n}' 'Object {\n "prop": "value1",\n Symbol(symbol1): "value2",\n Symbol(symbol2): "value3",\n}'
); );
@ -402,7 +402,7 @@ test({
enumerable: false, enumerable: false,
value: 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, enumerable: false,
value: 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", name: "prints an object with sorted properties",
fn() { fn() {
const val = { b: 1, a: 2 }; 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", name: "prints regular expressions from constructors",
fn() { fn() {
const val = new RegExp("regexp"); const val = new RegExp("regexp");
assertEq(format(val), "/regexp/"); assertEquals(format(val), "/regexp/");
} }
}); });
@ -442,7 +442,7 @@ test({
name: "prints regular expressions from literals", name: "prints regular expressions from literals",
fn() { fn() {
const val = /regexp/gi; 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}", name: "prints regular expressions {escapeRegex: false}",
fn() { fn() {
const val = /regexp\d/gi; 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}", name: "prints regular expressions {escapeRegex: true}",
fn() { fn() {
const val = /regexp\d/gi; 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", name: "escapes regular expressions nested inside object",
fn() { fn() {
const obj = { test: /regexp\d/gi }; const obj = { test: /regexp\d/gi };
assertEq( assertEquals(
format(obj, { escapeRegex: true }), format(obj, { escapeRegex: true }),
'Object {\n "test": /regexp\\\\d/gi,\n}' 'Object {\n "test": /regexp\\\\d/gi,\n}'
); );
@ -477,7 +477,7 @@ test({
name: "prints an empty set", name: "prints an empty set",
fn() { fn() {
const val = new Set(); const val = new Set();
assertEq(format(val), "Set {}"); assertEquals(format(val), "Set {}");
} }
}); });
@ -487,7 +487,7 @@ test({
const val = new Set(); const val = new Set();
val.add("value1"); val.add("value1");
val.add("value2"); 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", name: "prints a string",
fn() { fn() {
const val = "string"; const val = "string";
assertEq(format(val), '"string"'); assertEquals(format(val), '"string"');
} }
}); });
@ -503,7 +503,7 @@ test({
name: "prints and escape a string", name: "prints and escape a string",
fn() { fn() {
const val = "\"'\\"; const val = "\"'\\";
assertEq(format(val), '"\\"\'\\\\"'); assertEquals(format(val), '"\\"\'\\\\"');
} }
}); });
@ -511,15 +511,15 @@ test({
name: "doesn't escape string with {excapeString: false}", name: "doesn't escape string with {excapeString: false}",
fn() { fn() {
const val = "\"'\\n"; const val = "\"'\\n";
assertEq(format(val, { escapeString: false }), '""\'\\n"'); assertEquals(format(val, { escapeString: false }), '""\'\\n"');
} }
}); });
test({ test({
name: "prints a string with escapes", name: "prints a string with escapes",
fn() { fn() {
assertEq(format('"-"'), '"\\"-\\""'); assertEquals(format('"-"'), '"\\"-\\""');
assertEq(format("\\ \\\\"), '"\\\\ \\\\\\\\"'); assertEquals(format("\\ \\\\"), '"\\\\ \\\\\\\\"');
} }
}); });
@ -527,7 +527,7 @@ test({
name: "prints a multiline string", name: "prints a multiline string",
fn() { fn() {
const val = ["line 1", "line 2", "line 3"].join("\n"); 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" type: "svg"
}; };
assertEq( assertEquals(
format(val), format(val),
[ [
"Object {", "Object {",
@ -573,7 +573,7 @@ test({
name: "prints a symbol", name: "prints a symbol",
fn() { fn() {
const val = Symbol("symbol"); const val = Symbol("symbol");
assertEq(format(val), "Symbol(symbol)"); assertEquals(format(val), "Symbol(symbol)");
} }
}); });
@ -581,7 +581,7 @@ test({
name: "prints undefined", name: "prints undefined",
fn() { fn() {
const val = undefined; const val = undefined;
assertEq(format(val), "undefined"); assertEquals(format(val), "undefined");
} }
}); });
@ -589,7 +589,7 @@ test({
name: "prints a WeakMap", name: "prints a WeakMap",
fn() { fn() {
const val = new WeakMap(); const val = new WeakMap();
assertEq(format(val), "WeakMap {}"); assertEquals(format(val), "WeakMap {}");
} }
}); });
@ -597,7 +597,7 @@ test({
name: "prints a WeakSet", name: "prints a WeakSet",
fn() { fn() {
const val = new WeakSet(); const val = new WeakSet();
assertEq(format(val), "WeakSet {}"); assertEquals(format(val), "WeakSet {}");
} }
}); });
@ -605,7 +605,7 @@ test({
name: "prints deeply nested objects", name: "prints deeply nested objects",
fn() { fn() {
const val = { prop: { prop: { prop: "value" } } }; const val = { prop: { prop: { prop: "value" } } };
assertEq( assertEquals(
format(val), format(val),
'Object {\n "prop": Object {\n "prop": Object {\n "prop": "value",\n },\n },\n}' '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 // eslint-disable-next-line @typescript-eslint/no-explicit-any
const val: any = {}; const val: any = {};
val.prop = val; 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() { fn() {
const inner = {}; const inner = {};
const val = { prop1: inner, prop2: inner }; const val = { prop1: inner, prop2: inner };
assertEq( assertEquals(
format(val), format(val),
'Object {\n "prop1": Object {},\n "prop2": Object {},\n}' 'Object {\n "prop1": Object {},\n "prop2": Object {},\n}'
); );
@ -637,14 +637,14 @@ test({
test({ test({
name: "default implicit: 2 spaces", name: "default implicit: 2 spaces",
fn() { fn() {
assertEq(format(createVal()), createExpected()); assertEquals(format(createVal()), createExpected());
} }
}); });
test({ test({
name: "default explicit: 2 spaces", name: "default explicit: 2 spaces",
fn() { fn() {
assertEq(format(createVal(), { indent: 2 }), createExpected()); assertEquals(format(createVal(), { indent: 2 }), createExpected());
} }
}); });
@ -653,7 +653,7 @@ test({
name: "non-default: 0 spaces", name: "non-default: 0 spaces",
fn() { fn() {
const indent = 0; const indent = 0;
assertEq( assertEquals(
format(createVal(), { indent }), format(createVal(), { indent }),
createExpected().replace(/ {2}/g, " ".repeat(indent)) createExpected().replace(/ {2}/g, " ".repeat(indent))
); );
@ -664,7 +664,7 @@ test({
name: "non-default: 4 spaces", name: "non-default: 4 spaces",
fn() { fn() {
const indent = 4; const indent = 4;
assertEq( assertEquals(
format(createVal(), { indent }), format(createVal(), { indent }),
createExpected().replace(/ {2}/g, " ".repeat(indent)) createExpected().replace(/ {2}/g, " ".repeat(indent))
); );
@ -692,7 +692,7 @@ test({
"set non-empty": new Set(["value"]) "set non-empty": new Set(["value"])
} }
]; ];
assertEq( assertEquals(
format(v, { maxDepth: 2 }), format(v, { maxDepth: 2 }),
[ [
"Array [", "Array [",
@ -720,7 +720,7 @@ test({
test({ test({
name: "prints objects with no constructor", name: "prints objects with no constructor",
fn() { fn() {
assertEq(format(Object.create(null)), "Object {}"); assertEquals(format(Object.create(null)), "Object {}");
} }
}); });
@ -734,14 +734,14 @@ test({
' "constructor": "constructor",', ' "constructor": "constructor",',
"}" "}"
].join("\n"); ].join("\n");
assertEq(format(obj), expected); assertEquals(format(obj), expected);
} }
}); });
test({ test({
name: "calls toJSON and prints its return value", name: "calls toJSON and prints its return value",
fn() { fn() {
assertEq( assertEquals(
format({ format({
toJSON: () => ({ value: false }), toJSON: () => ({ value: false }),
value: true value: true
@ -754,7 +754,7 @@ test({
test({ test({
name: "calls toJSON and prints an internal representation.", name: "calls toJSON and prints an internal representation.",
fn() { fn() {
assertEq( assertEquals(
format({ format({
toJSON: () => "[Internal Object]", toJSON: () => "[Internal Object]",
value: true value: true
@ -767,7 +767,7 @@ test({
test({ test({
name: "calls toJSON only on functions", name: "calls toJSON only on functions",
fn() { fn() {
assertEq( assertEquals(
format({ format({
toJSON: false, toJSON: false,
value: true value: true
@ -780,7 +780,7 @@ test({
test({ test({
name: "does not call toJSON recursively", name: "does not call toJSON recursively",
fn() { fn() {
assertEq( assertEquals(
format({ format({
toJSON: () => ({ toJSON: () => ({ value: true }) }), toJSON: () => ({ toJSON: () => ({ value: true }) }),
value: false value: false
@ -796,6 +796,6 @@ test({
const set = new Set([1]); const set = new Set([1]);
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
(set as any).toJSON = () => "map"; (set as any).toJSON = () => "map";
assertEq(format(set), '"map"'); assertEquals(format(set), '"map"');
} }
}); });

View file

@ -55,7 +55,7 @@ function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>): string[] {
return messages; return messages;
} }
export function assertEq( export function assertEquals(
actual: unknown, actual: unknown,
expected: unknown, expected: unknown,
msg?: string msg?: string

View file

@ -2,7 +2,7 @@
import { test } from "./mod.ts"; import { test } from "./mod.ts";
import { red, green, white, gray, bold } from "../colors/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"; import { assertThrows } from "./asserts.ts";
const createHeader = (): string[] => [ const createHeader = (): string[] => [
@ -19,11 +19,11 @@ const removed: (s: string) => string = (s: string): string => red(bold(s));
test({ test({
name: "pass case", name: "pass case",
fn() { fn() {
assertEq({ a: 10 }, { a: 10 }); assertEquals({ a: 10 }, { a: 10 });
assertEq(true, true); assertEquals(true, true);
assertEq(10, 10); assertEquals(10, 10);
assertEq("abc", "abc"); assertEquals("abc", "abc");
assertEq({ a: 10, b: { c: "1" } }, { a: 10, b: { c: "1" } }); assertEquals({ a: 10, b: { c: "1" } }, { a: 10, b: { c: "1" } });
} }
}); });
@ -31,7 +31,7 @@ test({
name: "failed with number", name: "failed with number",
fn() { fn() {
assertThrows( assertThrows(
() => assertEq(1, 2), () => assertEquals(1, 2),
Error, Error,
[...createHeader(), removed(`- 1`), added(`+ 2`), ""].join("\n") [...createHeader(), removed(`- 1`), added(`+ 2`), ""].join("\n")
); );
@ -42,7 +42,7 @@ test({
name: "failed with number vs string", name: "failed with number vs string",
fn() { fn() {
assertThrows( assertThrows(
() => assertEq(1, "1"), () => assertEquals(1, "1"),
Error, Error,
[...createHeader(), removed(`- 1`), added(`+ "1"`)].join("\n") [...createHeader(), removed(`- 1`), added(`+ "1"`)].join("\n")
); );
@ -53,7 +53,7 @@ test({
name: "failed with array", name: "failed with array",
fn() { fn() {
assertThrows( assertThrows(
() => assertEq([1, "2", 3], ["1", "2", 3]), () => assertEquals([1, "2", 3], ["1", "2", 3]),
Error, Error,
[ [
...createHeader(), ...createHeader(),
@ -73,7 +73,7 @@ test({
name: "failed with object", name: "failed with object",
fn() { fn() {
assertThrows( 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, Error,
[ [
...createHeader(), ...createHeader(),

View file

@ -2,7 +2,7 @@
import { test, runIfMain } from "./mod.ts"; import { test, runIfMain } from "./mod.ts";
import { import {
assert, assert,
assertEq, assertEquals,
assertStrictEq, assertStrictEq,
assertThrows, assertThrows,
assertThrowsAsync, assertThrowsAsync,
@ -28,7 +28,7 @@ test(function testingAssertEqualActualUncoercable() {
let didThrow = false; let didThrow = false;
const a = Object.create(null); const a = Object.create(null);
try { try {
assertEq(a, "bar"); assertEquals(a, "bar");
} catch (e) { } catch (e) {
didThrow = true; didThrow = true;
} }

View file

@ -6,7 +6,7 @@
import { BufReader } from "../io/bufio.ts"; import { BufReader } from "../io/bufio.ts";
import { TextProtoReader, append } from "./mod.ts"; import { TextProtoReader, append } from "./mod.ts";
import { stringsReader } from "../io/util.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"; import { test } from "../testing/mod.ts";
function reader(s: string): TextProtoReader { function reader(s: string): TextProtoReader {
@ -16,15 +16,15 @@ function reader(s: string): TextProtoReader {
test(async function textprotoReader() { test(async function textprotoReader() {
let r = reader("line1\nline2\n"); let r = reader("line1\nline2\n");
let [s, err] = await r.readLine(); let [s, err] = await r.readLine();
assertEq(s, "line1"); assertEquals(s, "line1");
assert(err == null); assert(err == null);
[s, err] = await r.readLine(); [s, err] = await r.readLine();
assertEq(s, "line2"); assertEquals(s, "line2");
assert(err == null); assert(err == null);
[s, err] = await r.readLine(); [s, err] = await r.readLine();
assertEq(s, ""); assertEquals(s, "");
assert(err == "EOF"); assert(err == "EOF");
}); });
@ -47,7 +47,7 @@ test(async function textprotoReadMIMEHeader() {
test(async function textprotoReadMIMEHeaderSingle() { test(async function textprotoReadMIMEHeaderSingle() {
let r = reader("Foo: bar\n\n"); let r = reader("Foo: bar\n\n");
let [m, err] = await r.readMIMEHeader(); let [m, err] = await r.readMIMEHeader();
assertEq(m.get("Foo"), "bar"); assertEquals(m.get("Foo"), "bar");
assert(!err); assert(!err);
}); });
@ -88,12 +88,12 @@ test(async function textprotoAppend() {
const u1 = enc.encode("Hello "); const u1 = enc.encode("Hello ");
const u2 = enc.encode("World"); const u2 = enc.encode("World");
const joined = append(u1, u2); const joined = append(u1, u2);
assertEq(dec.decode(joined), "Hello World"); assertEquals(dec.decode(joined), "Hello World");
}); });
test(async function textprotoReadEmpty() { test(async function textprotoReadEmpty() {
let r = reader(""); let r = reader("");
let [, err] = await r.readMIMEHeader(); let [, err] = await r.readMIMEHeader();
// Should not crash! // Should not crash!
assertEq(err, "EOF"); assertEquals(err, "EOF");
}); });

View file

@ -1,24 +1,24 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { Sha1 } from "./sha1.ts"; import { Sha1 } from "./sha1.ts";
test(function testSha1() { test(function testSha1() {
const sha1 = new Sha1(); const sha1 = new Sha1();
sha1.update("abcde"); sha1.update("abcde");
assertEq(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334"); assertEquals(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
}); });
test(function testSha1WithArray() { test(function testSha1WithArray() {
const data = Uint8Array.of(0x61, 0x62, 0x63, 0x64, 0x65); const data = Uint8Array.of(0x61, 0x62, 0x63, 0x64, 0x65);
const sha1 = new Sha1(); const sha1 = new Sha1();
sha1.update(data); sha1.update(data);
assertEq(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334"); assertEquals(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
}); });
test(function testSha1WithBuffer() { test(function testSha1WithBuffer() {
const data = Uint8Array.of(0x61, 0x62, 0x63, 0x64, 0x65); const data = Uint8Array.of(0x61, 0x62, 0x63, 0x64, 0x65);
const sha1 = new Sha1(); const sha1 = new Sha1();
sha1.update(data.buffer); sha1.update(data.buffer);
assertEq(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334"); assertEquals(sha1.toString(), "03de6c570bfe24bfc328ccd7ca46b76eadaf4334");
}); });

View file

@ -3,7 +3,7 @@ import "./sha1_test.ts";
const { Buffer } = Deno; const { Buffer } = Deno;
import { BufReader } from "../io/bufio.ts"; 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 { test } from "../testing/mod.ts";
import { import {
acceptable, acceptable,
@ -19,10 +19,10 @@ test(async function testReadUnmaskedTextFrame() {
new Buffer(new Uint8Array([0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f])) new Buffer(new Uint8Array([0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f]))
); );
const frame = await readFrame(buf); const frame = await readFrame(buf);
assertEq(frame.opcode, OpCode.TextFrame); assertEquals(frame.opcode, OpCode.TextFrame);
assertEq(frame.mask, undefined); assertEquals(frame.mask, undefined);
assertEq(new Buffer(frame.payload).toString(), "Hello"); assertEquals(new Buffer(frame.payload).toString(), "Hello");
assertEq(frame.isLastFrame, true); assertEquals(frame.isLastFrame, true);
}); });
test(async function testReadMakedTextFrame() { test(async function testReadMakedTextFrame() {
@ -46,10 +46,10 @@ test(async function testReadMakedTextFrame() {
); );
const frame = await readFrame(buf); const frame = await readFrame(buf);
console.dir(frame); console.dir(frame);
assertEq(frame.opcode, OpCode.TextFrame); assertEquals(frame.opcode, OpCode.TextFrame);
unmask(frame.payload, frame.mask); unmask(frame.payload, frame.mask);
assertEq(new Buffer(frame.payload).toString(), "Hello"); assertEquals(new Buffer(frame.payload).toString(), "Hello");
assertEq(frame.isLastFrame, true); assertEquals(frame.isLastFrame, true);
}); });
test(async function testReadUnmaskedSplittedTextFrames() { test(async function testReadUnmaskedSplittedTextFrames() {
@ -60,15 +60,15 @@ test(async function testReadUnmaskedSplittedTextFrames() {
new Buffer(new Uint8Array([0x80, 0x02, 0x6c, 0x6f])) new Buffer(new Uint8Array([0x80, 0x02, 0x6c, 0x6f]))
); );
const [f1, f2] = await Promise.all([readFrame(buf1), readFrame(buf2)]); const [f1, f2] = await Promise.all([readFrame(buf1), readFrame(buf2)]);
assertEq(f1.isLastFrame, false); assertEquals(f1.isLastFrame, false);
assertEq(f1.mask, undefined); assertEquals(f1.mask, undefined);
assertEq(f1.opcode, OpCode.TextFrame); assertEquals(f1.opcode, OpCode.TextFrame);
assertEq(new Buffer(f1.payload).toString(), "Hel"); assertEquals(new Buffer(f1.payload).toString(), "Hel");
assertEq(f2.isLastFrame, true); assertEquals(f2.isLastFrame, true);
assertEq(f2.mask, undefined); assertEquals(f2.mask, undefined);
assertEq(f2.opcode, OpCode.Continue); assertEquals(f2.opcode, OpCode.Continue);
assertEq(new Buffer(f2.payload).toString(), "lo"); assertEquals(new Buffer(f2.payload).toString(), "lo");
}); });
test(async function testReadUnmaksedPingPongFrame() { test(async function testReadUnmaksedPingPongFrame() {
@ -77,8 +77,8 @@ test(async function testReadUnmaksedPingPongFrame() {
new Buffer(new Uint8Array([0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f])) new Buffer(new Uint8Array([0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f]))
); );
const ping = await readFrame(buf); const ping = await readFrame(buf);
assertEq(ping.opcode, OpCode.Ping); assertEquals(ping.opcode, OpCode.Ping);
assertEq(new Buffer(ping.payload).toString(), "Hello"); assertEquals(new Buffer(ping.payload).toString(), "Hello");
const buf2 = new BufReader( const buf2 = new BufReader(
new Buffer( new Buffer(
@ -98,10 +98,10 @@ test(async function testReadUnmaksedPingPongFrame() {
) )
); );
const pong = await readFrame(buf2); const pong = await readFrame(buf2);
assertEq(pong.opcode, OpCode.Pong); assertEquals(pong.opcode, OpCode.Pong);
assert(pong.mask !== undefined); assert(pong.mask !== undefined);
unmask(pong.payload, pong.mask); unmask(pong.payload, pong.mask);
assertEq(new Buffer(pong.payload).toString(), "Hello"); assertEquals(new Buffer(pong.payload).toString(), "Hello");
}); });
test(async function testReadUnmaksedBigBinaryFrame() { test(async function testReadUnmaksedBigBinaryFrame() {
@ -111,10 +111,10 @@ test(async function testReadUnmaksedBigBinaryFrame() {
} }
const buf = new BufReader(new Buffer(new Uint8Array(a))); const buf = new BufReader(new Buffer(new Uint8Array(a)));
const bin = await readFrame(buf); const bin = await readFrame(buf);
assertEq(bin.opcode, OpCode.BinaryFrame); assertEquals(bin.opcode, OpCode.BinaryFrame);
assertEq(bin.isLastFrame, true); assertEquals(bin.isLastFrame, true);
assertEq(bin.mask, undefined); assertEquals(bin.mask, undefined);
assertEq(bin.payload.length, 256); assertEquals(bin.payload.length, 256);
}); });
test(async function testReadUnmaskedBigBigBinaryFrame() { test(async function testReadUnmaskedBigBigBinaryFrame() {
@ -124,16 +124,16 @@ test(async function testReadUnmaskedBigBigBinaryFrame() {
} }
const buf = new BufReader(new Buffer(new Uint8Array(a))); const buf = new BufReader(new Buffer(new Uint8Array(a)));
const bin = await readFrame(buf); const bin = await readFrame(buf);
assertEq(bin.opcode, OpCode.BinaryFrame); assertEquals(bin.opcode, OpCode.BinaryFrame);
assertEq(bin.isLastFrame, true); assertEquals(bin.isLastFrame, true);
assertEq(bin.mask, undefined); assertEquals(bin.mask, undefined);
assertEq(bin.payload.length, 0xffff + 1); assertEquals(bin.payload.length, 0xffff + 1);
}); });
test(async function testCreateSecAccept() { test(async function testCreateSecAccept() {
const nonce = "dGhlIHNhbXBsZSBub25jZQ=="; const nonce = "dGhlIHNhbXBsZSBub25jZQ==";
const d = createSecAccept(nonce); const d = createSecAccept(nonce);
assertEq(d, "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="); assertEquals(d, "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=");
}); });
test(function testAcceptable() { test(function testAcceptable() {
@ -143,7 +143,7 @@ test(function testAcceptable() {
"sec-websocket-key": "aaa" "sec-websocket-key": "aaa"
}) })
}); });
assertEq(ret, true); assertEquals(ret, true);
}); });
const invalidHeaders = [ const invalidHeaders = [
@ -158,6 +158,6 @@ test(function testAcceptableInvalid() {
const ret = acceptable({ const ret = acceptable({
headers: new Headers(pat) headers: new Headers(pat)
}); });
assertEq(ret, false); assertEquals(ret, false);
} }
}); });