summaryrefslogtreecommitdiff
path: root/std/_util/assert_test.ts
blob: 919767fd0a8ed3e9270d778c6d2927eaa00700c5 (plain)
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
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import { assert, DenoStdInternalError } from "./assert.ts";
import { assertThrows } from "../testing/asserts.ts";

Deno.test({
  name: "assert valid scenario",
  fn(): void {
    assert(true);
  },
});

Deno.test({
  name: "assert invalid scenario, no message",
  fn(): void {
    assertThrows(() => {
      assert(false);
    }, DenoStdInternalError);
  },
});
Deno.test({
  name: "assert invalid scenario, with message",
  fn(): void {
    assertThrows(
      () => {
        assert(false, "Oops! Should be true");
      },
      DenoStdInternalError,
      "Oops! Should be true",
    );
  },
});