Skip to content

Commit

Permalink
test: verify isNativeError accepts internal errors
Browse files Browse the repository at this point in the history
This commit verifies that Node's internal errors are recognized
by V8's IsNativeError(), which is exposed in Node as
process.binding('util').isNativeError().

PR-URL: #13965
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
cjihrig authored and addaleax committed Jul 18, 2017
1 parent 4bb1a3a commit f7383eb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/parallel/test-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
// Flags: --expose-internals
const common = require('../common');
const assert = require('assert');
const util = require('util');
const errors = require('internal/errors');
const binding = process.binding('util');
const context = require('vm').runInNewContext;

Expand Down Expand Up @@ -167,4 +169,8 @@ util.error('test');
assert.strictEqual(binding.isNativeError([]), false);
assert.strictEqual(binding.isNativeError(Object.create(Error.prototype)),
false);
assert.strictEqual(
binding.isNativeError(new errors.Error('ERR_IPC_CHANNEL_CLOSED')),
true
);
}

0 comments on commit f7383eb

Please sign in to comment.