mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
parent
6a0e32dc35
commit
be65b2b0f6
2 changed files with 14 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue