Browse Source

test: remove unneeded common.indirectInstanceOf()

PR-URL: https://github.com/nodejs/node/pull/5149
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
process-exit-stdio-flushing
Rich Trott 9 years ago
parent
commit
25713861c0
  1. 13
      test/common.js
  2. 4
      test/parallel/test-assert.js
  3. 28
      test/sequential/test-module-loading.js

13
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) {

4
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)');

28
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);

Loading…
Cancel
Save