Skip to content

Commit 8c634d7

Browse files
Trottevanlucas
authored andcommitted
test: favor strictEqual() in addon test
Replace `assert.equal()` with `assert.strictEqual()` throughout `addon/make-callback-recurse/test.js`. PR-URL: #6704 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 1389a4f commit 8c634d7

File tree

1 file changed

+34
-35
lines changed
  • test/addons/make-callback-recurse

1 file changed

+34
-35
lines changed

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

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,50 @@ assert.throws(function() {
2424
// TODO(trevnorris): Is there a way to verify this is being run during
2525
// bootstrap?
2626
(function verifyExecutionOrder(arg) {
27-
const results_arr = [];
27+
const results = [];
2828

2929
// Processing of the MicrotaskQueue is manually handled by node. They are not
3030
// processed until after the nextTickQueue has been processed.
3131
Promise.resolve(1).then(common.mustCall(function() {
32-
results_arr.push(7);
32+
results.push(7);
3333
}));
3434

3535
// The nextTick should run after all immediately invoked calls.
3636
process.nextTick(common.mustCall(function() {
37-
results_arr.push(3);
37+
results.push(3);
3838

3939
// Run same test again but while processing the nextTickQueue to make sure
4040
// the following MakeCallback call breaks in the middle of processing the
4141
// queue and allows the script to run normally.
4242
process.nextTick(common.mustCall(function() {
43-
results_arr.push(6);
43+
results.push(6);
4444
}));
4545

4646
makeCallback({}, common.mustCall(function() {
47-
results_arr.push(4);
47+
results.push(4);
4848
}));
4949

50-
results_arr.push(5);
50+
results.push(5);
5151
}));
5252

53-
results_arr.push(0);
53+
results.push(0);
5454

5555
// MakeCallback is calling the function immediately, but should then detect
5656
// that a script is already in the middle of execution and return before
5757
// either the nextTickQueue or MicrotaskQueue are processed.
5858
makeCallback({}, common.mustCall(function() {
59-
results_arr.push(1);
59+
results.push(1);
6060
}));
6161

6262
// This should run before either the nextTickQueue or MicrotaskQueue are
6363
// processed. Previously MakeCallback would not detect this circumstance
6464
// and process them immediately.
65-
results_arr.push(2);
65+
results.push(2);
6666

6767
setImmediate(common.mustCall(function() {
68-
for (var i = 0; i < results_arr.length; i++) {
69-
assert.equal(results_arr[i],
70-
i,
71-
`verifyExecutionOrder(${arg}) results: ${results_arr}`);
68+
for (var i = 0; i < results.length; i++) {
69+
assert.strictEqual(results[i], i,
70+
`verifyExecutionOrder(${arg}) results: ${results}`);
7271
}
7372
if (arg === 1) {
7473
// The tests are first run on bootstrap during LoadEnvironment() in
@@ -102,16 +101,16 @@ function checkDomains() {
102101
const d2 = domain.create();
103102
const d3 = domain.create();
104103

105-
makeCallback({ domain: d1 }, common.mustCall(function() {
106-
assert.equal(d1, process.domain);
107-
makeCallback({ domain: d2 }, common.mustCall(function() {
108-
assert.equal(d2, process.domain);
109-
makeCallback({ domain: d3 }, common.mustCall(function() {
110-
assert.equal(d3, process.domain);
104+
makeCallback({domain: d1}, common.mustCall(function() {
105+
assert.strictEqual(d1, process.domain);
106+
makeCallback({domain: d2}, common.mustCall(function() {
107+
assert.strictEqual(d2, process.domain);
108+
makeCallback({domain: d3}, common.mustCall(function() {
109+
assert.strictEqual(d3, process.domain);
111110
}));
112-
assert.equal(d2, process.domain);
111+
assert.strictEqual(d2, process.domain);
113112
}));
114-
assert.equal(d1, process.domain);
113+
assert.strictEqual(d1, process.domain);
115114
}));
116115
}));
117116

@@ -120,16 +119,16 @@ function checkDomains() {
120119
const d2 = domain.create();
121120
const d3 = domain.create();
122121

123-
makeCallback({ domain: d1 }, common.mustCall(function() {
124-
assert.equal(d1, process.domain);
125-
makeCallback({ domain: d2 }, common.mustCall(function() {
126-
assert.equal(d2, process.domain);
127-
makeCallback({ domain: d3 }, common.mustCall(function() {
128-
assert.equal(d3, process.domain);
122+
makeCallback({domain: d1}, common.mustCall(function() {
123+
assert.strictEqual(d1, process.domain);
124+
makeCallback({domain: d2}, common.mustCall(function() {
125+
assert.strictEqual(d2, process.domain);
126+
makeCallback({domain: d3}, common.mustCall(function() {
127+
assert.strictEqual(d3, process.domain);
129128
}));
130-
assert.equal(d2, process.domain);
129+
assert.strictEqual(d2, process.domain);
131130
}));
132-
assert.equal(d1, process.domain);
131+
assert.strictEqual(d1, process.domain);
133132
}));
134133
}), 1);
135134

@@ -138,9 +137,9 @@ function checkDomains() {
138137
process.nextTick(common.mustCall(function() {
139138
const d = domain.create();
140139
d.on('error', common.mustCall(function(e) {
141-
assert.equal(e.message, 'throw from domain 3');
140+
assert.strictEqual(e.message, 'throw from domain 3');
142141
}));
143-
makeCallback({ domain: d }, function() {
142+
makeCallback({domain: d}, function() {
144143
throw new Error('throw from domain 3');
145144
});
146145
throw new Error('UNREACHABLE');
@@ -149,9 +148,9 @@ function checkDomains() {
149148
setImmediate(common.mustCall(function() {
150149
const d = domain.create();
151150
d.on('error', common.mustCall(function(e) {
152-
assert.equal(e.message, 'throw from domain 2');
151+
assert.strictEqual(e.message, 'throw from domain 2');
153152
}));
154-
makeCallback({ domain: d }, function() {
153+
makeCallback({domain: d}, function() {
155154
throw new Error('throw from domain 2');
156155
});
157156
throw new Error('UNREACHABLE');
@@ -160,9 +159,9 @@ function checkDomains() {
160159
setTimeout(common.mustCall(function() {
161160
const d = domain.create();
162161
d.on('error', common.mustCall(function(e) {
163-
assert.equal(e.message, 'throw from domain 1');
162+
assert.strictEqual(e.message, 'throw from domain 1');
164163
}));
165-
makeCallback({ domain: d }, function() {
164+
makeCallback({domain: d}, function() {
166165
throw new Error('throw from domain 1');
167166
});
168167
throw new Error('UNREACHABLE');

0 commit comments

Comments
 (0)