aboutsummaryrefslogtreecommitdiff
path: root/lib/assert.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2015-12-05 17:29:28 -0800
committerRich Trott <rtrott@gmail.com>2015-12-09 09:05:20 -0800
commitda5cdc2207128e85e978203cdf19dc8d692ca5e1 (patch)
treed7cddfc2d219b05dd29e96eeadde47267703be9b /lib/assert.js
parentdfc8bedbc5a7cc4d35a47e47a56e39d08d0dd279 (diff)
downloadandroid-node-v8-da5cdc2207128e85e978203cdf19dc8d692ca5e1.tar.gz
android-node-v8-da5cdc2207128e85e978203cdf19dc8d692ca5e1.tar.bz2
android-node-v8-da5cdc2207128e85e978203cdf19dc8d692ca5e1.zip
assert: accommodate ES6 classes that extend Error
`assert.throws()` and `assert.doesNotThrow()` blow up with a `TypeError` if used with an ES6 class that extends Error. Fixes: https://github.com/nodejs/node/issues/3188 PR-URL: https://github.com/nodejs/node/pull/4166 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/assert.js')
-rw-r--r--lib/assert.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/assert.js b/lib/assert.js
index f8e4920cf3..09353556f5 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -278,6 +278,10 @@ function expectedException(actual, expected) {
// Ignore. The instanceof check doesn't work for arrow functions.
}
+ if (Error.isPrototypeOf(expected)) {
+ return false;
+ }
+
return expected.call({}, actual) === true;
}