Skip to content

Commit

Permalink
test: cleanup test-util-inherits.js
Browse files Browse the repository at this point in the history
Replaced constructor with regular expression for assert.throw().

PR-URL: #12602
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
RobotMermaid authored and evanlucas committed May 1, 2017
1 parent 6836785 commit 3c2f578
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions test/parallel/test-util-inherits.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
require('../common');
const assert = require('assert');
const inherits = require('util').inherits;
const errCheck =
new RegExp('^TypeError: The super constructor to "inherits" must not be ' +
'null or undefined$');


// super constructor
function A() {
Expand Down Expand Up @@ -75,6 +79,12 @@ assert.strictEqual(e.e(), 'e');
assert.strictEqual(e.constructor, E);

// should throw with invalid arguments
assert.throws(function() { inherits(A, {}); }, TypeError);
assert.throws(function() { inherits(A, null); }, TypeError);
assert.throws(function() { inherits(null, A); }, TypeError);
assert.throws(function() {
inherits(A, {});
}, /^TypeError: The super constructor to "inherits" must have a prototype$/);
assert.throws(function() {
inherits(A, null);
}, errCheck);
assert.throws(function() {
inherits(null, A);
}, /^TypeError: The constructor to "inherits" must not be null or undefined$/);

0 comments on commit 3c2f578

Please sign in to comment.