diff --git a/assert/assert_test.ts b/assert/assert_test.ts new file mode 100644 index 000000000000..203ca1c80dff --- /dev/null +++ b/assert/assert_test.ts @@ -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); + } +});