diff options
author | Schwarzkopf Balázs <schwarzkopfb@icloud.com> | 2020-08-20 17:56:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-20 11:56:31 -0400 |
commit | 87b1b8c461d54170d2cd2d9232659837c1eeadc0 (patch) | |
tree | 61e69e9b1be0dd17b149e75e00b66a7e815b44b0 /std/testing/asserts.ts | |
parent | 5adb6cba3ee443801a4d54e894284183ef096364 (diff) |
fix(std/node): misnamed assert exports (#7123)
Diffstat (limited to 'std/testing/asserts.ts')
-rw-r--r-- | std/testing/asserts.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts index 4b9241e55..fe8b90f63 100644 --- a/std/testing/asserts.ts +++ b/std/testing/asserts.ts @@ -242,10 +242,20 @@ export function assertNotEquals( * assertStrictEquals(1, 2) * ``` */ +export function assertStrictEquals( + actual: unknown, + expected: unknown, + msg?: string, +): void; export function assertStrictEquals<T>( actual: T, expected: T, msg?: string, +): void; +export function assertStrictEquals( + actual: unknown, + expected: unknown, + msg?: string, ): void { if (actual === expected) { return; @@ -286,6 +296,37 @@ export function assertStrictEquals<T>( } /** + * Make an assertion that `actual` and `expected` are not strictly equal. + * If the values are strictly equal then throw. + * ```ts + * assertNotStrictEquals(1, 1) + * ``` + */ +export function assertNotStrictEquals( + actual: unknown, + expected: unknown, + msg?: string, +): void; +export function assertNotStrictEquals<T>( + actual: T, + expected: T, + msg?: string, +): void; +export function assertNotStrictEquals( + actual: unknown, + expected: unknown, + msg?: string, +): void { + if (actual !== expected) { + return; + } + + throw new AssertionError( + msg ?? `Expected "actual" to be strictly unequal to: ${_format(actual)}\n`, + ); +} + +/** * Make an assertion that actual contains expected. If not * then thrown. */ |