Skip to content

Commit 76ab347

Browse files
RobotMermaidevanlucas
authored andcommitted
test: cleanup test-util-inherits.js
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]>
1 parent 93b12a5 commit 76ab347

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test/parallel/test-util-inherits.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
require('../common');
44
const assert = require('assert');
55
const inherits = require('util').inherits;
6+
const errCheck =
7+
new RegExp('^TypeError: The super constructor to "inherits" must not be ' +
8+
'null or undefined$');
9+
610

711
// super constructor
812
function A() {
@@ -75,6 +79,12 @@ assert.strictEqual(e.e(), 'e');
7579
assert.strictEqual(e.constructor, E);
7680

7781
// should throw with invalid arguments
78-
assert.throws(function() { inherits(A, {}); }, TypeError);
79-
assert.throws(function() { inherits(A, null); }, TypeError);
80-
assert.throws(function() { inherits(null, A); }, TypeError);
82+
assert.throws(function() {
83+
inherits(A, {});
84+
}, /^TypeError: The super constructor to "inherits" must have a prototype$/);
85+
assert.throws(function() {
86+
inherits(A, null);
87+
}, errCheck);
88+
assert.throws(function() {
89+
inherits(null, A);
90+
}, /^TypeError: The constructor to "inherits" must not be null or undefined$/);

0 commit comments

Comments
 (0)