Skip to content

Commit 6f85c81

Browse files
gibfahnMylesBorins
authored andcommitted
test: s/assert.equal/assert.strictEqual/
Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. Backport-PR-URL: #11795 PR-URL: #10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
1 parent afea1d0 commit 6f85c81

File tree

365 files changed

+2205
-2147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+2205
-2147
lines changed

test/addons/load-long-path/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ fs.writeFileSync(addonDestinationPath, contents);
3333

3434
// Attempt to load at long path destination
3535
const addon = require(addonDestinationPath);
36-
assert.notEqual(addon, null);
36+
assert.notStrictEqual(addon, null);
3737
assert.strictEqual(addon.hello(), 'world');

test/disabled/test-fs-largefile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ var path = require('path'),
99
message = 'Large File';
1010

1111
fs.truncateSync(fd, offset);
12-
assert.equal(fs.statSync(filepath).size, offset);
12+
assert.strictEqual(fs.statSync(filepath).size, offset);
1313
var writeBuf = Buffer.from(message);
1414
fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset);
1515
var readBuf = Buffer.allocUnsafe(writeBuf.length);
1616
fs.readSync(fd, readBuf, 0, readBuf.length, offset);
17-
assert.equal(readBuf.toString(), message);
17+
assert.strictEqual(readBuf.toString(), message);
1818
fs.readSync(fd, readBuf, 0, 1, 0);
19-
assert.equal(readBuf[0], 0);
19+
assert.strictEqual(readBuf[0], 0);
2020

2121
var exceptionRaised = false;
2222
try {
2323
fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001);
2424
} catch (err) {
2525
console.log(err);
2626
exceptionRaised = true;
27-
assert.equal(err.message, 'Not an integer');
27+
assert.strictEqual(err.message, 'Not an integer');
2828
}
2929
assert.ok(exceptionRaised);
3030
fs.close(fd);

test/disabled/test-http-abort-stream-end.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ s.listen(common.PORT, function() {
3636

3737
process.on('exit', function() {
3838
assert(aborted);
39-
assert.equal(size, maxSize);
39+
assert.strictEqual(size, maxSize);
4040
console.log('ok');
4141
});

test/disabled/test-readline.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ var rl = readlineFakeStream();
4949
var written_bytes_length, refreshed;
5050

5151
rl.write('foo');
52-
assert.equal(3, rl.cursor);
52+
assert.strictEqual(3, rl.cursor);
5353
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) {
5454
rl.write.apply(rl, key.home);
55-
assert.equal(0, rl.cursor);
55+
assert.strictEqual(0, rl.cursor);
5656
rl.write.apply(rl, key.end);
57-
assert.equal(3, rl.cursor);
57+
assert.strictEqual(3, rl.cursor);
5858
});
5959

6060
rl = readlineFakeStream();
@@ -76,9 +76,9 @@ rl.write.apply(rl, key.xterm.home);
7676
].forEach(function(action) {
7777
written_bytes_length = rl.written_bytes.length;
7878
rl.write.apply(rl, action.key);
79-
assert.equal(action.cursor, rl.cursor);
79+
assert.strictEqual(action.cursor, rl.cursor);
8080
refreshed = written_bytes_length !== rl.written_bytes.length;
81-
assert.equal(true, refreshed);
81+
assert.strictEqual(true, refreshed);
8282
});
8383

8484
rl = readlineFakeStream();
@@ -93,7 +93,7 @@ rl.write.apply(rl, key.xterm.home);
9393
''
9494
].forEach(function(expectedLine) {
9595
rl.write.apply(rl, key.xterm.metad);
96-
assert.equal(0, rl.cursor);
97-
assert.equal(expectedLine, rl.line);
96+
assert.strictEqual(0, rl.cursor);
97+
assert.strictEqual(expectedLine, rl.line);
9898
});
9999
rl.close();

