diff options
| author | Vincent LE GOFF <g_n_s@hotmail.fr> | 2019-03-06 22:39:50 +0100 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-06 16:39:50 -0500 |
| commit | e36edfdb3fd4709358a5f499f13cfe3d53c2b4f7 (patch) | |
| tree | 1baef3f876a5e75288c3ec9056cdb93dd6b5787f /testing/mod.ts | |
| parent | d29957ad17956016c35a04f5f1f98565e58e8a2e (diff) | |
Testing refactor (denoland/deno_std#240)
Original: https://github.com/denoland/deno_std/commit/e1d5c00279132aa639030c6c6d9b4e308bd4775e
Diffstat (limited to 'testing/mod.ts')
| -rw-r--r-- | testing/mod.ts | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/testing/mod.ts b/testing/mod.ts index c9cdde0d2..09e183796 100644 --- a/testing/mod.ts +++ b/testing/mod.ts @@ -1,68 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { green, red } from "../colors/mod.ts"; -import { assertEqual as prettyAssertEqual } from "./pretty.ts"; -import { - assert as assertImport, - equal as AssertEqual, - assertStrictEq, - assertStrContains, - assertMatch, - fail, - assertThrows, - assertThrowsAsync -} from "./asserts.ts"; - -export function equal(c: unknown, d: unknown): boolean { - const seen = new Map(); - return (function compare(a: unknown, b: unknown) { - 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; - } - const merged = { ...a, ...b }; - for (const key in merged) { - type Key = keyof typeof merged; - if (!compare(a && a[key as Key], b && b[key as Key])) { - return false; - } - } - seen.set(a, b); - return true; - } - return false; - })(c, d); -} - -const assertions = { - assert: assertImport, - equal: AssertEqual, - strictEqual: assertStrictEq, - assertStrContains: assertStrContains, - assertMatch: assertMatch, - fail: fail, - throws: assertThrows, - throwsAsync: assertThrowsAsync -}; - -type Assert = typeof assertions.assert & typeof assertions; - -// Decorate assertions.assert with all the assertions -Object.assign(assertions.assert, assertions); - -export const assert = assertions.assert as Assert; - -/** - * Alias to pretty.assertEqual - * @deprecated - */ -export const assertEqual = prettyAssertEqual; export type TestFunction = () => void | Promise<void>; |
