Skip to content

Commit 1917139

Browse files
gibfahnitaloacasas
authored andcommitted
test: s/assert.equal/assert.strictEqual/
Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: nodejs#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 a73ea44 commit 1917139

File tree

332 files changed

+1710
-1671
lines changed

Some content is hidden

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

332 files changed

+1710
-1671
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
@@ -353,9 +353,9 @@ try {
353353
threw = true;
354354
assert.ok(e instanceof TypeError, 'type');
355355
}
356-
assert.equal(true, threw,
357-
'a.throws with an explicit error is eating extra errors',
358-
a.AssertionError);
356+
assert.strictEqual(true, threw,
357+
'a.throws with an explicit error is eating extra errors',
358+
a.AssertionError);
359359
threw = false;
360360

361361
// doesNotThrow should pass through all errors
@@ -365,8 +365,8 @@ try {
365365
threw = true;
366366
assert.ok(e instanceof TypeError);
367367
}
368-
assert.equal(true, threw,
369-
'a.doesNotThrow with an explicit error is eating extra errors');
368+
assert.strictEqual(true, threw, 'a.doesNotThrow with an explicit error is ' +
369+
'eating extra errors');
370370

371371
// key difference is that throwing our correct error makes an assertion error
372372
try {
@@ -375,8 +375,8 @@ try {
375375
threw = true;
376376
assert.ok(e instanceof a.AssertionError);
377377
}
378-
assert.equal(true, threw,
379-
'a.doesNotThrow is not catching type matching errors');
378+
assert.strictEqual(true, threw,
379+
'a.doesNotThrow is not catching type matching errors');
380380

381381
assert.throws(function() { assert.ifError(new Error('test error')); });
382382
assert.doesNotThrow(function() { assert.ifError(null); });
@@ -481,10 +481,10 @@ circular.x = circular;
481481

482482
function testAssertionMessage(actual, expected) {
483483
try {
484-
assert.equal(actual, '');
484+
assert.strictEqual(actual, '');
485485
} catch (e) {
486-
assert.equal(e.toString(),
487-
['AssertionError:', expected, '==', '\'\''].join(' '));
486+
assert.strictEqual(e.toString(),
487+
['AssertionError:', expected, '===', '\'\''].join(' '));
488488
assert.ok(e.generatedMessage, 'Message not marked as generated');
489489
}
490490
}
@@ -519,24 +519,24 @@ try {
519519
});
520520
} catch (e) {
521521
threw = true;
522-
assert.equal(e.message, 'Missing expected exception..');
522+
assert.strictEqual(e.message, 'Missing expected exception..');
523523
}
524524
assert.ok(threw);
525525

526526
// #5292
527527
try {
528-
assert.equal(1, 2);
528+
assert.strictEqual(1, 2);
529529
} catch (e) {
530-
assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2');
530+
assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: 1 === 2');
531531
assert.ok(e.generatedMessage, 'Message not marked as generated');
532532
}
533533

534534
try {
535-
assert.equal(1, 2, 'oh no');
535+
assert.strictEqual(1, 2, 'oh no');
536536
} catch (e) {
537-
assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no');
538-
assert.equal(e.generatedMessage, false,
539-
'Message incorrectly marked as generated');
537+
assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: oh no');
538+
assert.strictEqual(e.generatedMessage, false,
539+
'Message incorrectly marked as generated');
540540
}
541541

542542
// Verify that throws() and doesNotThrow() throw on non-function block
@@ -547,8 +547,8 @@ function testBlockTypeError(method, block) {
547547
method(block);
548548
threw = false;
549549
} catch (e) {
550-
assert.equal(e.toString(),
551-
'TypeError: "block" argument must be a function');
550+
assert.strictEqual(e.toString(),
551+
'TypeError: "block" argument must be a function');
552552
}
553553

554554
assert.ok(threw);

0 commit comments

Comments
 (0)