1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00
Original: c1c18c9469
This commit is contained in:
James Garbutt 2019-01-26 11:51:19 +00:00 committed by Ryan Dahl
parent 6a0e32dc35
commit be65b2b0f6
2 changed files with 14 additions and 0 deletions

View file

@ -74,6 +74,13 @@ const assertions = {
}
},
/**
* Forcefully throws a failed assertion
*/
fail(msg?: string): void {
assert(false, `Failed assertion${msg ? `: ${msg}` : "."}`);
},
/** Executes a function, expecting it to throw. If it does not, then it
* throws. An error class and a string that should be included in the
* error message can also be asserted.

View file

@ -31,6 +31,13 @@ test(function testingAssertEqual() {
assert(assertEqual === assert.equal);
});
test(function testingAssertFail() {
let didThrow = false;
assert.throws(assert.fail, Error, "Failed assertion.");
assert.throws(() => { assert.fail("foo"); }, Error, "Failed assertion: foo");
});
test(function testingAssertEqualActualUncoercable() {
let didThrow = false;
const a = Object.create(null);