Skip to content

Commit

Permalink
test: remove unneeded common.indirectInstanceOf()
Browse files Browse the repository at this point in the history
PR-URL: #5149
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
Trott authored and rvagg committed Feb 15, 2016
1 parent 6340974 commit 2c2cb67
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
13 changes: 0 additions & 13 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,6 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
});
});

function protoCtrChain(o) {
var result = [];
for (; o; o = Object.getPrototypeOf(o)) { result.push(o.constructor); }
return result.join();
}

exports.indirectInstanceOf = function(obj, cls) {
if (obj instanceof cls) { return true; }
var clsChain = protoCtrChain(cls.prototype);
var objChain = protoCtrChain(obj);
return objChain.slice(-clsChain.length) === clsChain;
};


exports.ddCommand = function(filename, kilobytes) {
if (exports.isWindows) {
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
var common = require('../common');
require('../common');
var assert = require('assert');
var a = require('assert');

Expand All @@ -10,7 +10,7 @@ function makeBlock(f) {
};
}

assert.ok(common.indirectInstanceOf(a.AssertionError.prototype, Error),
assert.ok(a.AssertionError.prototype instanceof Error,
'a.AssertionError instanceof Error');

assert.throws(makeBlock(a, false), a.AssertionError, 'ok(false)');
Expand Down
28 changes: 14 additions & 14 deletions test/sequential/test-module-loading.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
var common = require('../common');
require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
Expand Down Expand Up @@ -33,25 +33,25 @@ var d4 = require('../fixtures/b/d');

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

assert.equal(true, common.indirectInstanceOf(a.A, Function));
assert.ok(a.A instanceof Function);
assert.equal('A', a.A());

assert.equal(true, common.indirectInstanceOf(a.C, Function));
assert.ok(a.C instanceof Function);
assert.equal('C', a.C());

assert.equal(true, common.indirectInstanceOf(a.D, Function));
assert.ok(a.D instanceof Function);
assert.equal('D', a.D());

assert.equal(true, common.indirectInstanceOf(d.D, Function));
assert.ok(d.D instanceof Function);
assert.equal('D', d.D());

assert.equal(true, common.indirectInstanceOf(d2.D, Function));
assert.ok(d2.D instanceof Function);
assert.equal('D', d2.D());

assert.equal(true, common.indirectInstanceOf(d3.D, Function));
assert.ok(d3.D instanceof Function);
assert.equal('D', d3.D());

assert.equal(true, common.indirectInstanceOf(d4.D, Function));
assert.ok(d4.D instanceof Function);
assert.equal('D', d4.D());

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

Expand Down Expand Up @@ -255,19 +255,19 @@ assert.throws(function() {
}, 'missing path');

process.on('exit', function() {
assert.ok(common.indirectInstanceOf(a.A, Function));
assert.ok(a.A instanceof Function);
assert.equal('A done', a.A());

assert.ok(common.indirectInstanceOf(a.C, Function));
assert.ok(a.C instanceof Function);
assert.equal('C done', a.C());

assert.ok(common.indirectInstanceOf(a.D, Function));
assert.ok(a.D instanceof Function);
assert.equal('D done', a.D());

assert.ok(common.indirectInstanceOf(d.D, Function));
assert.ok(d.D instanceof Function);
assert.equal('D done', d.D());

assert.ok(common.indirectInstanceOf(d2.D, Function));
assert.ok(d2.D instanceof Function);
assert.equal('D done', d2.D());

assert.equal(true, errorThrown);
Expand Down

0 comments on commit 2c2cb67

Please sign in to comment.