blob: 1d0cb6ca946aa2f7684d2666159869e3174fded1 (
plain) (
blame)
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
|
function assert(x, msg) {
const mymsg = msg ? ": " + msg : "";
if (!x)
throw new TypeError("Assertion failed" + mymsg);
}
function assertThrows(expr, error) {
let me;
try {
eval(expr);
} catch (e) {
if (e instanceof error)
return;
me = e;
}
throw new TypeError("Assertion failed: expected " + error + ", got " + me + " for expression: " + expr);
}
function assertEquals(a, b) {
assert(a === b, "Expected " + b + " but got " + a);
}
function assertNotEquals(a, b) {
assert(a !== b, "Expected " + b + " to have some different value");
}
function assertInstanceof(a, b) {
assert(a instanceof b, a + " not an instance of " + b);
}
|