summaryrefslogtreecommitdiff
path: root/std/node/assert.ts
blob: 7b144b6909d96febbfaa852286be264b600af75c (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
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
export { AssertionError } from "./assertion_error.ts";
import {
  assertEquals as deepStrictEqual,
  AssertionError,
  assertMatch as match,
  assertNotEquals as notDeepStrictEqual,
  assertNotStrictEquals as notStrictEqual,
  assertStrictEquals as strictEqual,
  assertThrows as throws,
  fail,
} from "../testing/asserts.ts";

function assert(expr: unknown, msg = ""): asserts expr {
  if (!expr) {
    throw new AssertionError(msg);
  }
}
const ok = assert;
export default assert;

Object.assign(assert, {
  deepStrictEqual,
  fail,
  match,
  notDeepStrictEqual,
  notStrictEqual,
  ok,
  strictEqual,
  throws,
});

export {
  deepStrictEqual,
  fail,
  match,
  notDeepStrictEqual,
  notStrictEqual,
  ok,
  strictEqual,
  throws,
};