Skip to content
Permalink
Browse files

Rename assertEq to assertEquals (denoland#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.
  • Loading branch information...
ry committed Mar 7, 2019
1 parent e1d5c00 commit 4cf39d4a1420b8153cd78d03d03ef843607ae506
Showing with 720 additions and 714 deletions.
  1. +5 −5 bytes/bytes_test.ts
  2. +7 −7 colors/test.ts
  3. +13 −13 datetime/test.ts
  4. +4 −4 examples/test.ts
  5. +5 −5 flags/tests/all_bool.ts
  6. +23 −23 flags/tests/bool.ts
  7. +17 −14 flags/tests/dash.ts
  8. +5 −5 flags/tests/default_bool.ts
  9. +6 −6 flags/tests/dotted.ts
  10. +3 −3 flags/tests/kv_short.ts
  11. +6 −6 flags/tests/long.ts
  12. +11 −11 flags/tests/num.ts
  13. +46 −46 flags/tests/parse.ts
  14. +11 −11 flags/tests/short.ts
  15. +2 −2 flags/tests/stop_early.ts
  16. +8 −8 flags/tests/unknown.ts
  17. +2 −2 flags/tests/whitespace.ts
  18. +25 −25 fs/glob_test.ts
  19. +2 −2 fs/globrex_test.ts
  20. +57 −54 fs/path/basename_test.ts
  21. +42 −42 fs/path/dirname_test.ts
  22. +20 −20 fs/path/extname_test.ts
  23. +23 −23 fs/path/isabsolute_test.ts
  24. +4 −4 fs/path/join_test.ts
  25. +14 −14 fs/path/parse_format_test.ts
  26. +3 −3 fs/path/relative_test.ts
  27. +3 −3 fs/path/resolve_test.ts
  28. +17 −17 fs/path/zero_length_strings_test.ts
  29. +33 −33 fs/walk_test.ts
  30. +4 −4 http/file_server_test.ts
  31. +10 −10 http/server_test.ts
  32. +31 −31 io/bufio_test.ts
  33. +11 −11 io/ioutil_test.ts
  34. +12 −12 io/readers_test.ts
  35. +6 −6 io/util_test.ts
  36. +3 −3 io/writers_test.ts
  37. +6 −6 log/handlers_test.ts
  38. +12 −12 log/logger_test.ts
  39. +8 −8 log/test.ts
  40. +19 −19 media_types/test.ts
  41. +3 −3 multipart/formfile_test.ts
  42. +19 −19 multipart/multipart_test.ts
  43. +13 −13 prettier/main_test.ts
  44. +1 −1 prettier/vendor/parser_typescript.js
  45. +6 −6 testing/README.md
  46. +2 −2 testing/asserts.ts
  47. +1 −1 testing/asserts_test.ts
  48. +11 −11 testing/diff_test.ts
  49. +70 −70 testing/format_test.ts
  50. +1 −1 testing/pretty.ts
  51. +10 −10 testing/pretty_test.ts
  52. +2 −2 testing/test.ts
  53. +7 −7 textproto/test.ts
  54. +4 −4 ws/sha1_test.ts
  55. +31 −31 ws/test.ts
@@ -5,33 +5,33 @@ import {
bytesHasPrefix
} from "./bytes.ts";
import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts";
import { assertEquals } from "../testing/asserts.ts";

test(function bytesBytesFindIndex() {
const i = bytesFindIndex(
new Uint8Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 3]),
new Uint8Array([0, 1, 2])
);
assertEq(i, 2);
assertEquals(i, 2);
});

test(function bytesBytesFindLastIndex1() {
const i = bytesFindLastIndex(
new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 3]),
new Uint8Array([0, 1, 2])
);
assertEq(i, 3);
assertEquals(i, 3);
});

test(function bytesBytesBytesEqual() {
const v = bytesEqual(
new Uint8Array([0, 1, 2, 3]),
new Uint8Array([0, 1, 2, 3])
);
assertEq(v, true);
assertEquals(v, true);
});

test(function bytesBytesHasPrefix() {
const v = bytesHasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([0, 1]));
assertEq(v, true);
assertEquals(v, true);
});
@@ -1,25 +1,25 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts";
import { assertEquals } from "../testing/asserts.ts";
import { red, bgBlue, setEnabled, getEnabled } from "./mod.ts";
import "./example.ts";

test(function singleColor() {
assertEq(red("Hello world"), "[31mHello world[39m");
assertEquals(red("Hello world"), "[31mHello world[39m");
});

test(function doubleColor() {
assertEq(bgBlue(red("Hello world")), "[44m[31mHello world[39m[49m");
assertEquals(bgBlue(red("Hello world")), "[44m[31mHello world[39m[49m");
});

test(function replacesCloseCharacters() {
assertEq(red("Hel[39mlo"), "[31mHel[31mlo[39m");
assertEquals(red("Hel[39mlo"), "[31mHel[31mlo[39m");
});

