Skip to content

Commit

Permalink
test(assert): add "assert() throws if expr is falsy" test (#5267)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua authored Jul 3, 2024
1 parent 8a96290 commit c9a4eff
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 c9a4eff

Please sign in to comment.