test: cleanup test-util-inherits.js
Replaced constructor with regular expression for assert.throw(). PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
78e00631dd
commit
2055fd371f
@ -3,6 +3,10 @@
|
|||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const inherits = require('util').inherits;
|
const inherits = require('util').inherits;
|
||||||
|
const errCheck =
|
||||||
|
new RegExp('^TypeError: The super constructor to "inherits" must not be ' +
|
||||||
|
'null or undefined$');
|
||||||
|
|
||||||
|
|
||||||
// super constructor
|
// super constructor
|
||||||
function A() {
|
function A() {
|
||||||
@ -75,6 +79,12 @@ assert.strictEqual(e.e(), 'e');
|
|||||||
assert.strictEqual(e.constructor, E);
|
assert.strictEqual(e.constructor, E);
|
||||||
|
|
||||||
// should throw with invalid arguments
|
// should throw with invalid arguments
|
||||||
assert.throws(function() { inherits(A, {}); }, TypeError);
|
assert.throws(function() {
|
||||||
assert.throws(function() { inherits(A, null); }, TypeError);
|
inherits(A, {});
|
||||||
assert.throws(function() { inherits(null, A); }, TypeError);
|
}, /^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$/);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user