test(function enablingColors() {
assertEq(getEnabled(), true);
assertEquals(getEnabled(), true);
setEnabled(false);
assertEq(bgBlue(red("Hello world")), "Hello world");
assertEquals(bgBlue(red("Hello world")), "Hello world");
setEnabled(true);
assertEq(red("Hello world"), "[31mHello world[39m");
assertEquals(red("Hello world"), "[31mHello world[39m");
});
@@ -1,30 +1,30 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts";
import { assert, assertEq } from "../testing/asserts.ts";
import { assert, assertEquals } from "../testing/asserts.ts";
import * as datetime from "./mod.ts";

test(function parseDateTime() {
assertEq(
assertEquals(
datetime.parseDateTime("01-03-2019 16:34", "mm-dd-yyyy hh:mm"),
new Date(2019, 1, 3, 16, 34)
);
assertEq(
assertEquals(
datetime.parseDateTime("03-01-2019 16:34", "dd-mm-yyyy hh:mm"),
new Date(2019, 1, 3, 16, 34)
);
assertEq(
assertEquals(
datetime.parseDateTime("2019-01-03 16:34", "yyyy-mm-dd hh:mm"),
new Date(2019, 1, 3, 16, 34)
);
assertEq(
assertEquals(
datetime.parseDateTime("16:34 01-03-2019", "hh:mm mm-dd-yyyy"),
new Date(2019, 1, 3, 16, 34)
);
assertEq(
assertEquals(
datetime.parseDateTime("16:34 03-01-2019", "hh:mm dd-mm-yyyy"),
new Date(2019, 1, 3, 16, 34)
);
assertEq(
assertEquals(
datetime.parseDateTime("16:34 2019-01-03", "hh:mm yyyy-mm-dd"),
new Date(2019, 1, 3, 16, 34)
);
@@ -36,20 +36,20 @@ test(function invalidParseDateTimeFormatThrows() {
(datetime as any).parseDateTime("2019-01-01 00:00", "x-y-z");
assert(false, "no exception was thrown");
} catch (e) {
assertEq(e.message, "Invalid datetime format!");
assertEquals(e.message, "Invalid datetime format!");
}
});

test(function parseDate() {
assertEq(
assertEquals(
datetime.parseDate("01-03-2019", "mm-dd-yyyy"),
new Date(2019, 1, 3)
);
assertEq(
assertEquals(
datetime.parseDate("03-01-2019", "dd-mm-yyyy"),
new Date(2019, 1, 3)
);
assertEq(
assertEquals(
datetime.parseDate("2019-01-03", "yyyy-mm-dd"),
new Date(2019, 1, 3)
);
@@ -61,12 +61,12 @@ test(function invalidParseDateFormatThrows() {
(datetime as any).parseDate("2019-01-01", "x-y-z");
assert(false, "no exception was thrown");
} catch (e) {
assertEq(e.message, "Invalid date format!");
assertEquals(e.message, "Invalid date format!");
}
});

test(function currentDayOfYear() {
assertEq(
assertEquals(
datetime.currentDayOfYear(),
Math.ceil(new Date().getTime() / 86400000) -
Math.floor(
@@ -1,15 +1,15 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { run } = Deno;
import { test } from "../testing/mod.ts";
import { assertEq } from "../testing/asserts.ts";
import { assertEquals } from "../testing/asserts.ts";

/** Example of how to do basic tests */
test(function t1() {
assertEq("hello", "hello");
assertEquals("hello", "hello");
});

test(function t2() {
assertEq("world", "world");
assertEquals("world", "world");
});

/** A more complicated test that runs a subprocess. */
@@ -19,5 +19,5 @@ test(async function catSmoke() {
stdout: "piped"
});
const s = await p.status();
assertEq(s.code, 0);
assertEquals(s.code, 0);
});
@@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts";
import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts";

// flag boolean true (default all --args to boolean)
@@ -9,12 +9,12 @@ test(function flagBooleanTrue() {
boolean: true
});

assertEq(argv, {
assertEquals(argv, {
honk: true,
_: ["moo", "cow"]
});

assertEq(typeof argv.honk, "boolean");
assertEquals(typeof argv.honk, "boolean");
});

// flag boolean true only affects double hyphen arguments without equals signs
@@ -23,12 +23,12 @@ test(function flagBooleanTrueOnlyAffectsDoubleDash() {
boolean: true
});

assertEq(argv, {
assertEquals(argv, {
honk: true,
tacos: "good",
p: 55,
_: ["moo", "cow"]
});

assertEq(typeof argv.honk, "boolean");
assertEquals(typeof argv.honk, "boolean");
});
@@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts";
import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts";

test(function flagBooleanDefaultFalse() {
@@ -9,31 +9,31 @@ test(function flagBooleanDefaultFalse() {
default: { verbose: false, t: false }
});

assertEq(argv, {
assertEquals(argv, {
verbose: false,
t: false,
_: ["moo"]
});

assertEq(typeof argv.verbose, "boolean");
assertEq(typeof argv.t, "boolean");
assertEquals(typeof argv.verbose, "boolean");
assertEquals(typeof argv.t, "boolean");
});

test(function booleanGroups() {
const argv = parse(["-x", "-z", "one", "two", "three"], {
boolean: ["x", "y", "z"]
});

assertEq(argv, {
assertEquals(argv, {
x: true,
y: false,
z: true,
_: ["one", "two", "three"]
});

assertEq(typeof argv.x, "boolean");
assertEq(typeof argv.y, "boolean");
assertEq(typeof argv.z, "boolean");
assertEquals(typeof argv.x, "boolean");
assertEquals(typeof argv.y, "boolean");
assertEquals(typeof argv.z, "boolean");
});

test(function booleanAndAliasWithChainableApi() {
@@ -56,8 +56,8 @@ test(function booleanAndAliasWithChainableApi() {
_: ["derp"]
};

assertEq(aliasedArgv, expected);
assertEq(propertyArgv, expected);
assertEquals(aliasedArgv, expected);
assertEquals(propertyArgv, expected);
});

test(function booleanAndAliasWithOptionsHash() {
@@ -74,8 +74,8 @@ test(function booleanAndAliasWithOptionsHash() {
h: true,
_: ["derp"]
};
assertEq(aliasedArgv, expected);
assertEq(propertyArgv, expected);
assertEquals(aliasedArgv, expected);
assertEquals(propertyArgv, expected);
});

test(function booleanAndAliasArrayWithOptionsHash() {
@@ -95,9 +95,9 @@ test(function booleanAndAliasArrayWithOptionsHash() {
h: true,
_: ["derp"]
};
assertEq(aliasedArgv, expected);
assertEq(propertyArgv, expected);
assertEq(altPropertyArgv, expected);
assertEquals(aliasedArgv, expected);
assertEquals(propertyArgv, expected);
assertEquals(altPropertyArgv, expected);
});

test(function booleanAndAliasUsingExplicitTrue() {
@@ -115,8 +115,8 @@ test(function booleanAndAliasUsingExplicitTrue() {
_: []
};

assertEq(aliasedArgv, expected);
assertEq(propertyArgv, expected);
assertEquals(aliasedArgv, expected);
assertEquals(propertyArgv, expected);
});

// regression, see https://github.com/substack/node-optimist/issues/71
@@ -126,15 +126,15 @@ test(function booleanAndNonBoolean() {
boolean: "boool"
});

assertEq(parsed.boool, true);
assertEq(parsed.other, "true");
assertEquals(parsed.boool, true);
assertEquals(parsed.other, "true");

const parsed2 = parse(["--boool", "--other=false"], {
boolean: "boool"
});

assertEq(parsed2.boool, true);
assertEq(parsed2.other, "false");
assertEquals(parsed2.boool, true);
assertEquals(parsed2.other, "false");
});

test(function booleanParsingTrue() {
@@ -145,7 +145,7 @@ test(function booleanParsingTrue() {
boolean: ["boool"]
});

assertEq(parsed.boool, true);
assertEquals(parsed.boool, true);
});

test(function booleanParsingFalse() {
@@ -156,5 +156,5 @@ test(function booleanParsingFalse() {
boolean: ["boool"]
});

assertEq(parsed.boool, false);
assertEquals(parsed.boool, false);
});
@@ -1,26 +1,29 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../../testing/mod.ts";
import { assertEq } from "../../testing/asserts.ts";
import { assertEquals } from "../../testing/asserts.ts";
import { parse } from "../mod.ts";

test(function hyphen() {
assertEq(parse(["-n", "-"]), { n: "-", _: [] });
assertEq(parse(["-"]), { _: ["-"] });
assertEq(parse(["-f-"]), { f: "-", _: [] });
assertEq(parse(["-b", "-"], { boolean: "b" }), { b: true, _: ["-"] });
assertEq(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] });
assertEquals(parse(["-n", "-"]), { n: "-", _: [] });
assertEquals(parse(["-"]), { _: ["-"] });
assertEquals(parse(["-f-"]), { f: "-", _: [] });
assertEquals(parse(["-b", "-"], { boolean: "b" }), { b: true, _: ["-"] });
assertEquals(parse(["-s", "-"], { string: "s" }), { s: "-", _: [] });
});

test(function doubleDash() {
assertEq(parse(["-a", "--", "b"]), { a: true, _: ["b"] });
assertEq(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
assertEq(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
assertEquals(parse(["-a", "--", "b"]), { a: true, _: ["b"] });
assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
assertEquals(parse(["--a", "--", "b"]), { a: true, _: ["b"] });
});

test(function moveArgsAfterDoubleDashIntoOwnArray() {
assertEq(parse(["--name", "John", "before", "--", "after"], { "--": true }), {
name: "John",
_: ["before"],
"--": ["after"]
});
assertEquals(
parse(["--name", "John", "before", "--", "after"], { "--": true }),
{
name: "John",
_: ["before"],
"--": ["after"]
}
);
});
Oops, something went wrong.

0 comments on commit 4cf39d4

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.