Skip to content

Commit 2c2cb67

Browse files
Trottrvagg
authored andcommitted
test: remove unneeded common.indirectInstanceOf()
PR-URL: #5149 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 6340974 commit 2c2cb67

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed

test/common.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,6 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
188188
});
189189
});
190190

191-
function protoCtrChain(o) {
192-
var result = [];
193-
for (; o; o = Object.getPrototypeOf(o)) { result.push(o.constructor); }
194-
return result.join();
195-
}
196-
197-
exports.indirectInstanceOf = function(obj, cls) {
198-
if (obj instanceof cls) { return true; }
199-
var clsChain = protoCtrChain(cls.prototype);
200-
var objChain = protoCtrChain(obj);
201-
return objChain.slice(-clsChain.length) === clsChain;
202-
};
203-
204191

205192
exports.ddCommand = function(filename, kilobytes) {
206193
if (exports.isWindows) {

test/parallel/test-assert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
var common = require('../common');
2+
require('../common');
33
var assert = require('assert');
44
var a = require('assert');
55

@@ -10,7 +10,7 @@ function makeBlock(f) {
1010
};
1111
}
1212

13-
assert.ok(common.indirectInstanceOf(a.AssertionError.prototype, Error),
13+
assert.ok(a.AssertionError.prototype instanceof Error,
1414
'a.AssertionError instanceof Error');
1515

1616
assert.throws(makeBlock(a, false), a.AssertionError, 'ok(false)');

test/sequential/test-module-loading.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
var common = require('../common');
2+
require('../common');
33
var assert = require('assert');
44
var path = require('path');
55
var fs = require('fs');
@@ -33,25 +33,25 @@ var d4 = require('../fixtures/b/d');
3333

3434
assert.equal(false, false, 'testing the test program.');
3535

36-
assert.equal(true, common.indirectInstanceOf(a.A, Function));
36+
assert.ok(a.A instanceof Function);
3737
assert.equal('A', a.A());
3838

39-
assert.equal(true, common.indirectInstanceOf(a.C, Function));
39+
assert.ok(a.C instanceof Function);
4040
assert.equal('C', a.C());
4141

42-
assert.equal(true, common.indirectInstanceOf(a.D, Function));
42+
assert.ok(a.D instanceof Function);
4343
assert.equal('D', a.D());
4444

45-
assert.equal(true, common.indirectInstanceOf(d.D, Function));
45+
assert.ok(d.D instanceof Function);
4646
assert.equal('D', d.D());
4747

48-
assert.equal(true, common.indirectInstanceOf(d2.D, Function));
48+
assert.ok(d2.D instanceof Function);
4949
assert.equal('D', d2.D());
5050

51-
assert.equal(true, common.indirectInstanceOf(d3.D, Function));
51+
assert.ok(d3.D instanceof Function);
5252
assert.equal('D', d3.D());
5353

54-
assert.equal(true, common.indirectInstanceOf(d4.D, Function));
54+
assert.ok(d4.D instanceof Function);
5555
assert.equal('D', d4.D());
5656

5757
assert.ok((new a.SomeClass()) instanceof c.SomeClass);
@@ -88,7 +88,7 @@ require('../fixtures/node_modules/foo');
8888
console.error('test name clashes');
8989
// this one exists and should import the local module
9090
var my_path = require('../fixtures/path');
91-
assert.ok(common.indirectInstanceOf(my_path.path_func, Function));
91+
assert.ok(my_path.path_func instanceof Function);
9292
// this one does not exist and should throw
9393
assert.throws(function() { require('./utils'); });
9494

@@ -255,19 +255,19 @@ assert.throws(function() {
255255
}, 'missing path');
256256

257257
process.on('exit', function() {
258-
assert.ok(common.indirectInstanceOf(a.A, Function));
258+
assert.ok(a.A instanceof Function);
259259
assert.equal('A done', a.A());
260260

261-
assert.ok(common.indirectInstanceOf(a.C, Function));
261+
assert.ok(a.C instanceof Function);
262262
assert.equal('C done', a.C());
263263

264-
assert.ok(common.indirectInstanceOf(a.D, Function));
264+
assert.ok(a.D instanceof Function);
265265
assert.equal('D done', a.D());
266266

267-
assert.ok(common.indirectInstanceOf(d.D, Function));
267+
assert.ok(d.D instanceof Function);
268268
assert.equal('D done', d.D());
269269

270-
assert.ok(common.indirectInstanceOf(d2.D, Function));
270+
assert.ok(d2.D instanceof Function);
271271
assert.equal('D done', d2.D());
272272

273273
assert.equal(true, errorThrown);

0 commit comments

Comments
 (0)