summaryrefslogtreecommitdiff
path: root/std/testing/asserts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/testing/asserts.ts')
-rw-r--r--std/testing/asserts.ts41
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.
*/