diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2018-12-21 22:03:27 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-12-21 06:03:27 -0500 |
commit | 317fddbbf8615b8cb4dc3c0ea7d81c0c80a8e3ee (patch) | |
tree | 62f41c7cdd3fe9d36e6cc43739133c18f3690fbe /js/testing/util_test.ts | |
parent | e4be1209b6216ad12729981947c0725b5ccc55a5 (diff) |
Improve handling of non-coercable objects in assertEqual (#1385)
Diffstat (limited to 'js/testing/util_test.ts')
-rw-r--r-- | js/testing/util_test.ts | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/js/testing/util_test.ts b/js/testing/util_test.ts index 9ac3dfd71..25f0b2c45 100644 --- a/js/testing/util_test.ts +++ b/js/testing/util_test.ts @@ -17,7 +17,7 @@ import { test } from "./testing.ts"; import { assert } from "./util.ts"; import * as util from "./util.ts"; -test(async function util_equal() { +test(function util_equal() { assert(util.equal("world", "world")); assert(!util.equal("hello", "world")); assert(util.equal(5, 5)); @@ -38,3 +38,35 @@ test(async function util_equal() { ) ); }); + +test(function util_assertEqual() { + const a = Object.create(null); + a.b = "foo"; + util.assertEqual(a, a); +}); + +test(function util_assertEqualActualUncoercable() { + let didThrow = false; + const a = Object.create(null); + try { + util.assertEqual(a, "bar"); + } catch (e) { + didThrow = true; + console.log(e.message); + assert(e.message === "actual: [Cannot display] expected: bar"); + } + assert(didThrow); +}); + +test(function util_assertEqualExpectedUncoercable() { + let didThrow = false; + const a = Object.create(null); + try { + util.assertEqual("bar", a); + } catch (e) { + didThrow = true; + console.log(e.message); + assert(e.message === "actual: bar expected: [Cannot display]"); + } + assert(didThrow); +}); |