Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Fix throws TypeError when passing an arrow function #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ext/_assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function expectedException(actual, expected) {

if (Object.prototype.toString.call(expected) == "[object RegExp]") {
return expected.test(actual);
} else if (actual instanceof expected) {
} else if (expected.prototype && actual instanceof expected) {
return true;
} else if (expected.call({}, actual) === true) {
return true;
Expand Down
3 changes: 3 additions & 0 deletions test/ext/assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ describe("assert", function() {
);
threw = false;

// if passing a arrow function, catch all
assert.throws(makeBlock(thrower, TypeError), () => true);

// doesNotThrow should pass through all errors
try {
assert.doesNotThrow(makeBlock(thrower, TypeError), assert.AssertionError);
Expand Down