Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 64f9adc

Browse filesBrowse 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 <santiago.gimeno@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 43d3c00 commit 64f9adc
Copy full SHA for 64f9adc

File tree

Expand file treeCollapse file tree

1 file changed

+13
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-3
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-util-inherits.js
+13-3Lines changed: 13 additions & 3 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.