From 6a783ea179de1321ae7fd0586967476e72984c63 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 1 Jan 2019 22:46:17 -0500 Subject: [PATCH] Add testing module Original: https://github.com/denoland/deno_std/commit/61fdae51a7cc50874b9674c40b1aef3fbf012494 --- README.md | 5 +- colors/main_test.ts | 2 +- examples/test.ts | 2 +- flags/tests/all_bool.ts | 2 +- flags/tests/bool.ts | 2 +- flags/tests/dash.ts | 2 +- flags/tests/default_bool.ts | 2 +- flags/tests/dotted.ts | 2 +- flags/tests/kv_short.ts | 2 +- flags/tests/long.ts | 2 +- flags/tests/num.ts | 2 +- flags/tests/parse.ts | 2 +- flags/tests/short.ts | 2 +- flags/tests/stop_early.ts | 2 +- flags/tests/unknown.ts | 2 +- flags/tests/whitespace.ts | 2 +- logging/README.md | 26 ++--- logging/test.ts | 3 +- mkdirp/test.ts | 2 +- net/bufio_test.ts | 2 +- net/extension_map.json | 2 +- net/file_server_test.ts | 2 +- net/http_test.ts | 2 +- net/textproto_test.ts | 2 +- path/basename_test.ts | 2 +- path/dirname_test.ts | 2 +- path/extname_test.ts | 2 +- path/isabsolute_test.ts | 2 +- path/join_test.ts | 2 +- path/parse_format_test.ts | 2 +- path/relative_test.ts | 2 +- path/resolve_test.ts | 2 +- path/zero_length_strings_test.ts | 2 +- test.ts | 28 ++---- testing/mod.ts | 162 +++++++++++++++++++++++++++++++ testing/test.ts | 57 +++++++++++ 36 files changed, 275 insertions(+), 66 deletions(-) create mode 100644 testing/mod.ts create mode 100644 testing/test.ts diff --git a/README.md b/README.md index 995ce9c53d..f6c40627ad 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,12 @@ for Deno. | Collection | Description | | --------------------- | --------------------------------------------------------------- | | [colors](./colors/) | Modules that generate ANSI color codes for the console. | -| [net](./net/) | A framework for creating HTTP/HTTPS servers inspired by GoLang. | -| [path](./path/) | File path manipulation. | | [flags](./flags/) | Command line arguments parser. | | [logging](./logging/) | Command line logging | | [mkdirp](./mkdirp/) | Make directory branches. | +| [net](./net/) | A framework for creating HTTP/HTTPS servers inspired by GoLang. | +| [path](./path/) | File path manipulation. | +| [testing](./testing/) | Testing | --- diff --git a/colors/main_test.ts b/colors/main_test.ts index 3ca064bb7e..2073c7c788 100644 --- a/colors/main_test.ts +++ b/colors/main_test.ts @@ -1,4 +1,4 @@ -import { assertEqual, test } from "https://deno.land/x/testing/testing.ts"; +import { assertEqual, test } from "../testing/mod.ts"; import { color } from "main.ts"; import "example.ts"; diff --git a/examples/test.ts b/examples/test.ts index 4d2dea1571..f42db1bba6 100644 --- a/examples/test.ts +++ b/examples/test.ts @@ -1,5 +1,5 @@ import { run } from "deno"; -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; /** Example of how to do basic tests */ test(function t1() { diff --git a/flags/tests/all_bool.ts b/flags/tests/all_bool.ts index 879de5cc04..2e0bba4ce4 100755 --- a/flags/tests/all_bool.ts +++ b/flags/tests/all_bool.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; // flag boolean true (default all --args to boolean) diff --git a/flags/tests/bool.ts b/flags/tests/bool.ts index ee4f5e1c3b..5d135028e5 100755 --- a/flags/tests/bool.ts +++ b/flags/tests/bool.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function flagBooleanDefaultFalse() { diff --git a/flags/tests/dash.ts b/flags/tests/dash.ts index 2008cce43f..f8cec6ef7d 100755 --- a/flags/tests/dash.ts +++ b/flags/tests/dash.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function hyphen() { diff --git a/flags/tests/default_bool.ts b/flags/tests/default_bool.ts index b43c52e8dc..8cf6a720b2 100755 --- a/flags/tests/default_bool.ts +++ b/flags/tests/default_bool.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function booleanDefaultTrue() { diff --git a/flags/tests/dotted.ts b/flags/tests/dotted.ts index 03f72dc838..94867abb27 100755 --- a/flags/tests/dotted.ts +++ b/flags/tests/dotted.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function dottedAlias() { diff --git a/flags/tests/kv_short.ts b/flags/tests/kv_short.ts index 93aa763877..1050d77347 100755 --- a/flags/tests/kv_short.ts +++ b/flags/tests/kv_short.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function short() { diff --git a/flags/tests/long.ts b/flags/tests/long.ts index 57e48ecbea..41c3e77436 100755 --- a/flags/tests/long.ts +++ b/flags/tests/long.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function longOpts() { diff --git a/flags/tests/num.ts b/flags/tests/num.ts index 66cbcb7ad2..0588b51f6d 100755 --- a/flags/tests/num.ts +++ b/flags/tests/num.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function nums() { diff --git a/flags/tests/parse.ts b/flags/tests/parse.ts index 29a500868a..30551f875d 100644 --- a/flags/tests/parse.ts +++ b/flags/tests/parse.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function _arseArgs() { diff --git a/flags/tests/short.ts b/flags/tests/short.ts index 00c9dcc807..dee981351f 100755 --- a/flags/tests/short.ts +++ b/flags/tests/short.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function numbericShortArgs() { diff --git a/flags/tests/stop_early.ts b/flags/tests/stop_early.ts index 62725e6cfa..ca64bf97ec 100755 --- a/flags/tests/stop_early.ts +++ b/flags/tests/stop_early.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; // stops parsing on the first non-option when stopEarly is set diff --git a/flags/tests/unknown.ts b/flags/tests/unknown.ts index ff5f2041c3..2c87b18feb 100755 --- a/flags/tests/unknown.ts +++ b/flags/tests/unknown.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function booleanAndAliasIsNotUnknown() { diff --git a/flags/tests/whitespace.ts b/flags/tests/whitespace.ts index f50518b4fa..8373cd19e0 100755 --- a/flags/tests/whitespace.ts +++ b/flags/tests/whitespace.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../../testing/mod.ts"; import { parse } from "../index.ts"; test(function whitespaceShouldBeWhitespace() { diff --git a/logging/README.md b/logging/README.md index 4d7e954748..1d88cb0708 100644 --- a/logging/README.md +++ b/logging/README.md @@ -12,27 +12,27 @@ log.critical("500 Internal server error"); // configure as needed await log.setup({ - handlers: { - console: new log.handlers.ConsoleHandler("DEBUG"), - file: new log.handlers.FileHandler("WARNING", "./log.txt"), - }, + handlers: { + console: new log.handlers.ConsoleHandler("DEBUG"), + file: new log.handlers.FileHandler("WARNING", "./log.txt") + }, - loggers: { - default: { - level: "DEBUG", - handlers: ["console", "file"], - } + loggers: { + default: { + level: "DEBUG", + handlers: ["console", "file"] } + } }); // get configured logger const logger = log.getLogger("default"); -logger.debug("fizz") // <- logs to `console`, because `file` handler requires 'WARNING' level -logger.warning("buzz") // <- logs to both `console` and `file` handlers +logger.debug("fizz"); // <- logs to `console`, because `file` handler requires 'WARNING' level +logger.warning("buzz"); // <- logs to both `console` and `file` handlers // if you try to use a logger that hasn't been configured // you're good to go, it gets created automatically with level set to 0 // so no message is logged const unknownLogger = log.getLogger("mystery"); -unknownLogger.info("foobar") // no-op -``` \ No newline at end of file +unknownLogger.info("foobar"); // no-op +``` diff --git a/logging/test.ts b/logging/test.ts index 4808b59444..b96a046ddc 100644 --- a/logging/test.ts +++ b/logging/test.ts @@ -1,6 +1,5 @@ import { remove, open, readAll } from "deno"; -import { assertEqual, test } from "https://deno.land/x/testing/testing.ts"; - +import { assertEqual, test } from "../testing/mod.ts"; import * as log from "index.ts"; import { FileHandler } from "./handlers.ts"; diff --git a/mkdirp/test.ts b/mkdirp/test.ts index 9f5d7fb929..a3a4fac037 100644 --- a/mkdirp/test.ts +++ b/mkdirp/test.ts @@ -1,5 +1,5 @@ import { cwd, lstat, makeTempDirSync, removeAll, FileInfo } from "deno"; -import { test, assert } from "https://deno.land/x/testing/testing.ts"; +import { test, assert } from "../testing/mod.ts"; import { mkdirp } from "./mkdirp.ts"; let root: string = `${cwd()}/${Date.now()}`; //makeTempDirSync(); diff --git a/net/bufio_test.ts b/net/bufio_test.ts index 96490a6c9d..411f173f4f 100644 --- a/net/bufio_test.ts +++ b/net/bufio_test.ts @@ -8,7 +8,7 @@ import { test, assert, assertEqual -} from "https://deno.land/x/testing/testing.ts"; +} from "../testing/mod.ts"; import { BufReader, BufState, BufWriter } from "./bufio.ts"; import * as iotest from "./iotest.ts"; import { charCode, copyBytes, stringsReader } from "./util.ts"; diff --git a/net/extension_map.json b/net/extension_map.json index 241e8677dd..b02517d6b0 100644 --- a/net/extension_map.json +++ b/net/extension_map.json @@ -82,4 +82,4 @@ ".yml": "text/yaml", ".yaml": "text/yaml", ".zip": "application/zip" -} \ No newline at end of file +} diff --git a/net/file_server_test.ts b/net/file_server_test.ts index 40bec1c4b2..36fe8bdc31 100644 --- a/net/file_server_test.ts +++ b/net/file_server_test.ts @@ -4,7 +4,7 @@ import { test, assert, assertEqual -} from "https://deno.land/x/testing/testing.ts"; +} from "../testing/mod.ts"; // Promise to completeResolve when all tests completes let completeResolve; diff --git a/net/http_test.ts b/net/http_test.ts index 93a8049e65..46ea601854 100644 --- a/net/http_test.ts +++ b/net/http_test.ts @@ -10,7 +10,7 @@ import { test, assert, assertEqual -} from "https://deno.land/x/testing/testing.ts"; +} from "../testing/mod.ts"; import { listenAndServe, ServerRequest, diff --git a/net/textproto_test.ts b/net/textproto_test.ts index 3af21247a6..9fe5e8dd34 100644 --- a/net/textproto_test.ts +++ b/net/textproto_test.ts @@ -10,7 +10,7 @@ import { test, assert, assertEqual -} from "https://deno.land/x/testing/testing.ts"; +} from "../testing/mod.ts"; function reader(s: string): TextProtoReader { return new TextProtoReader(new BufReader(stringsReader(s))); diff --git a/path/basename_test.ts b/path/basename_test.ts index a5104106ac..b605aa2100 100644 --- a/path/basename_test.ts +++ b/path/basename_test.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; test(function basename() { diff --git a/path/dirname_test.ts b/path/dirname_test.ts index 8e92c4498b..e535ec8911 100644 --- a/path/dirname_test.ts +++ b/path/dirname_test.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; test(function dirname() { diff --git a/path/extname_test.ts b/path/extname_test.ts index c9a4a68f45..0d6d283a8a 100644 --- a/path/extname_test.ts +++ b/path/extname_test.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; const slashRE = /\//g; diff --git a/path/isabsolute_test.ts b/path/isabsolute_test.ts index 38eddd5e8c..548819ac0e 100644 --- a/path/isabsolute_test.ts +++ b/path/isabsolute_test.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; test(function isAbsolute() { diff --git a/path/join_test.ts b/path/join_test.ts index 2c98592f5c..25e302eba7 100644 --- a/path/join_test.ts +++ b/path/join_test.ts @@ -1,4 +1,4 @@ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; const backslashRE = /\\/g; diff --git a/path/parse_format_test.ts b/path/parse_format_test.ts index 75c3ff00a2..1b5e5908ad 100644 --- a/path/parse_format_test.ts +++ b/path/parse_format_test.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; const winPaths = [ diff --git a/path/relative_test.ts b/path/relative_test.ts index 2e4b455f79..dcf8fed984 100644 --- a/path/relative_test.ts +++ b/path/relative_test.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; const relativeTests = { diff --git a/path/resolve_test.ts b/path/resolve_test.ts index b734560b9e..b365d40b07 100644 --- a/path/resolve_test.ts +++ b/path/resolve_test.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; import { cwd } from "deno"; diff --git a/path/zero_length_strings_test.ts b/path/zero_length_strings_test.ts index 8774c51f77..f9b357bf1c 100644 --- a/path/zero_length_strings_test.ts +++ b/path/zero_length_strings_test.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { test, assertEqual } from "https://deno.land/x/testing/testing.ts"; +import { test, assertEqual } from "../testing/mod.ts"; import * as path from "./index.ts"; import { cwd } from "deno"; diff --git a/test.ts b/test.ts index 25178ecc62..4c7f763af8 100755 --- a/test.ts +++ b/test.ts @@ -1,27 +1,14 @@ #!/usr/bin/env deno --allow-run --allow-net --allow-write import { run } from "deno"; -// colors tests import "colors/main_test.ts"; - -// flags tests +import "examples/test.ts"; import "flags/test.ts"; - -// net tests +import "logging/test.ts"; +import "mkdirp/test.ts"; import "net/bufio_test.ts"; import "net/http_test.ts"; import "net/textproto_test.ts"; -import "examples/test.ts"; -import { runTests, completePromise } from "net/file_server_test.ts"; - -// logging tests -import "logging/test.ts"; - -// file server test -const fileServer = run({ - args: ["deno", "--allow-net", "net/file_server.ts", ".", "--cors"] -}); -// path test import "path/basename_test.ts"; import "path/dirname_test.ts"; import "path/extname_test.ts"; @@ -31,11 +18,14 @@ import "path/parse_format_test.ts"; import "path/relative_test.ts"; import "path/resolve_test.ts"; import "path/zero_length_strings_test.ts"; +import "testing/test.ts"; -// mkdirp tests -import "mkdirp/test.ts"; +import { runTests, completePromise } from "net/file_server_test.ts"; + +const fileServer = run({ + args: ["deno", "--allow-net", "net/file_server.ts", ".", "--cors"] +}); -// I am also too lazy to do this properly LOL runTests(new Promise(res => setTimeout(res, 5000))); (async () => { await completePromise; diff --git a/testing/mod.ts b/testing/mod.ts new file mode 100644 index 0000000000..f33e743fc0 --- /dev/null +++ b/testing/mod.ts @@ -0,0 +1,162 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. + +// Do not add imports in this file in order to be compatible with Node. + +export function assertEqual(actual: unknown, expected: unknown, msg?: string) { + if (!equal(actual, expected)) { + let actualString: string; + let expectedString: string; + try { + actualString = String(actual); + } catch (e) { + actualString = "[Cannot display]"; + } + try { + expectedString = String(expected); + } catch (e) { + expectedString = "[Cannot display]"; + } + console.error( + "assertEqual failed. actual =", + actualString, + "expected =", + expectedString + ); + if (!msg) { + msg = `actual: ${actualString} expected: ${expectedString}`; + } + throw new Error(msg); + } +} + +export function assert(expr: boolean, msg = "") { + if (!expr) { + throw new Error(msg); + } +} + +// TODO(ry) Use unknown here for parameters types. +// tslint:disable-next-line:no-any +export function equal(c: any, d: any): boolean { + const seen = new Map(); + return (function compare(a, b) { + if (Object.is(a, b)) { + return true; + } + if (a && typeof a === "object" && b && typeof b === "object") { + if (seen.get(a) === b) { + return true; + } + if (Object.keys(a).length !== Object.keys(b).length) { + return false; + } + for (const key in { ...a, ...b }) { + if (!compare(a[key], b[key])) { + return false; + } + } + seen.set(a, b); + return true; + } + return false; + })(c, d); +} + +export type TestFunction = () => void | Promise; + +export interface TestDefinition { + fn: TestFunction; + name: string; +} + +export const exitOnFail = true; + +let filterRegExp: RegExp | null; +const tests: TestDefinition[] = []; + +let filtered = 0; +const ignored = 0; +const measured = 0; + +// Must be called before any test() that needs to be filtered. +export function setFilter(s: string): void { + filterRegExp = new RegExp(s, "i"); +} + +export function test(t: TestDefinition | TestFunction): void { + const fn: TestFunction = typeof t === "function" ? t : t.fn; + const name: string = t.name; + + if (!name) { + throw new Error("Test function may not be anonymous"); + } + if (filter(name)) { + tests.push({ fn, name }); + } else { + filtered++; + } +} + +function filter(name: string): boolean { + if (filterRegExp) { + return filterRegExp.test(name); + } else { + return true; + } +} + +const RESET = "\x1b[0m"; +const FG_RED = "\x1b[31m"; +const FG_GREEN = "\x1b[32m"; + +function red_failed() { + return FG_RED + "FAILED" + RESET; +} + +function green_ok() { + return FG_GREEN + "ok" + RESET; +} + +async function runTests() { + let passed = 0; + let failed = 0; + + console.log("running", tests.length, "tests"); + for (let i = 0; i < tests.length; i++) { + const { fn, name } = tests[i]; + let result = green_ok(); + console.log("test", name); + try { + await fn(); + passed++; + } catch (e) { + result = red_failed(); + console.error((e && e.stack) || e); + failed++; + if (exitOnFail) { + break; + } + } + // TODO Do this on the same line as test name is printed. + console.log("...", result); + } + + // Attempting to match the output of Rust's test runner. + const result = failed > 0 ? red_failed() : green_ok(); + console.log( + `\ntest result: ${result}. ${passed} passed; ${failed} failed; ` + + `${ignored} ignored; ${measured} measured; ${filtered} filtered out\n` + ); + + if (failed === 0) { + // All good. + } else { + // Use setTimeout to avoid the error being ignored due to unhandled + // promise rejections being swallowed. + setTimeout(() => { + throw new Error(`There were ${failed} test failures.`); + }, 0); + } +} + +setTimeout(runTests, 0); diff --git a/testing/test.ts b/testing/test.ts new file mode 100644 index 0000000000..7012a6e472 --- /dev/null +++ b/testing/test.ts @@ -0,0 +1,57 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. + +import { test, assert, assertEqual, equal } from "./mod.ts"; + +test(function testingEqual() { + assert(equal("world", "world")); + assert(!equal("hello", "world")); + assert(equal(5, 5)); + assert(!equal(5, 6)); + assert(equal(NaN, NaN)); + assert(equal({ hello: "world" }, { hello: "world" })); + assert(!equal({ world: "hello" }, { hello: "world" })); + assert( + equal( + { hello: "world", hi: { there: "everyone" } }, + { hello: "world", hi: { there: "everyone" } } + ) + ); + assert( + !equal( + { hello: "world", hi: { there: "everyone" } }, + { hello: "world", hi: { there: "everyone else" } } + ) + ); +}); + +test(function testingAssertEqual() { + const a = Object.create(null); + a.b = "foo"; + assertEqual(a, a); +}); + +test(function testingAssertEqualActualUncoercable() { + let didThrow = false; + const a = Object.create(null); + try { + assertEqual(a, "bar"); + } catch (e) { + didThrow = true; + console.log(e.message); + assert(e.message === "actual: [Cannot display] expected: bar"); + } + assert(didThrow); +}); + +test(function testingAssertEqualExpectedUncoercable() { + let didThrow = false; + const a = Object.create(null); + try { + assertEqual("bar", a); + } catch (e) { + didThrow = true; + console.log(e.message); + assert(e.message === "actual: bar expected: [Cannot display]"); + } + assert(didThrow); +});