From 8b7f5531ee1ccde897e87890e9aabc554fedb9dd Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 9 Nov 2020 06:25:13 -0800 Subject: feat(std/node): consistent Node.js builtin shapes (#8274) --- std/node/assert.ts | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'std/node/assert.ts') diff --git a/std/node/assert.ts b/std/node/assert.ts index ad353912e..ed402dd7f 100644 --- a/std/node/assert.ts +++ b/std/node/assert.ts @@ -1,25 +1,42 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +export { AssertionError } from "./assertion_error.ts"; import { - assertEquals, - assertMatch, - assertNotEquals, - assertNotStrictEquals, - assertStrictEquals, - assertThrows, + assertEquals as deepStrictEqual, + AssertionError, + assertMatch as match, + assertNotEquals as notDeepStrictEqual, + assertNotStrictEquals as notStrictEqual, + assertStrictEquals as strictEqual, + assertThrows as throws, + fail, } from "../testing/asserts.ts"; -export { AssertionError } from "./assertion_error.ts"; +function assert(expr: unknown, msg = ""): asserts expr { + if (!expr) { + throw new AssertionError(msg); + } +} +const ok = assert; +export default assert; -export { - assert, - assert as default, - assert as ok, +Object.assign(assert, { + deepStrictEqual, fail, -} from "../testing/asserts.ts"; + match, + notDeepStrictEqual, + notStrictEqual, + ok, + strictEqual, + throws, +}); -export const deepStrictEqual = assertEquals; -export const notDeepStrictEqual = assertNotEquals; -export const strictEqual = assertStrictEquals; -export const notStrictEqual = assertNotStrictEquals; -export const match = assertMatch; -export const throws = assertThrows; +export { + deepStrictEqual, + fail, + match, + notDeepStrictEqual, + notStrictEqual, + ok, + strictEqual, + throws, +}; -- cgit v1.2.3