Skip to content

Commit c9a4eff

Browse files
authored
test(assert): add "assert() throws if expr is falsy" test (#5267)
1 parent 8a96290 commit c9a4eff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

assert/assert_test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2+
import { assert, AssertionError, assertThrows } from "./mod.ts";
3+
4+
Deno.test("assert() throws if expr is falsy", () => {
5+
const FALSY_VALUES = [false, 0, "", null, undefined, NaN];
6+
for (const value of FALSY_VALUES) {
7+
const msg = crypto.randomUUID();
8+
assertThrows(() => assert(value, msg), AssertionError, msg);
9+
}
10+
});

0 commit comments

Comments
 (0)