Skip to content

Commit

Permalink
test(assert): add "assert() throws if expr is falsy" test
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua committed Jul 3, 2024
1 parent 1a11b69 commit 6b10839
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions assert/assert_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assert, AssertionError, assertThrows } from "./mod.ts";

Deno.test("assert() throws if expr is falsy", () => {
const FALSY_VALUES = [false, 0, "", null, undefined, NaN];
for (const value of FALSY_VALUES) {
const msg = crypto.randomUUID();
assertThrows(() => assert(value, msg), AssertionError, msg);
}
});

0 comments on commit 6b10839

Please sign in to comment.