test/disabled/test-sendfd.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var logChild = function(d) {
6363
// validate any data sent back by the child. We send the write end of the
6464
// pipe to the child and close it off in our process.
6565
var pipeFDs = netBinding.pipe();
66-
assert.equal(pipeFDs.length, 2);
66+
assert.strictEqual(pipeFDs.length, 2);
6767

6868
var seenOrdinals = [];
6969

@@ -72,8 +72,8 @@ pipeReadStream.on('data', function(data) {
7272
data.toString('utf8').trim().split('\n').forEach(function(d) {
7373
var rd = JSON.parse(d);
7474

75-
assert.equal(rd.pid, cpp);
76-
assert.equal(seenOrdinals.indexOf(rd.ord), -1);
75+
assert.strictEqual(rd.pid, cpp);
76+
assert.strictEqual(seenOrdinals.indexOf(rd.ord), -1);
7777

7878
seenOrdinals.unshift(rd.ord);
7979
});
@@ -119,8 +119,8 @@ cp.on('exit', function(code, signal) {
119119
srv.close();
120120
// fs.unlinkSync(SOCK_PATH);
121121

122-
assert.equal(code, 0);
123-
assert.equal(seenOrdinals.length, 2);
122+
assert.strictEqual(code, 0);
123+
assert.strictEqual(seenOrdinals.length, 2);
124124
});
125125

126126
// vim:ts=2 sw=2 et

test/disabled/test-setuidgid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ assert.notEqual(newuid, olduid, 'uids expected to be different');
1616
try {
1717
process.setuid('nobody1234');
1818
} catch (e) {
19-
assert.equal(e.message,
19+
assert.strictEqual(e.message,
2020
'failed to resolve group',
2121
'unexpected error message'
2222
);

test/fixtures/GH-892-request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var options = {
1616
};
1717

1818
var req = https.request(options, function(res) {
19-
assert.equal(200, res.statusCode);
19+
assert.strictEqual(200, res.statusCode);
2020
gotResponse = true;
2121
console.error('DONE');
2222
res.resume();

test/fixtures/b/c.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var assert = require('assert');
44

55
var package = require('./package');
66

7-
assert.equal('world', package.hello);
7+
assert.strictEqual('world', package.hello);
88

99
console.error('load fixtures/b/c.js');
1010

test/fixtures/node_modules/baz/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/node_modules/foo.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/internet/test-dns-txt-sigsegv.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ const assert = require('assert');
44
const dns = require('dns');
55

66
dns.resolveTxt('www.microsoft.com', function(err, records) {
7-
assert.equal(err, null);
8-
assert.equal(records.length, 0);
7+
assert.strictEqual(err, null);
8+
assert.strictEqual(records.length, 0);
99
});

test/message/error_exit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ process.on('exit', function(code) {
66
console.error('Exiting with code=%d', code);
77
});
88

9-
assert.equal(1, 2);
9+
assert.strictEqual(1, 2);

test/message/error_exit.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Exiting with code=1
33
assert.js:*
44
throw new assert.AssertionError({
55
^
6-
AssertionError: 1 == 2
6+
AssertionError: 1 === 2
77
at Object.<anonymous> (*test*message*error_exit.js:*:*)
88
at Module._compile (module.js:*:*)
99
at Object.Module._extensions..js (module.js:*:*)

test/parallel/test-assert.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,9 @@ try {
355355
threw = true;
356356
assert.ok(e instanceof TypeError, 'type');
357357
}
358-
assert.equal(true, threw,
359-
'a.throws with an explicit error is eating extra errors',
360-
a.AssertionError);
358+
assert.strictEqual(true, threw,
359+
'a.throws with an explicit error is eating extra errors',
360+
a.AssertionError);
361361
threw = false;
362362

363363
// doesNotThrow should pass through all errors
@@ -367,8 +367,8 @@ try {
367367
threw = true;
368368
assert.ok(e instanceof TypeError);
369369
}
370-
assert.equal(true, threw,
371-
'a.doesNotThrow with an explicit error is eating extra errors');
370+
assert.strictEqual(true, threw, 'a.doesNotThrow with an explicit error is ' +
371+
'eating extra errors');
372372

373373
// key difference is that throwing our correct error makes an assertion error
374374
try {
@@ -377,8 +377,8 @@ try {
377377
threw = true;
378378
assert.ok(e instanceof a.AssertionError);
379379
}
380-
assert.equal(true, threw,
381-
'a.doesNotThrow is not catching type matching errors');
380+
assert.strictEqual(true, threw,
381+
'a.doesNotThrow is not catching type matching errors');
382382

383383
assert.throws(function() { assert.ifError(new Error('test error')); },
384384
/^Error: test error$/);
@@ -484,10 +484,10 @@ circular.x = circular;
484484

485485
function testAssertionMessage(actual, expected) {
486486
try {
487-
assert.equal(actual, '');
487+
assert.strictEqual(actual, '');
488488
} catch (e) {
489-
assert.equal(e.toString(),
490-
['AssertionError:', expected, '==', '\'\''].join(' '));
489+
assert.strictEqual(e.toString(),
490+
['AssertionError:', expected, '===', '\'\''].join(' '));
491491
assert.ok(e.generatedMessage, 'Message not marked as generated');
492492
}
493493
}
@@ -522,24 +522,24 @@ try {
522522
});
523523
} catch (e) {
524524
threw = true;
525-
assert.equal(e.message, 'Missing expected exception..');
525+
assert.strictEqual(e.message, 'Missing expected exception..');
526526
}
527527
assert.ok(threw);
528528

529529
// #5292
530530
try {
531-
assert.equal(1, 2);
531+
assert.strictEqual(1, 2);
532532
} catch (e) {
533-
assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2');
533+
assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: 1 === 2');
534534
assert.ok(e.generatedMessage, 'Message not marked as generated');
535535
}
536536

537537
try {
538-
assert.equal(1, 2, 'oh no');
538+
assert.strictEqual(1, 2, 'oh no');
539539
} catch (e) {
540-
assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no');
541-
assert.equal(e.generatedMessage, false,
542-
'Message incorrectly marked as generated');
540+
assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: oh no');
541+
assert.strictEqual(e.generatedMessage, false,
542+
'Message incorrectly marked as generated');
543543
}
544544

545545
// Verify that throws() and doesNotThrow() throw on non-function block
@@ -550,8 +550,8 @@ function testBlockTypeError(method, block) {
550550
method(block);
551551
threw = false;
552552
} catch (e) {
553-
assert.equal(e.toString(),
554-
'TypeError: "block" argument must be a function');
553+
assert.strictEqual(e.toString(),
554+
'TypeError: "block" argument must be a function');
555555
}
556556

557557
assert.ok(threw);

test/parallel/test-buffer-alloc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ assert.strictEqual('<Buffer 81 a3 66 6f 6f a3 62 61 72>', x.inspect());
742742
Buffer.allocUnsafe(3.3).fill().toString();
743743
// throws bad argument error in commit 43cb4ec
744744
Buffer.alloc(3.3).fill().toString();
745-
assert.equal(Buffer.allocUnsafe(-1).length, 0);
745+
assert.strictEqual(Buffer.allocUnsafe(-1).length, 0);
746746
assert.strictEqual(Buffer.allocUnsafe(NaN).length, 0);
747747
assert.strictEqual(Buffer.allocUnsafe(3.3).length, 3);
748748
assert.strictEqual(Buffer.from({length: 3.3}).length, 3);
@@ -779,7 +779,7 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
779779
'ucs-2',
780780
'utf16le',
781781
'utf-16le' ].forEach(function(enc) {
782-
assert.equal(Buffer.isEncoding(enc), true);
782+
assert.strictEqual(Buffer.isEncoding(enc), true);
783783
});
784784

785785
[ 'utf9',
@@ -794,7 +794,7 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
794794
1,
795795
0,
796796
-1 ].forEach(function(enc) {
797-
assert.equal(Buffer.isEncoding(enc), false);
797+
assert.strictEqual(Buffer.isEncoding(enc), false);
798798
});
799799

800800
// GH-5110

0 commit comments

Comments
 (0)