deno.land / std@0.173.0 / _util / asserts_test.ts

asserts_test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.import { assert, DenoStdInternalError, unreachable } from "./asserts.ts";import { assertThrows } from "../testing/asserts.ts";
Deno.test({ name: "assert valid scenario", fn() { assert(true); },});
Deno.test({ name: "assert invalid scenario, no message", fn() { assertThrows(() => { assert(false); }, DenoStdInternalError); },});Deno.test({ name: "assert invalid scenario, with message", fn() { assertThrows( () => { assert(false, "Oops! Should be true"); }, DenoStdInternalError, "Oops! Should be true", ); },});
Deno.test("assert unreachable", function () { let didThrow = false; try { unreachable(); } catch (e) { assert(e instanceof DenoStdInternalError); assert(e.message === "unreachable"); didThrow = true; } assert(didThrow);});
std

Version Info

Tagged at
a year ago