std/assert/mod.ts
Yusuke Tanaka de9f8d2db1
feat(assert/unstable): add assertNever (#5690)
This commit adds a new function `assertNever` to the `assert` submodule.

This function is particularly useful when we want to check whether we properly
handle all the variants of a discriminated union. Ref:
https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#union-exhaustiveness-checking

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2024-08-16 08:10:23 -07:00

49 lines
1.5 KiB
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
/** A library of assertion functions.
* If the assertion is false an `AssertionError` will be thrown which will
* result in pretty-printed diff of failing assertion.
*
* This module is browser compatible, but do not rely on good formatting of
* values for AssertionError messages in browsers.
*
* ```ts no-eval
* import { assert } from "@std/assert";
*
* assert("I am truthy"); // Doesn't throw
* assert(false); // Throws `AssertionError`
* ```
*
* @module
*/
export * from "./almost_equals.ts";
export * from "./array_includes.ts";
export * from "./equals.ts";
export * from "./exists.ts";
export * from "./false.ts";
export * from "./greater_or_equal.ts";
export * from "./greater.ts";
export * from "./instance_of.ts";
export * from "./is_error.ts";
export * from "./less_or_equal.ts";
export * from "./less.ts";
export * from "./match.ts";
export * from "./never.ts";
export * from "./not_equals.ts";
export * from "./not_instance_of.ts";
export * from "./not_match.ts";
export * from "./not_strict_equals.ts";
export * from "./object_match.ts";
export * from "./rejects.ts";
export * from "./strict_equals.ts";
export * from "./string_includes.ts";
export * from "./throws.ts";
export * from "./assert.ts";
export * from "./assertion_error.ts";
export * from "./equal.ts";
export * from "./fail.ts";
export * from "./unimplemented.ts";
export * from "./unreachable.ts";