mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
27 lines
653 B
TypeScript
27 lines
653 B
TypeScript
// 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);
|
|
});
|