Browse Source

test: favor strictEqual() in addon test

Replace `assert.equal()` with `assert.strictEqual()` throughout
`addon/make-callback-recurse/test.js`.

PR-URL: https://github.com/nodejs/node/pull/6704
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
process-exit-stdio-flushing
Rich Trott 9 years ago
parent
commit
517d1da47c
  1. 69
      test/addons/make-callback-recurse/test.js

69
test/addons/make-callback-recurse/test.js

@ -24,51 +24,50 @@ assert.throws(function() {
// TODO(trevnorris): Is there a way to verify this is being run during // TODO(trevnorris): Is there a way to verify this is being run during
// bootstrap? // bootstrap?
(function verifyExecutionOrder(arg) { (function verifyExecutionOrder(arg) {
const results_arr = []; const results = [];
// Processing of the MicrotaskQueue is manually handled by node. They are not // Processing of the MicrotaskQueue is manually handled by node. They are not
// processed until after the nextTickQueue has been processed. // processed until after the nextTickQueue has been processed.
Promise.resolve(1).then(common.mustCall(function() { Promise.resolve(1).then(common.mustCall(function() {
results_arr.push(7); results.push(7);
})); }));
// The nextTick should run after all immediately invoked calls. // The nextTick should run after all immediately invoked calls.
process.nextTick(common.mustCall(function() { process.nextTick(common.mustCall(function() {
results_arr.push(3); results.push(3);
// Run same test again but while processing the nextTickQueue to make sure // Run same test again but while processing the nextTickQueue to make sure
// the following MakeCallback call breaks in the middle of processing the // the following MakeCallback call breaks in the middle of processing the
// queue and allows the script to run normally. // queue and allows the script to run normally.
process.nextTick(common.mustCall(function() { process.nextTick(common.mustCall(function() {
results_arr.push(6); results.push(6);
})); }));
makeCallback({}, common.mustCall(function() { makeCallback({}, common.mustCall(function() {
results_arr.push(4); results.push(4);
})); }));
results_arr.push(5); results.push(5);
})); }));
results_arr.push(0); results.push(0);
// MakeCallback is calling the function immediately, but should then detect // MakeCallback is calling the function immediately, but should then detect
// that a script is already in the middle of execution and return before // that a script is already in the middle of execution and return before
// either the nextTickQueue or MicrotaskQueue are processed. // either the nextTickQueue or MicrotaskQueue are processed.
makeCallback({}, common.mustCall(function() { makeCallback({}, common.mustCall(function() {
results_arr.push(1); results.push(1);
})); }));
// This should run before either the nextTickQueue or MicrotaskQueue are // This should run before either the nextTickQueue or MicrotaskQueue are
// processed. Previously MakeCallback would not detect this circumstance // processed. Previously MakeCallback would not detect this circumstance
// and process them immediately. // and process them immediately.
results_arr.push(2); results.push(2);
setImmediate(common.mustCall(function() { setImmediate(common.mustCall(function() {
for (var i = 0; i < results_arr.length; i++) { for (var i = 0; i < results.length; i++) {
assert.equal(results_arr[i], assert.strictEqual(results[i], i,
i, `verifyExecutionOrder(${arg}) results: ${results}`);
`verifyExecutionOrder(${arg}) results: ${results_arr}`);
} }
if (arg === 1) { if (arg === 1) {
// The tests are first run on bootstrap during LoadEnvironment() in // The tests are first run on bootstrap during LoadEnvironment() in
@ -102,16 +101,16 @@ function checkDomains() {
const d2 = domain.create(); const d2 = domain.create();
const d3 = domain.create(); const d3 = domain.create();
makeCallback({ domain: d1 }, common.mustCall(function() { makeCallback({domain: d1}, common.mustCall(function() {
assert.equal(d1, process.domain); assert.strictEqual(d1, process.domain);
makeCallback({ domain: d2 }, common.mustCall(function() { makeCallback({domain: d2}, common.mustCall(function() {
assert.equal(d2, process.domain); assert.strictEqual(d2, process.domain);
makeCallback({ domain: d3 }, common.mustCall(function() { makeCallback({domain: d3}, common.mustCall(function() {
assert.equal(d3, process.domain); assert.strictEqual(d3, process.domain);
})); }));
assert.equal(d2, process.domain); assert.strictEqual(d2, process.domain);
})); }));
assert.equal(d1, process.domain); assert.strictEqual(d1, process.domain);
})); }));
})); }));
@ -120,16 +119,16 @@ function checkDomains() {
const d2 = domain.create(); const d2 = domain.create();
const d3 = domain.create(); const d3 = domain.create();
makeCallback({ domain: d1 }, common.mustCall(function() { makeCallback({domain: d1}, common.mustCall(function() {
assert.equal(d1, process.domain); assert.strictEqual(d1, process.domain);
makeCallback({ domain: d2 }, common.mustCall(function() { makeCallback({domain: d2}, common.mustCall(function() {
assert.equal(d2, process.domain); assert.strictEqual(d2, process.domain);
makeCallback({ domain: d3 }, common.mustCall(function() { makeCallback({domain: d3}, common.mustCall(function() {
assert.equal(d3, process.domain); assert.strictEqual(d3, process.domain);
})); }));
assert.equal(d2, process.domain); assert.strictEqual(d2, process.domain);
})); }));
assert.equal(d1, process.domain); assert.strictEqual(d1, process.domain);
})); }));
}), 1); }), 1);
@ -138,9 +137,9 @@ function checkDomains() {
process.nextTick(common.mustCall(function() { process.nextTick(common.mustCall(function() {
const d = domain.create(); const d = domain.create();
d.on('error', common.mustCall(function(e) { d.on('error', common.mustCall(function(e) {
assert.equal(e.message, 'throw from domain 3'); assert.strictEqual(e.message, 'throw from domain 3');
})); }));
makeCallback({ domain: d }, function() { makeCallback({domain: d}, function() {
throw new Error('throw from domain 3'); throw new Error('throw from domain 3');
}); });
throw new Error('UNREACHABLE'); throw new Error('UNREACHABLE');
@ -149,9 +148,9 @@ function checkDomains() {
setImmediate(common.mustCall(function() { setImmediate(common.mustCall(function() {
const d = domain.create(); const d = domain.create();
d.on('error', common.mustCall(function(e) { d.on('error', common.mustCall(function(e) {
assert.equal(e.message, 'throw from domain 2'); assert.strictEqual(e.message, 'throw from domain 2');
})); }));
makeCallback({ domain: d }, function() { makeCallback({domain: d}, function() {
throw new Error('throw from domain 2'); throw new Error('throw from domain 2');
}); });
throw new Error('UNREACHABLE'); throw new Error('UNREACHABLE');
@ -160,9 +159,9 @@ function checkDomains() {
setTimeout(common.mustCall(function() { setTimeout(common.mustCall(function() {
const d = domain.create(); const d = domain.create();
d.on('error', common.mustCall(function(e) { d.on('error', common.mustCall(function(e) {
assert.equal(e.message, 'throw from domain 1'); assert.strictEqual(e.message, 'throw from domain 1');
})); }));
makeCallback({ domain: d }, function() { makeCallback({domain: d}, function() {
throw new Error('throw from domain 1'); throw new Error('throw from domain 1');
}); });
throw new Error('UNREACHABLE'); throw new Error('UNREACHABLE');

Loading…
Cancel
Save