Skip to content

Commit 3d2aef3

Browse files
committed
test: s/assert.equal/assert.strictEqual/
Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: #10698 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Teddy Katz <[email protected]>
1 parent 81fef91 commit 3d2aef3

File tree

331 files changed

+1706
-1667
lines changed

Some content is hidden

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

331 files changed

+1706
-1667
lines changed

test/disabled/test-fs-largefile.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ const 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

+1-1
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

+7-7
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

+5-5
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ assert.notStrictEqual(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

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const assert = require('assert');
44

55
const 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

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/node_modules/foo.js

+1-1
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

+2-2
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

+1-1
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

+1-1
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

+19-19
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ try {
333333
threw = true;
334334
assert.ok(e instanceof TypeError, 'type');
335335
}
336-
assert.equal(true, threw,
337-
'a.throws with an explicit error is eating extra errors',
338-
a.AssertionError);
336+
assert.strictEqual(true, threw,
337+
'a.throws with an explicit error is eating extra errors',
338+
a.AssertionError);
339339
threw = false;
340340

341341
// doesNotThrow should pass through all errors
@@ -345,8 +345,8 @@ try {
345345
threw = true;
346346
assert.ok(e instanceof TypeError);
347347
}
348-
assert.equal(true, threw,
349-
'a.doesNotThrow with an explicit error is eating extra errors');
348+
assert.strictEqual(true, threw, 'a.doesNotThrow with an explicit error is ' +
349+
'eating extra errors');
350350

351351
// key difference is that throwing our correct error makes an assertion error
352352
try {
@@ -355,8 +355,8 @@ try {
355355
threw = true;
356356
assert.ok(e instanceof a.AssertionError);
357357
}
358-
assert.equal(true, threw,
359-
'a.doesNotThrow is not catching type matching errors');
358+
assert.strictEqual(true, threw,
359+
'a.doesNotThrow is not catching type matching errors');
360360

361361
assert.throws(function() { assert.ifError(new Error('test error')); });
362362
assert.doesNotThrow(function() { assert.ifError(null); });
@@ -461,10 +461,10 @@ circular.x = circular;
461461

462462
function testAssertionMessage(actual, expected) {
463463
try {
464-
assert.equal(actual, '');
464+
assert.strictEqual(actual, '');
465465
} catch (e) {
466-
assert.equal(e.toString(),
467-
['AssertionError:', expected, '==', '\'\''].join(' '));
466+
assert.strictEqual(e.toString(),
467+
['AssertionError:', expected, '===', '\'\''].join(' '));
468468
assert.ok(e.generatedMessage, 'Message not marked as generated');
469469
}
470470
}
@@ -499,24 +499,24 @@ try {
499499
});
500500
} catch (e) {
501501
threw = true;
502-
assert.equal(e.message, 'Missing expected exception..');
502+
assert.strictEqual(e.message, 'Missing expected exception..');
503503
}
504504
assert.ok(threw);
505505

506506
// #5292
507507
try {
508-
assert.equal(1, 2);
508+
assert.strictEqual(1, 2);
509509
} catch (e) {
510-
assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2');
510+
assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: 1 === 2');
511511
assert.ok(e.generatedMessage, 'Message not marked as generated');
512512
}
513513

514514
try {
515-
assert.equal(1, 2, 'oh no');
515+
assert.strictEqual(1, 2, 'oh no');
516516
} catch (e) {
517-
assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no');
518-
assert.equal(e.generatedMessage, false,
519-
'Message incorrectly marked as generated');
517+
assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: oh no');
518+
assert.strictEqual(e.generatedMessage, false,
519+
'Message incorrectly marked as generated');
520520
}
521521

522522
// Verify that throws() and doesNotThrow() throw on non-function block
@@ -527,8 +527,8 @@ function testBlockTypeError(method, block) {
527527
method(block);
528528
threw = false;
529529
} catch (e) {
530-
assert.equal(e.toString(),
531-
'TypeError: "block" argument must be a function');
530+
assert.strictEqual(e.toString(),
531+
'TypeError: "block" argument must be a function');
532532
}
533533

534534
assert.ok(threw);

0 commit comments

Comments
 (0)