assert: support arrow functions in .throws()
authorBen Noordhuis <info@bnoordhuis.nl>
Thu, 8 Oct 2015 10:25:03 +0000 (12:25 +0200)
committerJames M Snell <jasnell@gmail.com>
Sat, 10 Oct 2015 17:49:54 +0000 (10:49 -0700)
commit8383c4fe00e05bb139a3315eefe08b8d1020dfbd
treee7fd0294abf34cabd0d9ccdb2fe5bf995de7cdae
parentf0f8afd8795ae6e86129ab5ad1b15b9069454db4
assert: support arrow functions in .throws()

`x instanceof f` where f is an arrow function throws a (spec-conforming)
"Function has non-object prototype 'undefined' in instanceof check"
exception.

Add a workaround so that it's possible to pass arrow functions as the
second argument to assert.throws().  The try/catch block is a little
jarring but swapping around the clauses in the if statements changes
the semantics too much.

Fixes: https://github.com/nodejs/node/issues/3275
PR-URL: https://github.com/nodejs/node/pull/3276
Reviewed-By: Michaƫl Zasso <mic.besace@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
lib/assert.js
test/parallel/test-assert.js