diff --git a/test/common.js b/test/common.js index 152e5e5c6f..b7c64d2852 100644 --- a/test/common.js +++ b/test/common.js @@ -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) { diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 1ab9f8dd1d..2f4b757f4e 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var a = require('assert'); @@ -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)'); diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index 3e4101f8e2..a6f9488f5f 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var path = require('path'); var fs = require('fs'); @@ -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); @@ -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'); }); @@ -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);