This release is 21 versions behind 1.0.16 — the latest version of @std/assert. Jump to latest
Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
Works with
•JSR Score100%•This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




Downloads60,953/wk
•Published2 years ago (0.224.0)
Common assertion functions, especially useful for testing
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import { assert, AssertionError, unreachable } from "./mod.ts"; Deno.test("AssertsUnreachable", function () { let didThrow = false; try { unreachable(); } catch (e) { assert(e instanceof AssertionError); assert(e.message === "unreachable"); didThrow = true; } assert(didThrow); }); Deno.test("unreachable with reason", function () { let didThrow = false; try { unreachable("inconceivable!"); } catch (e) { assert(e instanceof AssertionError); assert(e.message === "inconceivable!"); didThrow = true; } assert(didThrow); });