Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: cleanup test-utils-inherits.js #12602

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions test/parallel/test-util-inherits.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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);
}, /^TypeError: The super constructor to "inherits" must not be null or undefined$/); // eslint-disable-line max-len
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long line here. Lines should not be longer than 80 chars

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, I know this inlines the eslint rule, but this can be reworked to avoid that entirely...

const errCheck =
  new RegExp('^TypeError: The super constructor to "inherits" must not be ' +
                      'null or undefined$');
assert.throws(() => inherits(A, null), errCheck);

assert.throws(function() {
inherits(null, A);
}, /^TypeError: The constructor to "inherits" must not be null or undefined$/);