Skip to content

Commit 64f9adc

Browse files
RobotMermaidgibfahn
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 43d3c00 commit 64f9adc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

‎test/parallel/test-util-inherits.js‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
require('../common');
44
constassert=require('assert');
55
constinherits=require('util').inherits;
6+
consterrCheck=
7+
newRegExp('^TypeError: The super constructor to "inherits" must not be '+
8+
'null or undefined$');
9+
610

711
// super constructor
812
functionA(){
@@ -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:Thesuperconstructorto"inherits"musthaveaprototype$/);
85+
assert.throws(function(){
86+
inherits(A,null);
87+
},errCheck);
88+
assert.throws(function(){
89+
inherits(null,A);
90+
},/^TypeError:Theconstructorto"inherits"mustnotbenullorundefined$/);

0 commit comments

Comments
(0)