Browse Source

test: s/assert.equal/assert.strictEqual/

Use assert.strictEqual instead of assert.equal in tests, manually
convert types where necessary.

PR-URL: https://github.com/nodejs/node/pull/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>
v6
Gibson Fahnestock 8 years ago
parent
commit
3d2aef3979
  1. 8
      test/disabled/test-fs-largefile.js
  2. 2
      test/disabled/test-http-abort-stream-end.js
  3. 14
      test/disabled/test-readline.js
  4. 10
      test/disabled/test-sendfd.js
  5. 2
      test/disabled/test-setuidgid.js
  6. 2
      test/fixtures/GH-892-request.js
  7. 2
      test/fixtures/b/c.js
  8. 4
      test/fixtures/node_modules/baz/index.js
  9. 2
      test/fixtures/node_modules/foo.js
  10. 4
      test/internet/test-dns-txt-sigsegv.js
  11. 2
      test/message/error_exit.js
  12. 2
      test/message/error_exit.out
  13. 28
      test/parallel/test-assert.js
  14. 250
      test/parallel/test-buffer-indexof.js
  15. 2
      test/parallel/test-child-process-fork-net.js
  16. 4
      test/parallel/test-child-process-fork-net2.js
  17. 2
      test/parallel/test-child-process-fork-ref.js
  18. 2
      test/parallel/test-child-process-ipc.js
  19. 2
      test/parallel/test-child-process-set-blocking.js
  20. 2
      test/parallel/test-child-process-spawnsync-env.js
  21. 66
      test/parallel/test-crypto-dh.js
  22. 2
      test/parallel/test-crypto-domains.js
  23. 2
      test/parallel/test-dh-padding.js
  24. 2
      test/parallel/test-domain-nested.js
  25. 7
      test/parallel/test-event-emitter-prepend.js
  26. 2
      test/parallel/test-event-emitter-subclass.js
  27. 4
      test/parallel/test-fs-error-messages.js
  28. 4
      test/parallel/test-fs-mkdir-rmdir.js
  29. 4
      test/parallel/test-fs-mkdir.js
  30. 2
      test/parallel/test-fs-mkdtemp.js
  31. 30
      test/parallel/test-fs-open-flags.js
  32. 2
      test/parallel/test-fs-read-stream.js
  33. 4
      test/parallel/test-fs-read-zero-length.js
  34. 2
      test/parallel/test-fs-readdir-ucs2.js
  35. 2
      test/parallel/test-fs-readdir.js
  36. 4
      test/parallel/test-fs-realpath.js
  37. 14
      test/parallel/test-fs-stat.js
  38. 8
      test/parallel/test-fs-sync-fd-leak.js
  39. 4
      test/parallel/test-fs-watch-enoent.js
  40. 4
      test/parallel/test-fs-watch-stop-async.js
  41. 2
      test/parallel/test-fs-write-stream-change-open.js
  42. 8
      test/parallel/test-fs-write-stream-err.js
  43. 2
      test/parallel/test-fs-write-string-coerce.js
  44. 22
      test/parallel/test-http-abort-queued.js
  45. 6
      test/parallel/test-http-agent-error-on-idle.js
  46. 48
      test/parallel/test-http-agent-keepalive.js
  47. 6
      test/parallel/test-http-agent-maxsockets.js
  48. 2
      test/parallel/test-http-agent.js
  49. 12
      test/parallel/test-http-automatic-headers.js
  50. 4
      test/parallel/test-http-blank-header.js
  51. 6
      test/parallel/test-http-buffer-sanity.js
  52. 2
      test/parallel/test-http-catch-uncaughtexception.js
  53. 2
      test/parallel/test-http-chunk-problem.js
  54. 4
      test/parallel/test-http-chunked.js
  55. 2
      test/parallel/test-http-client-abort.js
  56. 4
      test/parallel/test-http-client-agent.js
  57. 4
      test/parallel/test-http-client-get-url.js
  58. 6
      test/parallel/test-http-client-parse-error.js
  59. 6
      test/parallel/test-http-client-race-2.js
  60. 4
      test/parallel/test-http-client-race.js
  61. 2
      test/parallel/test-http-client-reject-chunked-with-content-length.js
  62. 2
      test/parallel/test-http-client-reject-cr-no-lf.js
  63. 2
      test/parallel/test-http-client-response-domain.js
  64. 2
      test/parallel/test-http-client-upload-buf.js
  65. 2
      test/parallel/test-http-client-upload.js
  66. 2
      test/parallel/test-http-conn-reset.js
  67. 12
      test/parallel/test-http-connect-req-res.js
  68. 2
      test/parallel/test-http-createConnection.js
  69. 2
      test/parallel/test-http-default-encoding.js
  70. 8
      test/parallel/test-http-default-port.js
  71. 4
      test/parallel/test-http-destroyed-socket-write2.js
  72. 2
      test/parallel/test-http-double-content-length.js
  73. 11
      test/parallel/test-http-expect-continue.js
  74. 6
      test/parallel/test-http-expect-handling.js
  75. 4
      test/parallel/test-http-extra-response.js
  76. 2
      test/parallel/test-http-flush-headers.js
  77. 2
      test/parallel/test-http-flush-response-headers.js
  78. 4
      test/parallel/test-http-full-response.js
  79. 6
      test/parallel/test-http-get-pipeline-problem.js
  80. 2
      test/parallel/test-http-header-read.js
  81. 4
      test/parallel/test-http-host-headers.js
  82. 8
      test/parallel/test-http-keep-alive-close-on-header.js
  83. 8
      test/parallel/test-http-keepalive-client.js
  84. 14
      test/parallel/test-http-keepalive-maxsockets.js
  85. 8
      test/parallel/test-http-keepalive-request.js
  86. 2
      test/parallel/test-http-localaddress.js
  87. 2
      test/parallel/test-http-malformed-request.js
  88. 8
      test/parallel/test-http-max-headers-count.js
  89. 2
      test/parallel/test-http-multi-line-headers.js
  90. 4
      test/parallel/test-http-parser-bad-ref.js
  91. 2
      test/parallel/test-http-parser-free.js
  92. 12
      test/parallel/test-http-parser.js
  93. 4
      test/parallel/test-http-pause.js
  94. 2
      test/parallel/test-http-pipeline-regr-2639.js
  95. 2
      test/parallel/test-http-pipeline-regr-3332.js
  96. 12
      test/parallel/test-http-proxy.js
  97. 4
      test/parallel/test-http-remove-header-stays-removed.js
  98. 2
      test/parallel/test-http-request-dont-override-options.js
  99. 2
      test/parallel/test-http-res-write-after-end.js
  100. 4
      test/parallel/test-http-response-multi-content-length.js

8
test/disabled/test-fs-largefile.js

@ -9,14 +9,14 @@ const path = require('path'),
message = 'Large File'; message = 'Large File';
fs.truncateSync(fd, offset); fs.truncateSync(fd, offset);
assert.equal(fs.statSync(filepath).size, offset); assert.strictEqual(fs.statSync(filepath).size, offset);
var writeBuf = Buffer.from(message); var writeBuf = Buffer.from(message);
fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset); fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset);
var readBuf = Buffer.allocUnsafe(writeBuf.length); var readBuf = Buffer.allocUnsafe(writeBuf.length);
fs.readSync(fd, readBuf, 0, readBuf.length, offset); fs.readSync(fd, readBuf, 0, readBuf.length, offset);
assert.equal(readBuf.toString(), message); assert.strictEqual(readBuf.toString(), message);
fs.readSync(fd, readBuf, 0, 1, 0); fs.readSync(fd, readBuf, 0, 1, 0);
assert.equal(readBuf[0], 0); assert.strictEqual(readBuf[0], 0);
var exceptionRaised = false; var exceptionRaised = false;
try { try {
@ -24,7 +24,7 @@ try {
} catch (err) { } catch (err) {
console.log(err); console.log(err);
exceptionRaised = true; exceptionRaised = true;
assert.equal(err.message, 'Not an integer'); assert.strictEqual(err.message, 'Not an integer');
} }
assert.ok(exceptionRaised); assert.ok(exceptionRaised);
fs.close(fd); fs.close(fd);

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

@ -36,6 +36,6 @@ s.listen(common.PORT, function() {
process.on('exit', function() { process.on('exit', function() {
assert(aborted); assert(aborted);
assert.equal(size, maxSize); assert.strictEqual(size, maxSize);
console.log('ok'); console.log('ok');
}); });

14
test/disabled/test-readline.js

@ -49,12 +49,12 @@ var rl = readlineFakeStream();
var written_bytes_length, refreshed; var written_bytes_length, refreshed;
rl.write('foo'); rl.write('foo');
assert.equal(3, rl.cursor); assert.strictEqual(3, rl.cursor);
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) { [key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) {
rl.write.apply(rl, key.home); rl.write.apply(rl, key.home);
assert.equal(0, rl.cursor); assert.strictEqual(0, rl.cursor);
rl.write.apply(rl, key.end); rl.write.apply(rl, key.end);
assert.equal(3, rl.cursor); assert.strictEqual(3, rl.cursor);
}); });
rl = readlineFakeStream(); rl = readlineFakeStream();
@ -76,9 +76,9 @@ rl.write.apply(rl, key.xterm.home);
].forEach(function(action) { ].forEach(function(action) {
written_bytes_length = rl.written_bytes.length; written_bytes_length = rl.written_bytes.length;
rl.write.apply(rl, action.key); rl.write.apply(rl, action.key);
assert.equal(action.cursor, rl.cursor); assert.strictEqual(action.cursor, rl.cursor);
refreshed = written_bytes_length !== rl.written_bytes.length; refreshed = written_bytes_length !== rl.written_bytes.length;
assert.equal(true, refreshed); assert.strictEqual(true, refreshed);
}); });
rl = readlineFakeStream(); rl = readlineFakeStream();
@ -93,7 +93,7 @@ rl.write.apply(rl, key.xterm.home);
'' ''
].forEach(function(expectedLine) { ].forEach(function(expectedLine) {
rl.write.apply(rl, key.xterm.metad); rl.write.apply(rl, key.xterm.metad);
assert.equal(0, rl.cursor); assert.strictEqual(0, rl.cursor);
assert.equal(expectedLine, rl.line); assert.strictEqual(expectedLine, rl.line);
}); });
rl.close(); rl.close();

10
test/disabled/test-sendfd.js

@ -63,7 +63,7 @@ var logChild = function(d) {
// validate any data sent back by the child. We send the write end of the // validate any data sent back by the child. We send the write end of the
// pipe to the child and close it off in our process. // pipe to the child and close it off in our process.
var pipeFDs = netBinding.pipe(); var pipeFDs = netBinding.pipe();
assert.equal(pipeFDs.length, 2); assert.strictEqual(pipeFDs.length, 2);
var seenOrdinals = []; var seenOrdinals = [];
@ -72,8 +72,8 @@ pipeReadStream.on('data', function(data) {
data.toString('utf8').trim().split('\n').forEach(function(d) { data.toString('utf8').trim().split('\n').forEach(function(d) {
var rd = JSON.parse(d); var rd = JSON.parse(d);
assert.equal(rd.pid, cpp); assert.strictEqual(rd.pid, cpp);
assert.equal(seenOrdinals.indexOf(rd.ord), -1); assert.strictEqual(seenOrdinals.indexOf(rd.ord), -1);
seenOrdinals.unshift(rd.ord); seenOrdinals.unshift(rd.ord);
}); });
@ -119,8 +119,8 @@ cp.on('exit', function(code, signal) {
srv.close(); srv.close();
// fs.unlinkSync(SOCK_PATH); // fs.unlinkSync(SOCK_PATH);
assert.equal(code, 0); assert.strictEqual(code, 0);
assert.equal(seenOrdinals.length, 2); assert.strictEqual(seenOrdinals.length, 2);
}); });
// vim:ts=2 sw=2 et // vim:ts=2 sw=2 et

2
test/disabled/test-setuidgid.js

@ -16,7 +16,7 @@ assert.notStrictEqual(newuid, olduid, 'uids expected to be different');
try { try {
process.setuid('nobody1234'); process.setuid('nobody1234');
} catch (e) { } catch (e) {
assert.equal(e.message, assert.strictEqual(e.message,
'failed to resolve group', 'failed to resolve group',
'unexpected error message' 'unexpected error message'
); );

2
test/fixtures/GH-892-request.js

@ -16,7 +16,7 @@ var options = {
}; };
var req = https.request(options, function(res) { var req = https.request(options, function(res) {
assert.equal(200, res.statusCode); assert.strictEqual(200, res.statusCode);
gotResponse = true; gotResponse = true;
console.error('DONE'); console.error('DONE');
res.resume(); res.resume();

2
test/fixtures/b/c.js

@ -4,7 +4,7 @@ const assert = require('assert');
const package = require('./package'); const package = require('./package');
assert.equal('world', package.hello); assert.strictEqual('world', package.hello);
console.error('load fixtures/b/c.js'); console.error('load fixtures/b/c.js');

4
test/fixtures/node_modules/baz/index.js

@ -2,9 +2,9 @@ console.error(__filename);
console.error(module.paths.join('\n') + '\n'); console.error(module.paths.join('\n') + '\n');
// this should work, and get the one that doesn't throw // this should work, and get the one that doesn't throw
const assert = require('assert'); const assert = require('assert');
assert.equal(require('bar'), require('../bar.js')); assert.strictEqual(require('bar'), require('../bar.js'));
// this should work, and get the one in ./node_modules/asdf.js // this should work, and get the one in ./node_modules/asdf.js
assert.equal(require('asdf'), require('./node_modules/asdf.js')); assert.strictEqual(require('asdf'), require('./node_modules/asdf.js'));
module.exports = 'eye catcher'; module.exports = 'eye catcher';

2
test/fixtures/node_modules/foo.js

@ -1,4 +1,4 @@
console.error(__filename); console.error(__filename);
console.error(module.paths.join('\n') + '\n'); console.error(module.paths.join('\n') + '\n');
const assert = require('assert'); const assert = require('assert');
assert.equal(require('baz'), require('./baz/index.js')); assert.strictEqual(require('baz'), require('./baz/index.js'));

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

@ -4,6 +4,6 @@ const assert = require('assert');
const dns = require('dns'); const dns = require('dns');
dns.resolveTxt('www.microsoft.com', function(err, records) { dns.resolveTxt('www.microsoft.com', function(err, records) {
assert.equal(err, null); assert.strictEqual(err, null);
assert.equal(records.length, 0); assert.strictEqual(records.length, 0);
}); });

2
test/message/error_exit.js

@ -6,4 +6,4 @@ process.on('exit', function(code) {
console.error('Exiting with code=%d', code); console.error('Exiting with code=%d', code);
}); });
assert.equal(1, 2); assert.strictEqual(1, 2);

2
test/message/error_exit.out

@ -3,7 +3,7 @@ Exiting with code=1
assert.js:* assert.js:*
throw new assert.AssertionError({ throw new assert.AssertionError({
^ ^
AssertionError: 1 == 2 AssertionError: 1 === 2
at Object.<anonymous> (*test*message*error_exit.js:*:*) at Object.<anonymous> (*test*message*error_exit.js:*:*)
at Module._compile (module.js:*:*) at Module._compile (module.js:*:*)
at Object.Module._extensions..js (module.js:*:*) at Object.Module._extensions..js (module.js:*:*)

28
test/parallel/test-assert.js

@ -333,7 +333,7 @@ try {
threw = true; threw = true;
assert.ok(e instanceof TypeError, 'type'); assert.ok(e instanceof TypeError, 'type');
} }
assert.equal(true, threw, assert.strictEqual(true, threw,
'a.throws with an explicit error is eating extra errors', 'a.throws with an explicit error is eating extra errors',
a.AssertionError); a.AssertionError);
threw = false; threw = false;
@ -345,8 +345,8 @@ try {
threw = true; threw = true;
assert.ok(e instanceof TypeError); assert.ok(e instanceof TypeError);
} }
assert.equal(true, threw, assert.strictEqual(true, threw, 'a.doesNotThrow with an explicit error is ' +
'a.doesNotThrow with an explicit error is eating extra errors'); 'eating extra errors');
// key difference is that throwing our correct error makes an assertion error // key difference is that throwing our correct error makes an assertion error
try { try {
@ -355,7 +355,7 @@ try {
threw = true; threw = true;
assert.ok(e instanceof a.AssertionError); assert.ok(e instanceof a.AssertionError);
} }
assert.equal(true, threw, assert.strictEqual(true, threw,
'a.doesNotThrow is not catching type matching errors'); 'a.doesNotThrow is not catching type matching errors');
assert.throws(function() { assert.ifError(new Error('test error')); }); assert.throws(function() { assert.ifError(new Error('test error')); });
@ -461,10 +461,10 @@ circular.x = circular;
function testAssertionMessage(actual, expected) { function testAssertionMessage(actual, expected) {
try { try {
assert.equal(actual, ''); assert.strictEqual(actual, '');
} catch (e) { } catch (e) {
assert.equal(e.toString(), assert.strictEqual(e.toString(),
['AssertionError:', expected, '==', '\'\''].join(' ')); ['AssertionError:', expected, '===', '\'\''].join(' '));
assert.ok(e.generatedMessage, 'Message not marked as generated'); assert.ok(e.generatedMessage, 'Message not marked as generated');
} }
} }
@ -499,23 +499,23 @@ try {
}); });
} catch (e) { } catch (e) {
threw = true; threw = true;
assert.equal(e.message, 'Missing expected exception..'); assert.strictEqual(e.message, 'Missing expected exception..');
} }
assert.ok(threw); assert.ok(threw);
// #5292 // #5292
try { try {
assert.equal(1, 2); assert.strictEqual(1, 2);
} catch (e) { } catch (e) {
assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2'); assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: 1 === 2');
assert.ok(e.generatedMessage, 'Message not marked as generated'); assert.ok(e.generatedMessage, 'Message not marked as generated');
} }
try { try {
assert.equal(1, 2, 'oh no'); assert.strictEqual(1, 2, 'oh no');
} catch (e) { } catch (e) {
assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no'); assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: oh no');
assert.equal(e.generatedMessage, false, assert.strictEqual(e.generatedMessage, false,
'Message incorrectly marked as generated'); 'Message incorrectly marked as generated');
} }
@ -527,7 +527,7 @@ function testBlockTypeError(method, block) {
method(block); method(block);
threw = false; threw = false;
} catch (e) { } catch (e) {
assert.equal(e.toString(), assert.strictEqual(e.toString(),
'TypeError: "block" argument must be a function'); 'TypeError: "block" argument must be a function');
} }

250
test/parallel/test-buffer-indexof.js

@ -71,12 +71,12 @@ assert.strictEqual(b.indexOf('f', 5), 5);
assert.strictEqual(b.indexOf('f', -1), 5); assert.strictEqual(b.indexOf('f', -1), 5);
assert.strictEqual(b.indexOf('f', 6), -1); assert.strictEqual(b.indexOf('f', 6), -1);
assert.equal(b.indexOf(Buffer.from('d'), 2), 3); assert.strictEqual(b.indexOf(Buffer.from('d'), 2), 3);
assert.equal(b.indexOf(Buffer.from('f'), 5), 5); assert.strictEqual(b.indexOf(Buffer.from('f'), 5), 5);
assert.equal(b.indexOf(Buffer.from('f'), -1), 5); assert.strictEqual(b.indexOf(Buffer.from('f'), -1), 5);
assert.equal(b.indexOf(Buffer.from('f'), 6), -1); assert.strictEqual(b.indexOf(Buffer.from('f'), 6), -1);
assert.equal(Buffer.from('ff').indexOf(Buffer.from('f'), 1, 'ucs2'), -1); assert.strictEqual(Buffer.from('ff').indexOf(Buffer.from('f'), 1, 'ucs2'), -1);
// test invalid and uppercase encoding // test invalid and uppercase encoding
assert.strictEqual(b.indexOf('b', 'utf8'), 1); assert.strictEqual(b.indexOf('b', 'utf8'), 1);
@ -176,62 +176,67 @@ assert.strictEqual(
// test optional offset with passed encoding // test optional offset with passed encoding
assert.equal(Buffer.from('aaaa0').indexOf('30', 'hex'), 4); assert.strictEqual(Buffer.from('aaaa0').indexOf('30', 'hex'), 4);
assert.equal(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4); assert.strictEqual(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4);
{ {
// test usc2 encoding // test usc2 encoding
const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
assert.equal(8, twoByteString.indexOf('\u0395', 4, 'ucs2')); assert.strictEqual(8, twoByteString.indexOf('\u0395', 4, 'ucs2'));
assert.equal(6, twoByteString.indexOf('\u03a3', -4, 'ucs2')); assert.strictEqual(6, twoByteString.indexOf('\u03a3', -4, 'ucs2'));
assert.equal(4, twoByteString.indexOf('\u03a3', -6, 'ucs2')); assert.strictEqual(4, twoByteString.indexOf('\u03a3', -6, 'ucs2'));
assert.equal(4, twoByteString.indexOf( assert.strictEqual(4, twoByteString.indexOf(
Buffer.from('\u03a3', 'ucs2'), -6, 'ucs2')); Buffer.from('\u03a3', 'ucs2'), -6, 'ucs2'));
assert.equal(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2')); assert.strictEqual(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2'));
} }
const mixedByteStringUcs2 = const mixedByteStringUcs2 =
Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395', 'ucs2'); Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395', 'ucs2');
assert.equal(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2')); assert.strictEqual(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2'));
assert.equal(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2')); assert.strictEqual(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2'));
assert.equal(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2')); assert.strictEqual(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2'));
assert.equal( assert.strictEqual(
6, mixedByteStringUcs2.indexOf(Buffer.from('bc', 'ucs2'), 0, 'ucs2')); 6, mixedByteStringUcs2.indexOf(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
assert.equal( assert.strictEqual(
10, mixedByteStringUcs2.indexOf(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2')); 10, mixedByteStringUcs2.indexOf(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'));
assert.equal( assert.strictEqual(
-1, mixedByteStringUcs2.indexOf(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2')); -1, mixedByteStringUcs2.indexOf(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'));
{ {
const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
// Test single char pattern // Test single char pattern
assert.equal(0, twoByteString.indexOf('\u039a', 0, 'ucs2')); assert.strictEqual(0, twoByteString.indexOf('\u039a', 0, 'ucs2'));
assert.equal(2, twoByteString.indexOf('\u0391', 0, 'ucs2'), 'Alpha'); assert.strictEqual(2, twoByteString.indexOf('\u0391', 0, 'ucs2'),
assert.equal(4, twoByteString.indexOf('\u03a3', 0, 'ucs2'), 'First Sigma'); 'Alpha');
assert.equal(6, twoByteString.indexOf('\u03a3', 6, 'ucs2'), 'Second Sigma'); assert.strictEqual(4, twoByteString.indexOf('\u03a3', 0, 'ucs2'),
assert.equal(8, twoByteString.indexOf('\u0395', 0, 'ucs2'), 'Epsilon'); 'First Sigma');
assert.equal(-1, twoByteString.indexOf('\u0392', 0, 'ucs2'), 'Not beta'); assert.strictEqual(6, twoByteString.indexOf('\u03a3', 6, 'ucs2'),
'Second Sigma');
assert.strictEqual(8, twoByteString.indexOf('\u0395', 0, 'ucs2'),
'Epsilon');
assert.strictEqual(-1, twoByteString.indexOf('\u0392', 0, 'ucs2'),
'Not beta');
// Test multi-char pattern // Test multi-char pattern
assert.equal( assert.strictEqual(
0, twoByteString.indexOf('\u039a\u0391', 0, 'ucs2'), 'Lambda Alpha'); 0, twoByteString.indexOf('\u039a\u0391', 0, 'ucs2'), 'Lambda Alpha');
assert.equal( assert.strictEqual(
2, twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2'), 'Alpha Sigma'); 2, twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2'), 'Alpha Sigma');
assert.equal( assert.strictEqual(
4, twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2'), 'Sigma Sigma'); 4, twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2'), 'Sigma Sigma');
assert.equal( assert.strictEqual(
6, twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2'), 'Sigma Epsilon'); 6, twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2'), 'Sigma Epsilon');
} }
const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395'); const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395');
assert.equal(5, mixedByteStringUtf8.indexOf('bc')); assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc'));
assert.equal(5, mixedByteStringUtf8.indexOf('bc', 5)); assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc', 5));
assert.equal(5, mixedByteStringUtf8.indexOf('bc', -8)); assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc', -8));
assert.equal(7, mixedByteStringUtf8.indexOf('\u03a3')); assert.strictEqual(7, mixedByteStringUtf8.indexOf('\u03a3'));
assert.equal(-1, mixedByteStringUtf8.indexOf('\u0396')); assert.strictEqual(-1, mixedByteStringUtf8.indexOf('\u0396'));
// Test complex string indexOf algorithms. Only trigger for long strings. // Test complex string indexOf algorithms. Only trigger for long strings.
@ -247,23 +252,25 @@ const longBufferString = Buffer.from(longString);
let pattern = 'ABACABADABACABA'; let pattern = 'ABACABADABACABA';
for (let i = 0; i < longBufferString.length - pattern.length; i += 7) { for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
const index = longBufferString.indexOf(pattern, i); const index = longBufferString.indexOf(pattern, i);
assert.equal((i + 15) & ~0xf, index, 'Long ABACABA...-string at index ' + i); assert.strictEqual((i + 15) & ~0xf, index,
'Long ABACABA...-string at index ' + i);
} }
assert.equal(510, longBufferString.indexOf('AJABACA'), 'Long AJABACA, First J'); assert.strictEqual(510, longBufferString.indexOf('AJABACA'),
assert.equal( 'Long AJABACA, First J');
assert.strictEqual(
1534, longBufferString.indexOf('AJABACA', 511), 'Long AJABACA, Second J'); 1534, longBufferString.indexOf('AJABACA', 511), 'Long AJABACA, Second J');
pattern = 'JABACABADABACABA'; pattern = 'JABACABADABACABA';
assert.equal( assert.strictEqual(
511, longBufferString.indexOf(pattern), 'Long JABACABA..., First J'); 511, longBufferString.indexOf(pattern), 'Long JABACABA..., First J');
assert.equal( assert.strictEqual(
1535, longBufferString.indexOf(pattern, 512), 'Long JABACABA..., Second J'); 1535, longBufferString.indexOf(pattern, 512), 'Long JABACABA..., Second J');
// Search for a non-ASCII string in a pure ASCII string. // Search for a non-ASCII string in a pure ASCII string.
const asciiString = Buffer.from( const asciiString = Buffer.from(
'arglebargleglopglyfarglebargleglopglyfarglebargleglopglyf'); 'arglebargleglopglyfarglebargleglopglyfarglebargleglopglyf');
assert.equal(-1, asciiString.indexOf('\x2061')); assert.strictEqual(-1, asciiString.indexOf('\x2061'));
assert.equal(3, asciiString.indexOf('leb', 0)); assert.strictEqual(3, asciiString.indexOf('leb', 0));
// Search in string containing many non-ASCII chars. // Search in string containing many non-ASCII chars.
const allCodePoints = []; const allCodePoints = [];
@ -274,8 +281,8 @@ const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2');
// Search for string long enough to trigger complex search with ASCII pattern // Search for string long enough to trigger complex search with ASCII pattern
// and UC16 subject. // and UC16 subject.
assert.equal(-1, allCharsBufferUtf8.indexOf('notfound')); assert.strictEqual(-1, allCharsBufferUtf8.indexOf('notfound'));
assert.equal(-1, allCharsBufferUcs2.indexOf('notfound')); assert.strictEqual(-1, allCharsBufferUcs2.indexOf('notfound'));
// Needle is longer than haystack, but only because it's encoded as UTF-16 // Needle is longer than haystack, but only because it's encoded as UTF-16
assert.strictEqual(Buffer.from('aaaa').indexOf('a'.repeat(4), 'ucs2'), -1); assert.strictEqual(Buffer.from('aaaa').indexOf('a'.repeat(4), 'ucs2'), -1);
@ -308,10 +315,10 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
} }
const patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length); const patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length);
assert.equal(index, allCharsBufferUtf8.indexOf(patternBufferUtf8)); assert.strictEqual(index, allCharsBufferUtf8.indexOf(patternBufferUtf8));
const patternStringUtf8 = patternBufferUtf8.toString(); const patternStringUtf8 = patternBufferUtf8.toString();
assert.equal(index, allCharsBufferUtf8.indexOf(patternStringUtf8)); assert.strictEqual(index, allCharsBufferUtf8.indexOf(patternStringUtf8));
} }
} }
} }
@ -327,11 +334,11 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
const patternBufferUcs2 = const patternBufferUcs2 =
allCharsBufferUcs2.slice(index, index + length); allCharsBufferUcs2.slice(index, index + length);
assert.equal( assert.strictEqual(
index, allCharsBufferUcs2.indexOf(patternBufferUcs2, 0, 'ucs2')); index, allCharsBufferUcs2.indexOf(patternBufferUcs2, 0, 'ucs2'));
const patternStringUcs2 = patternBufferUcs2.toString('ucs2'); const patternStringUcs2 = patternBufferUcs2.toString('ucs2');
assert.equal( assert.strictEqual(
index, allCharsBufferUcs2.indexOf(patternStringUcs2, 0, 'ucs2')); index, allCharsBufferUcs2.indexOf(patternStringUcs2, 0, 'ucs2'));
} }
} }
@ -352,62 +359,62 @@ assert.throws(function() {
// Test lastIndexOf basic functionality; Buffer b contains 'abcdef'. // Test lastIndexOf basic functionality; Buffer b contains 'abcdef'.
// lastIndexOf string: // lastIndexOf string:
assert.equal(b.lastIndexOf('a'), 0); assert.strictEqual(b.lastIndexOf('a'), 0);
assert.equal(b.lastIndexOf('a', 1), 0); assert.strictEqual(b.lastIndexOf('a', 1), 0);
assert.equal(b.lastIndexOf('b', 1), 1); assert.strictEqual(b.lastIndexOf('b', 1), 1);
assert.equal(b.lastIndexOf('c', 1), -1); assert.strictEqual(b.lastIndexOf('c', 1), -1);
assert.equal(b.lastIndexOf('a', -1), 0); assert.strictEqual(b.lastIndexOf('a', -1), 0);
assert.equal(b.lastIndexOf('a', -4), 0); assert.strictEqual(b.lastIndexOf('a', -4), 0);
assert.equal(b.lastIndexOf('a', -b.length), 0); assert.strictEqual(b.lastIndexOf('a', -b.length), 0);
assert.equal(b.lastIndexOf('a', -b.length - 1), -1); assert.strictEqual(b.lastIndexOf('a', -b.length - 1), -1);
assert.equal(b.lastIndexOf('a', NaN), 0); assert.strictEqual(b.lastIndexOf('a', NaN), 0);
assert.equal(b.lastIndexOf('a', -Infinity), -1); assert.strictEqual(b.lastIndexOf('a', -Infinity), -1);
assert.equal(b.lastIndexOf('a', Infinity), 0); assert.strictEqual(b.lastIndexOf('a', Infinity), 0);
// lastIndexOf Buffer: // lastIndexOf Buffer:
assert.equal(b.lastIndexOf(buf_a), 0); assert.strictEqual(b.lastIndexOf(buf_a), 0);
assert.equal(b.lastIndexOf(buf_a, 1), 0); assert.strictEqual(b.lastIndexOf(buf_a, 1), 0);
assert.equal(b.lastIndexOf(buf_a, -1), 0); assert.strictEqual(b.lastIndexOf(buf_a, -1), 0);
assert.equal(b.lastIndexOf(buf_a, -4), 0); assert.strictEqual(b.lastIndexOf(buf_a, -4), 0);
assert.equal(b.lastIndexOf(buf_a, -b.length), 0); assert.strictEqual(b.lastIndexOf(buf_a, -b.length), 0);
assert.equal(b.lastIndexOf(buf_a, -b.length - 1), -1); assert.strictEqual(b.lastIndexOf(buf_a, -b.length - 1), -1);
assert.equal(b.lastIndexOf(buf_a, NaN), 0); assert.strictEqual(b.lastIndexOf(buf_a, NaN), 0);
assert.equal(b.lastIndexOf(buf_a, -Infinity), -1); assert.strictEqual(b.lastIndexOf(buf_a, -Infinity), -1);
assert.equal(b.lastIndexOf(buf_a, Infinity), 0); assert.strictEqual(b.lastIndexOf(buf_a, Infinity), 0);
assert.equal(b.lastIndexOf(buf_bc), 1); assert.strictEqual(b.lastIndexOf(buf_bc), 1);
assert.equal(b.lastIndexOf(buf_bc, 2), 1); assert.strictEqual(b.lastIndexOf(buf_bc, 2), 1);
assert.equal(b.lastIndexOf(buf_bc, -1), 1); assert.strictEqual(b.lastIndexOf(buf_bc, -1), 1);
assert.equal(b.lastIndexOf(buf_bc, -3), 1); assert.strictEqual(b.lastIndexOf(buf_bc, -3), 1);
assert.equal(b.lastIndexOf(buf_bc, -5), 1); assert.strictEqual(b.lastIndexOf(buf_bc, -5), 1);
assert.equal(b.lastIndexOf(buf_bc, -6), -1); assert.strictEqual(b.lastIndexOf(buf_bc, -6), -1);
assert.equal(b.lastIndexOf(buf_bc, NaN), 1); assert.strictEqual(b.lastIndexOf(buf_bc, NaN), 1);
assert.equal(b.lastIndexOf(buf_bc, -Infinity), -1); assert.strictEqual(b.lastIndexOf(buf_bc, -Infinity), -1);
assert.equal(b.lastIndexOf(buf_bc, Infinity), 1); assert.strictEqual(b.lastIndexOf(buf_bc, Infinity), 1);
assert.equal(b.lastIndexOf(buf_f), b.length - 1); assert.strictEqual(b.lastIndexOf(buf_f), b.length - 1);
assert.equal(b.lastIndexOf(buf_z), -1); assert.strictEqual(b.lastIndexOf(buf_z), -1);
assert.equal(b.lastIndexOf(buf_empty), -1); assert.strictEqual(b.lastIndexOf(buf_empty), -1);
assert.equal(b.lastIndexOf(buf_empty, 1), -1); assert.strictEqual(b.lastIndexOf(buf_empty, 1), -1);
assert.equal(b.lastIndexOf(buf_empty, b.length + 1), -1); assert.strictEqual(b.lastIndexOf(buf_empty, b.length + 1), -1);
assert.equal(b.lastIndexOf(buf_empty, Infinity), -1); assert.strictEqual(b.lastIndexOf(buf_empty, Infinity), -1);
// lastIndexOf number: // lastIndexOf number:
assert.equal(b.lastIndexOf(0x61), 0); assert.strictEqual(b.lastIndexOf(0x61), 0);
assert.equal(b.lastIndexOf(0x61, 1), 0); assert.strictEqual(b.lastIndexOf(0x61, 1), 0);
assert.equal(b.lastIndexOf(0x61, -1), 0); assert.strictEqual(b.lastIndexOf(0x61, -1), 0);
assert.equal(b.lastIndexOf(0x61, -4), 0); assert.strictEqual(b.lastIndexOf(0x61, -4), 0);
assert.equal(b.lastIndexOf(0x61, -b.length), 0); assert.strictEqual(b.lastIndexOf(0x61, -b.length), 0);
assert.equal(b.lastIndexOf(0x61, -b.length - 1), -1); assert.strictEqual(b.lastIndexOf(0x61, -b.length - 1), -1);
assert.equal(b.lastIndexOf(0x61, NaN), 0); assert.strictEqual(b.lastIndexOf(0x61, NaN), 0);
assert.equal(b.lastIndexOf(0x61, -Infinity), -1); assert.strictEqual(b.lastIndexOf(0x61, -Infinity), -1);
assert.equal(b.lastIndexOf(0x61, Infinity), 0); assert.strictEqual(b.lastIndexOf(0x61, Infinity), 0);
assert.equal(b.lastIndexOf(0x0), -1); assert.strictEqual(b.lastIndexOf(0x0), -1);
// Test weird offset arguments. // Test weird offset arguments.
// Behaviour should match String.lastIndexOf: // Behaviour should match String.lastIndexOf:
assert.equal(b.lastIndexOf('b', 0), -1); assert.strictEqual(b.lastIndexOf('b', 0), -1);
assert.equal(b.lastIndexOf('b', undefined), 1); assert.strictEqual(b.lastIndexOf('b', undefined), 1);
assert.equal(b.lastIndexOf('b', null), -1); assert.strictEqual(b.lastIndexOf('b', null), -1);
assert.equal(b.lastIndexOf('b', {}), 1); assert.strictEqual(b.lastIndexOf('b', {}), 1);
assert.equal(b.lastIndexOf('b', []), -1); assert.strictEqual(b.lastIndexOf('b', []), -1);
assert.equal(b.lastIndexOf('b', [2]), 1); assert.strictEqual(b.lastIndexOf('b', [2]), 1);
// Test needles longer than the haystack. // Test needles longer than the haystack.
assert.strictEqual(b.lastIndexOf('aaaaaaaaaaaaaaa', 'ucs2'), -1); assert.strictEqual(b.lastIndexOf('aaaaaaaaaaaaaaa', 'ucs2'), -1);
@ -435,20 +442,21 @@ assert.strictEqual(buf_bc.lastIndexOf(Buffer.from('你好'), 7), -1);
// Test lastIndexOf on a longer buffer: // Test lastIndexOf on a longer buffer:
const bufferString = new Buffer('a man a plan a canal panama'); const bufferString = new Buffer('a man a plan a canal panama');
assert.equal(15, bufferString.lastIndexOf('canal')); assert.strictEqual(15, bufferString.lastIndexOf('canal'));
assert.equal(21, bufferString.lastIndexOf('panama')); assert.strictEqual(21, bufferString.lastIndexOf('panama'));
assert.equal(0, bufferString.lastIndexOf('a man a plan a canal panama')); assert.strictEqual(0, bufferString.lastIndexOf('a man a plan a canal panama'));
assert.equal(-1, bufferString.lastIndexOf('a man a plan a canal mexico')); assert.strictEqual(-1, bufferString.lastIndexOf('a man a plan a canal mexico'));
assert.equal(-1, bufferString.lastIndexOf('a man a plan a canal mexico city')); assert.strictEqual(-1, bufferString
assert.equal(-1, bufferString.lastIndexOf(Buffer.from('a'.repeat(1000)))); .lastIndexOf('a man a plan a canal mexico city'));
assert.equal(0, bufferString.lastIndexOf('a man a plan', 4)); assert.strictEqual(-1, bufferString.lastIndexOf(Buffer.from('a'.repeat(1000))));
assert.equal(13, bufferString.lastIndexOf('a ')); assert.strictEqual(0, bufferString.lastIndexOf('a man a plan', 4));
assert.equal(13, bufferString.lastIndexOf('a ', 13)); assert.strictEqual(13, bufferString.lastIndexOf('a '));
assert.equal(6, bufferString.lastIndexOf('a ', 12)); assert.strictEqual(13, bufferString.lastIndexOf('a ', 13));
assert.equal(0, bufferString.lastIndexOf('a ', 5)); assert.strictEqual(6, bufferString.lastIndexOf('a ', 12));
assert.equal(13, bufferString.lastIndexOf('a ', -1)); assert.strictEqual(0, bufferString.lastIndexOf('a ', 5));
assert.equal(0, bufferString.lastIndexOf('a ', -27)); assert.strictEqual(13, bufferString.lastIndexOf('a ', -1));
assert.equal(-1, bufferString.lastIndexOf('a ', -28)); assert.strictEqual(0, bufferString.lastIndexOf('a ', -27));
assert.strictEqual(-1, bufferString.lastIndexOf('a ', -28));
// Test lastIndexOf for the case that the first character can be found, // Test lastIndexOf for the case that the first character can be found,
// but in a part of the buffer that does not make search to search // but in a part of the buffer that does not make search to search
@ -472,9 +480,9 @@ assert.strictEqual(0, Buffer.from('abc').lastIndexOf('ab', 3));
// Now, we test the BOYER-MOORE-HORSPOOL strategy. // Now, we test the BOYER-MOORE-HORSPOOL strategy.
// Test lastIndexOf on a long buffer w multiple matches: // Test lastIndexOf on a long buffer w multiple matches:
pattern = 'JABACABADABACABA'; pattern = 'JABACABADABACABA';
assert.equal(1535, longBufferString.lastIndexOf(pattern)); assert.strictEqual(1535, longBufferString.lastIndexOf(pattern));
assert.equal(1535, longBufferString.lastIndexOf(pattern, 1535)); assert.strictEqual(1535, longBufferString.lastIndexOf(pattern, 1535));
assert.equal(511, longBufferString.lastIndexOf(pattern, 1534)); assert.strictEqual(511, longBufferString.lastIndexOf(pattern, 1534));
// Finally, give it a really long input to trigger fallback from BMH to // Finally, give it a really long input to trigger fallback from BMH to
// regular BOYER-MOORE (which has better worst-case complexity). // regular BOYER-MOORE (which has better worst-case complexity).
@ -496,19 +504,19 @@ for (let i = 0; i < 1000000; i++) {
parts.push((countBits(i) % 2 === 0) ? 'yolo' : 'swag'); parts.push((countBits(i) % 2 === 0) ? 'yolo' : 'swag');
} }
const reallyLong = new Buffer(parts.join(' ')); const reallyLong = new Buffer(parts.join(' '));
assert.equal('yolo swag swag yolo', reallyLong.slice(0, 19).toString()); assert.strictEqual('yolo swag swag yolo', reallyLong.slice(0, 19).toString());
// Expensive reverse searches. Stress test lastIndexOf: // Expensive reverse searches. Stress test lastIndexOf:
pattern = reallyLong.slice(0, 100000); // First 1/50th of the pattern. pattern = reallyLong.slice(0, 100000); // First 1/50th of the pattern.
assert.equal(4751360, reallyLong.lastIndexOf(pattern)); assert.strictEqual(4751360, reallyLong.lastIndexOf(pattern));
assert.equal(3932160, reallyLong.lastIndexOf(pattern, 4000000)); assert.strictEqual(3932160, reallyLong.lastIndexOf(pattern, 4000000));
assert.equal(2949120, reallyLong.lastIndexOf(pattern, 3000000)); assert.strictEqual(2949120, reallyLong.lastIndexOf(pattern, 3000000));
pattern = reallyLong.slice(100000, 200000); // Second 1/50th. pattern = reallyLong.slice(100000, 200000); // Second 1/50th.
assert.equal(4728480, reallyLong.lastIndexOf(pattern)); assert.strictEqual(4728480, reallyLong.lastIndexOf(pattern));
pattern = reallyLong.slice(0, 1000000); // First 1/5th. pattern = reallyLong.slice(0, 1000000); // First 1/5th.
assert.equal(3932160, reallyLong.lastIndexOf(pattern)); assert.strictEqual(3932160, reallyLong.lastIndexOf(pattern));
pattern = reallyLong.slice(0, 2000000); // first 2/5ths. pattern = reallyLong.slice(0, 2000000); // first 2/5ths.
assert.equal(0, reallyLong.lastIndexOf(pattern)); assert.strictEqual(0, reallyLong.lastIndexOf(pattern));
// test truncation of Number arguments to uint8 // test truncation of Number arguments to uint8
{ {

2
test/parallel/test-child-process-fork-net.js

@ -153,7 +153,7 @@ if (process.argv[2] === 'child') {
}); });
connect.on('close', function() { connect.on('close', function() {
console.log('CLIENT: closed'); console.log('CLIENT: closed');
assert.equal(store, 'echo'); assert.strictEqual(store, 'echo');
server.close(); server.close();
}); });
}); });

4
test/parallel/test-child-process-fork-net2.js

@ -135,7 +135,7 @@ if (process.argv[2] === 'child') {
}; };
process.on('exit', function() { process.on('exit', function() {
assert.equal(disconnected, count); assert.strictEqual(disconnected, count);
assert.equal(connected, count); assert.strictEqual(connected, count);
}); });
} }

2
test/parallel/test-child-process-fork-ref.js

@ -33,6 +33,6 @@ if (process.argv[2] === 'child') {
child.once('exit', function() { child.once('exit', function() {
assert.deepStrictEqual(ipc, ['1', '2']); assert.deepStrictEqual(ipc, ['1', '2']);
assert.equal(stdout, '3'); assert.strictEqual(stdout, '3');
}); });
} }

2
test/parallel/test-child-process-ipc.js

@ -30,7 +30,7 @@ child.stdout.on('data', function(data) {
child.stdin.write('echo me\r\n'); child.stdin.write('echo me\r\n');
} else { } else {
console.error('testing for echo me'); console.error('testing for echo me');
assert.equal('echo me\r\n', data); assert.strictEqual('echo me\r\n', data);
gotEcho = true; gotEcho = true;
child.stdin.end(); child.stdin.end();
} }

2
test/parallel/test-child-process-set-blocking.js

@ -10,5 +10,5 @@ const cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], {
}); });
cp.on('exit', common.mustCall(function(code) { cp.on('exit', common.mustCall(function(code) {
assert.equal(0, code); assert.strictEqual(0, code);
})); }));

2
test/parallel/test-child-process-spawnsync-env.js

@ -11,5 +11,5 @@ if (process.argv[2] === 'child') {
env: Object.assign(process.env, { foo: expected }) env: Object.assign(process.env, { foo: expected })
}); });
assert.equal(child.stdout.toString().trim(), expected); assert.strictEqual(child.stdout.toString().trim(), expected);
} }

66
test/parallel/test-crypto-dh.js

@ -19,9 +19,9 @@ let key2 = dh2.generateKeys('hex');
let secret1 = dh1.computeSecret(key2, 'hex', 'base64'); let secret1 = dh1.computeSecret(key2, 'hex', 'base64');
let secret2 = dh2.computeSecret(key1, 'latin1', 'buffer'); let secret2 = dh2.computeSecret(key1, 'latin1', 'buffer');
assert.equal(secret1, secret2.toString('base64')); assert.strictEqual(secret1, secret2.toString('base64'));
assert.equal(dh1.verifyError, 0); assert.strictEqual(dh1.verifyError, 0);
assert.equal(dh2.verifyError, 0); assert.strictEqual(dh2.verifyError, 0);
assert.throws(function() { assert.throws(function() {
crypto.createDiffieHellman([0x1, 0x2]); crypto.createDiffieHellman([0x1, 0x2]);
@ -50,11 +50,11 @@ assert.deepStrictEqual(dh1.getPrime(), dh3.getPrime());
assert.deepStrictEqual(dh1.getGenerator(), dh3.getGenerator()); assert.deepStrictEqual(dh1.getGenerator(), dh3.getGenerator());
assert.deepStrictEqual(dh1.getPublicKey(), dh3.getPublicKey()); assert.deepStrictEqual(dh1.getPublicKey(), dh3.getPublicKey());
assert.deepStrictEqual(dh1.getPrivateKey(), dh3.getPrivateKey()); assert.deepStrictEqual(dh1.getPrivateKey(), dh3.getPrivateKey());
assert.equal(dh3.verifyError, 0); assert.strictEqual(dh3.verifyError, 0);
const secret3 = dh3.computeSecret(key2, 'hex', 'base64'); const secret3 = dh3.computeSecret(key2, 'hex', 'base64');
assert.equal(secret1, secret3); assert.strictEqual(secret1, secret3);
// Run this one twice to make sure that the dh3 clears its error properly // Run this one twice to make sure that the dh3 clears its error properly
{ {
@ -78,9 +78,9 @@ alice.generateKeys();
bob.generateKeys(); bob.generateKeys();
const aSecret = alice.computeSecret(bob.getPublicKey()).toString('hex'); const aSecret = alice.computeSecret(bob.getPublicKey()).toString('hex');
const bSecret = bob.computeSecret(alice.getPublicKey()).toString('hex'); const bSecret = bob.computeSecret(alice.getPublicKey()).toString('hex');
assert.equal(aSecret, bSecret); assert.strictEqual(aSecret, bSecret);
assert.equal(alice.verifyError, DH_NOT_SUITABLE_GENERATOR); assert.strictEqual(alice.verifyError, DH_NOT_SUITABLE_GENERATOR);
assert.equal(bob.verifyError, DH_NOT_SUITABLE_GENERATOR); assert.strictEqual(bob.verifyError, DH_NOT_SUITABLE_GENERATOR);
/* Ensure specific generator (buffer) works as expected. /* Ensure specific generator (buffer) works as expected.
* The values below (modp2/modp2buf) are for a 1024 bits long prime from * The values below (modp2/modp2buf) are for a 1024 bits long prime from
@ -107,9 +107,9 @@ exmodp2.generateKeys();
let modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()).toString('hex'); let modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()).toString('hex');
const exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey()) const exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey())
.toString('hex'); .toString('hex');
assert.equal(modp2Secret, exmodp2Secret); assert.strictEqual(modp2Secret, exmodp2Secret);
assert.equal(modp2.verifyError, DH_NOT_SUITABLE_GENERATOR); assert.strictEqual(modp2.verifyError, DH_NOT_SUITABLE_GENERATOR);
assert.equal(exmodp2.verifyError, DH_NOT_SUITABLE_GENERATOR); assert.strictEqual(exmodp2.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Ensure specific generator (string with encoding) works as expected. // Ensure specific generator (string with encoding) works as expected.
@ -118,8 +118,8 @@ exmodp2_2.generateKeys();
modp2Secret = modp2.computeSecret(exmodp2_2.getPublicKey()).toString('hex'); modp2Secret = modp2.computeSecret(exmodp2_2.getPublicKey()).toString('hex');
const exmodp2_2Secret = exmodp2_2.computeSecret(modp2.getPublicKey()) const exmodp2_2Secret = exmodp2_2.computeSecret(modp2.getPublicKey())
.toString('hex'); .toString('hex');
assert.equal(modp2Secret, exmodp2_2Secret); assert.strictEqual(modp2Secret, exmodp2_2Secret);
assert.equal(exmodp2_2.verifyError, DH_NOT_SUITABLE_GENERATOR); assert.strictEqual(exmodp2_2.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Ensure specific generator (string without encoding) works as expected. // Ensure specific generator (string without encoding) works as expected.
@ -128,8 +128,8 @@ exmodp2_3.generateKeys();
modp2Secret = modp2.computeSecret(exmodp2_3.getPublicKey()).toString('hex'); modp2Secret = modp2.computeSecret(exmodp2_3.getPublicKey()).toString('hex');
const exmodp2_3Secret = exmodp2_3.computeSecret(modp2.getPublicKey()) const exmodp2_3Secret = exmodp2_3.computeSecret(modp2.getPublicKey())
.toString('hex'); .toString('hex');
assert.equal(modp2Secret, exmodp2_3Secret); assert.strictEqual(modp2Secret, exmodp2_3Secret);
assert.equal(exmodp2_3.verifyError, DH_NOT_SUITABLE_GENERATOR); assert.strictEqual(exmodp2_3.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Ensure specific generator (numeric) works as expected. // Ensure specific generator (numeric) works as expected.
@ -138,8 +138,8 @@ exmodp2_4.generateKeys();
modp2Secret = modp2.computeSecret(exmodp2_4.getPublicKey()).toString('hex'); modp2Secret = modp2.computeSecret(exmodp2_4.getPublicKey()).toString('hex');
const exmodp2_4Secret = exmodp2_4.computeSecret(modp2.getPublicKey()) const exmodp2_4Secret = exmodp2_4.computeSecret(modp2.getPublicKey())
.toString('hex'); .toString('hex');
assert.equal(modp2Secret, exmodp2_4Secret); assert.strictEqual(modp2Secret, exmodp2_4Secret);
assert.equal(exmodp2_4.verifyError, DH_NOT_SUITABLE_GENERATOR); assert.strictEqual(exmodp2_4.verifyError, DH_NOT_SUITABLE_GENERATOR);
const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' + const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
@ -147,7 +147,7 @@ const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF';
const bad_dh = crypto.createDiffieHellman(p, 'hex'); const bad_dh = crypto.createDiffieHellman(p, 'hex');
assert.equal(bad_dh.verifyError, DH_NOT_SUITABLE_GENERATOR); assert.strictEqual(bad_dh.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Test ECDH // Test ECDH
@ -158,7 +158,7 @@ key2 = ecdh2.generateKeys('hex');
secret1 = ecdh1.computeSecret(key2, 'hex', 'base64'); secret1 = ecdh1.computeSecret(key2, 'hex', 'base64');
secret2 = ecdh2.computeSecret(key1, 'latin1', 'buffer'); secret2 = ecdh2.computeSecret(key1, 'latin1', 'buffer');
assert.equal(secret1, secret2.toString('base64')); assert.strictEqual(secret1, secret2.toString('base64'));
// Oakley curves do not clean up ERR stack, it was causing unexpected failure // Oakley curves do not clean up ERR stack, it was causing unexpected failure
// when accessing other OpenSSL APIs afterwards. // when accessing other OpenSSL APIs afterwards.
@ -166,7 +166,7 @@ crypto.createECDH('Oakley-EC2N-3');
crypto.createHash('sha256'); crypto.createHash('sha256');
// Point formats // Point formats
assert.equal(ecdh1.getPublicKey('buffer', 'uncompressed')[0], 4); assert.strictEqual(ecdh1.getPublicKey('buffer', 'uncompressed')[0], 4);
let firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0]; let firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0];
assert(firstByte === 2 || firstByte === 3); assert(firstByte === 2 || firstByte === 3);
firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0]; firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0];
@ -210,9 +210,9 @@ const cafebabePubPtUnComp =
'04672a31bfc59d3f04548ec9b7daeeba2f61814e8ccc40448045007f5479f693a3' + '04672a31bfc59d3f04548ec9b7daeeba2f61814e8ccc40448045007f5479f693a3' +
'2e02c7f93d13dc2732b760ca377a5897b9dd41a1c1b29dc0442fdce6d0a04d1d'; '2e02c7f93d13dc2732b760ca377a5897b9dd41a1c1b29dc0442fdce6d0a04d1d';
ecdh5.setPrivateKey(cafebabeKey, 'hex'); ecdh5.setPrivateKey(cafebabeKey, 'hex');
assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey); assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey);
// Show that the public point (key) is generated while setting the private key. // Show that the public point (key) is generated while setting the private key.
assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
// Compressed and uncompressed public points/keys for other party's private key // Compressed and uncompressed public points/keys for other party's private key
// 0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF // 0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF
@ -225,24 +225,26 @@ const peerPubPtUnComp =
const sharedSecret = const sharedSecret =
'1da220b5329bbe8bfd19ceef5a5898593f411a6f12ea40f2a8eead9a5cf59970'; '1da220b5329bbe8bfd19ceef5a5898593f411a6f12ea40f2a8eead9a5cf59970';
assert.equal(ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'), sharedSecret); assert.strictEqual(ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'),
assert.equal(ecdh5.computeSecret(peerPubPtUnComp, 'hex', 'hex'), sharedSecret); sharedSecret);
assert.strictEqual(ecdh5.computeSecret(peerPubPtUnComp, 'hex', 'hex'),
sharedSecret);
// Verify that we still have the same key pair as before the computation. // Verify that we still have the same key pair as before the computation.
assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey); assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey);
assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
// Verify setting and getting compressed and non-compressed serializations. // Verify setting and getting compressed and non-compressed serializations.
ecdh5.setPublicKey(cafebabePubPtComp, 'hex'); ecdh5.setPublicKey(cafebabePubPtComp, 'hex');
assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
assert.equal(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp); assert.strictEqual(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp);
ecdh5.setPublicKey(cafebabePubPtUnComp, 'hex'); ecdh5.setPublicKey(cafebabePubPtUnComp, 'hex');
assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
assert.equal(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp); assert.strictEqual(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp);
// Show why allowing the public key to be set on this type does not make sense. // Show why allowing the public key to be set on this type does not make sense.
ecdh5.setPublicKey(peerPubPtComp, 'hex'); ecdh5.setPublicKey(peerPubPtComp, 'hex');
assert.equal(ecdh5.getPublicKey('hex'), peerPubPtUnComp); assert.strictEqual(ecdh5.getPublicKey('hex'), peerPubPtUnComp);
assert.throws(function() { assert.throws(function() {
// Error because the public key does not match the private key anymore. // Error because the public key does not match the private key anymore.
ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'); ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex');
@ -261,5 +263,5 @@ ecdh5.setPrivateKey(cafebabeKey, 'hex');
ecdh5.setPrivateKey(element, 'hex'); ecdh5.setPrivateKey(element, 'hex');
}, /Private key is not valid for specified curve/); }, /Private key is not valid for specified curve/);
// Verify object state did not change. // Verify object state did not change.
assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey); assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey);
}); });

2
test/parallel/test-crypto-domains.js

@ -12,7 +12,7 @@ if (!common.hasCrypto) {
const crypto = require('crypto'); const crypto = require('crypto');
d.on('error', common.mustCall(function(e) { d.on('error', common.mustCall(function(e) {
assert.equal(e.message, expect.shift()); assert.strictEqual(e.message, expect.shift());
}, 3)); }, 3));
d.run(function() { d.run(function() {

2
test/parallel/test-dh-padding.js

@ -85,7 +85,7 @@ const p = crypto.createDiffieHellman(
p.setPublicKey(apub, 'hex'); p.setPublicKey(apub, 'hex');
p.setPrivateKey(apriv, 'hex'); p.setPrivateKey(apriv, 'hex');
assert.equal( assert.strictEqual(
p.computeSecret(bpub, 'hex', 'hex').toString('hex'), p.computeSecret(bpub, 'hex', 'hex').toString('hex'),
secret secret
); );

2
test/parallel/test-domain-nested.js

@ -6,7 +6,7 @@ const assert = require('assert');
const domain = require('domain'); const domain = require('domain');
process.on('exit', function(c) { process.on('exit', function(c) {
assert.equal(domain._stack.length, 0); assert.strictEqual(domain._stack.length, 0);
}); });
domain.create().run(function() { domain.create().run(function() {

7
test/parallel/test-event-emitter-prepend.js

@ -7,13 +7,14 @@ const assert = require('assert');
const myEE = new EventEmitter(); const myEE = new EventEmitter();
let m = 0; let m = 0;
// This one comes last. // This one comes last.
myEE.on('foo', common.mustCall(() => assert.equal(m, 2))); myEE.on('foo', common.mustCall(() => assert.strictEqual(m, 2)));
// This one comes second. // This one comes second.
myEE.prependListener('foo', common.mustCall(() => assert.equal(m++, 1))); myEE.prependListener('foo', common.mustCall(() => assert.strictEqual(m++, 1)));
// This one comes first. // This one comes first.
myEE.prependOnceListener('foo', common.mustCall(() => assert.equal(m++, 0))); myEE.prependOnceListener('foo',
common.mustCall(() => assert.strictEqual(m++, 0)));
myEE.emit('foo'); myEE.emit('foo');

2
test/parallel/test-event-emitter-subclass.js

@ -43,4 +43,4 @@ const ee2 = new MyEE2();
ee1.on('x', function() {}); ee1.on('x', function() {});
assert.equal(ee2.listenerCount('x'), 0); assert.strictEqual(ee2.listenerCount('x'), 0);

4
test/parallel/test-fs-error-messages.js

@ -12,7 +12,7 @@ const existingDir2 = path.join(common.fixturesDir, 'keys');
// ASYNC_CALL // ASYNC_CALL
fs.stat(fn, function(err) { fs.stat(fn, function(err) {
assert.equal(fn, err.path); assert.strictEqual(fn, err.path);
assert.ok(0 <= err.message.indexOf(fn)); assert.ok(0 <= err.message.indexOf(fn));
}); });
@ -204,7 +204,7 @@ try {
} }
process.on('exit', function() { process.on('exit', function() {
assert.equal(expected, errors.length, assert.strictEqual(expected, errors.length,
'Test fs sync exceptions raised, got ' + errors.length + 'Test fs sync exceptions raised, got ' + errors.length +
' expected ' + expected); ' expected ' + expected);
}); });

4
test/parallel/test-fs-mkdir-rmdir.js

@ -29,8 +29,8 @@ fs.mkdir(d, 0o666, function(err) {
fs.mkdir(d, 0o666, function(err) { fs.mkdir(d, 0o666, function(err) {
assert.ok(err.message.match(/^EEXIST/), 'got EEXIST message'); assert.ok(err.message.match(/^EEXIST/), 'got EEXIST message');
assert.equal(err.code, 'EEXIST', 'got EEXIST code'); assert.strictEqual(err.code, 'EEXIST', 'got EEXIST code');
assert.equal(err.path, d, 'got proper path for EEXIST'); assert.strictEqual(err.path, d, 'got proper path for EEXIST');
fs.rmdir(d, assert.ifError); fs.rmdir(d, assert.ifError);
}); });

4
test/parallel/test-fs-mkdir.js

@ -33,8 +33,8 @@ common.refreshTmpDir();
unlink(pathname); unlink(pathname);
fs.mkdir(pathname, 0o777, common.mustCall(function(err) { fs.mkdir(pathname, 0o777, common.mustCall(function(err) {
assert.equal(err, null); assert.strictEqual(err, null);
assert.equal(common.fileExists(pathname), true); assert.strictEqual(common.fileExists(pathname), true);
})); }));
process.on('exit', function() { process.on('exit', function() {

2
test/parallel/test-fs-mkdtemp.js

@ -14,7 +14,7 @@ assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length);
assert(common.fileExists(tmpFolder)); assert(common.fileExists(tmpFolder));
const utf8 = fs.mkdtempSync(path.join(common.tmpDir, '\u0222abc.')); const utf8 = fs.mkdtempSync(path.join(common.tmpDir, '\u0222abc.'));
assert.equal(Buffer.byteLength(path.basename(utf8)), assert.strictEqual(Buffer.byteLength(path.basename(utf8)),
Buffer.byteLength('\u0222abc.XXXXXX')); Buffer.byteLength('\u0222abc.XXXXXX'));
assert(common.fileExists(utf8)); assert(common.fileExists(utf8));

30
test/parallel/test-fs-open-flags.js

@ -15,21 +15,21 @@ const O_WRONLY = fs.constants.O_WRONLY || 0;
const { stringToFlags } = require('internal/fs'); const { stringToFlags } = require('internal/fs');
assert.equal(stringToFlags('r'), O_RDONLY); assert.strictEqual(stringToFlags('r'), O_RDONLY);
assert.equal(stringToFlags('r+'), O_RDWR); assert.strictEqual(stringToFlags('r+'), O_RDWR);
assert.equal(stringToFlags('w'), O_TRUNC | O_CREAT | O_WRONLY); assert.strictEqual(stringToFlags('w'), O_TRUNC | O_CREAT | O_WRONLY);
assert.equal(stringToFlags('w+'), O_TRUNC | O_CREAT | O_RDWR); assert.strictEqual(stringToFlags('w+'), O_TRUNC | O_CREAT | O_RDWR);
assert.equal(stringToFlags('a'), O_APPEND | O_CREAT | O_WRONLY); assert.strictEqual(stringToFlags('a'), O_APPEND | O_CREAT | O_WRONLY);
assert.equal(stringToFlags('a+'), O_APPEND | O_CREAT | O_RDWR); assert.strictEqual(stringToFlags('a+'), O_APPEND | O_CREAT | O_RDWR);
assert.equal(stringToFlags('wx'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL); assert.strictEqual(stringToFlags('wx'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL);
assert.equal(stringToFlags('xw'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL); assert.strictEqual(stringToFlags('xw'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL);
assert.equal(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL); assert.strictEqual(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
assert.equal(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL); assert.strictEqual(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
assert.equal(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); assert.strictEqual(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
assert.equal(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); assert.strictEqual(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
assert.equal(stringToFlags('ax+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); assert.strictEqual(stringToFlags('ax+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL);
assert.equal(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); assert.strictEqual(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL);
('+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx') ('+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx')
.split(' ') .split(' ')

2
test/parallel/test-fs-read-stream.js

@ -61,7 +61,7 @@ file.on('close', function() {
assert.strictEqual(file.bytesRead, fileSize); assert.strictEqual(file.bytesRead, fileSize);
callbacks.close++; callbacks.close++;
//assert.equal(fs.readFileSync(fn), fileContent); //assert.strictEqual(fs.readFileSync(fn), fileContent);
}); });
const file3 = fs.createReadStream(fn, {encoding: 'utf8'}); const file3 = fs.createReadStream(fn, {encoding: 'utf8'});

4
test/parallel/test-fs-read-zero-length.js

@ -10,10 +10,10 @@ const bufferAsync = Buffer.alloc(0);
const bufferSync = Buffer.alloc(0); const bufferSync = Buffer.alloc(0);
fs.read(fd, bufferAsync, 0, 0, 0, common.mustCall(function(err, bytesRead) { fs.read(fd, bufferAsync, 0, 0, 0, common.mustCall(function(err, bytesRead) {
assert.equal(bytesRead, 0); assert.strictEqual(bytesRead, 0);
assert.deepStrictEqual(bufferAsync, Buffer.alloc(0)); assert.deepStrictEqual(bufferAsync, Buffer.alloc(0));
})); }));
const r = fs.readSync(fd, bufferSync, 0, 0, 0); const r = fs.readSync(fd, bufferSync, 0, 0, 0);
assert.deepStrictEqual(bufferSync, Buffer.alloc(0)); assert.deepStrictEqual(bufferSync, Buffer.alloc(0));
assert.equal(r, 0); assert.strictEqual(r, 0);

2
test/parallel/test-fs-readdir-ucs2.js

@ -20,7 +20,7 @@ fs.closeSync(fs.openSync(fullpath, 'w+'));
fs.readdir(common.tmpDir, 'ucs2', (err, list) => { fs.readdir(common.tmpDir, 'ucs2', (err, list) => {
assert.ifError(err); assert.ifError(err);
assert.equal(1, list.length); assert.strictEqual(1, list.length);
const fn = list[0]; const fn = list[0];
assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2')); assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2'));
assert.strictEqual(fn, filename); assert.strictEqual(fn, filename);

2
test/parallel/test-fs-readdir.js

@ -31,5 +31,5 @@ assert.throws(function() {
}, /Error: ENOTDIR: not a directory/); }, /Error: ENOTDIR: not a directory/);
fs.readdir(__filename, common.mustCall(function(e) { fs.readdir(__filename, common.mustCall(function(e) {
assert.equal(e.code, 'ENOTDIR'); assert.strictEqual(e.code, 'ENOTDIR');
})); }));

4
test/parallel/test-fs-realpath.js

@ -508,6 +508,6 @@ function runTest() {
process.on('exit', function() { process.on('exit', function() {
assert.equal(numtests, testsRun); assert.strictEqual(numtests, testsRun);
assert.equal(async_completed, async_expected); assert.strictEqual(async_completed, async_expected);
}); });

14
test/parallel/test-fs-stat.js

@ -57,25 +57,25 @@ fs.stat(__filename, common.mustCall(function(err, s) {
console.dir(s); console.dir(s);
console.log('isDirectory: ' + JSON.stringify(s.isDirectory())); console.log('isDirectory: ' + JSON.stringify(s.isDirectory()));
assert.equal(false, s.isDirectory()); assert.strictEqual(false, s.isDirectory());
console.log('isFile: ' + JSON.stringify(s.isFile())); console.log('isFile: ' + JSON.stringify(s.isFile()));
assert.equal(true, s.isFile()); assert.strictEqual(true, s.isFile());
console.log('isSocket: ' + JSON.stringify(s.isSocket())); console.log('isSocket: ' + JSON.stringify(s.isSocket()));
assert.equal(false, s.isSocket()); assert.strictEqual(false, s.isSocket());
console.log('isBlockDevice: ' + JSON.stringify(s.isBlockDevice())); console.log('isBlockDevice: ' + JSON.stringify(s.isBlockDevice()));
assert.equal(false, s.isBlockDevice()); assert.strictEqual(false, s.isBlockDevice());
console.log('isCharacterDevice: ' + JSON.stringify(s.isCharacterDevice())); console.log('isCharacterDevice: ' + JSON.stringify(s.isCharacterDevice()));
assert.equal(false, s.isCharacterDevice()); assert.strictEqual(false, s.isCharacterDevice());
console.log('isFIFO: ' + JSON.stringify(s.isFIFO())); console.log('isFIFO: ' + JSON.stringify(s.isFIFO()));
assert.equal(false, s.isFIFO()); assert.strictEqual(false, s.isFIFO());
console.log('isSymbolicLink: ' + JSON.stringify(s.isSymbolicLink())); console.log('isSymbolicLink: ' + JSON.stringify(s.isSymbolicLink()));
assert.equal(false, s.isSymbolicLink()); assert.strictEqual(false, s.isSymbolicLink());
assert.ok(s.mtime instanceof Date); assert.ok(s.mtime instanceof Date);
})); }));

8
test/parallel/test-fs-sync-fd-leak.js

@ -8,7 +8,7 @@ fs.openSync = function() {
return 42; return 42;
}; };
fs.closeSync = function(fd) { fs.closeSync = function(fd) {
assert.equal(fd, 42); assert.strictEqual(fd, 42);
close_called++; close_called++;
}; };
fs.readSync = function() { fs.readSync = function() {
@ -40,10 +40,10 @@ function ensureThrows(cb) {
try { try {
cb(); cb();
} catch (e) { } catch (e) {
assert.equal(e.message, 'BAM'); assert.strictEqual(e.message, 'BAM');
got_exception = true; got_exception = true;
} }
assert.equal(close_called, 1); assert.strictEqual(close_called, 1);
assert.equal(got_exception, true); assert.strictEqual(got_exception, true);
} }

4
test/parallel/test-fs-watch-enoent.js

@ -8,7 +8,7 @@ assert.throws(function() {
}, function(err) { }, function(err) {
assert(err); assert(err);
assert(/non-existent-file/.test(err)); assert(/non-existent-file/.test(err));
assert.equal(err.filename, 'non-existent-file'); assert.strictEqual(err.filename, 'non-existent-file');
return true; return true;
}); });
@ -16,6 +16,6 @@ const watcher = fs.watch(__filename);
watcher.on('error', common.mustCall(function(err) { watcher.on('error', common.mustCall(function(err) {
assert(err); assert(err);
assert(/non-existent-file/.test(err)); assert(/non-existent-file/.test(err));
assert.equal(err.filename, 'non-existent-file'); assert.strictEqual(err.filename, 'non-existent-file');
})); }));
watcher._handle.onchange(-1, 'ENOENT', 'non-existent-file'); watcher._handle.onchange(-1, 'ENOENT', 'non-existent-file');

4
test/parallel/test-fs-watch-stop-async.js

@ -12,8 +12,8 @@ const listener = common.mustCall(() => {
triggered = false; triggered = false;
watch.once('stop', listener); // Should trigger. watch.once('stop', listener); // Should trigger.
watch.stop(); watch.stop();
assert.equal(triggered, false); assert.strictEqual(triggered, false);
setImmediate(() => { setImmediate(() => {
assert.equal(triggered, true); assert.strictEqual(triggered, true);
watch.removeListener('stop', listener); watch.removeListener('stop', listener);
}); });

2
test/parallel/test-fs-write-stream-change-open.js

@ -29,5 +29,5 @@ stream.write('foo');
stream.end(); stream.end();
process.on('exit', function() { process.on('exit', function() {
assert.equal(fs.open, _fs_open); assert.strictEqual(fs.open, _fs_open);
}); });

8
test/parallel/test-fs-write-stream-err.js

@ -33,14 +33,14 @@ fs.write = function() {
fs.close = common.mustCall(function(fd_, cb) { fs.close = common.mustCall(function(fd_, cb) {
console.error('fs.close', fd_, stream.fd); console.error('fs.close', fd_, stream.fd);
assert.equal(fd_, stream.fd); assert.strictEqual(fd_, stream.fd);
process.nextTick(cb); process.nextTick(cb);
}); });
stream.on('error', common.mustCall(function(err_) { stream.on('error', common.mustCall(function(err_) {
console.error('error handler'); console.error('error handler');
assert.equal(stream.fd, null); assert.strictEqual(stream.fd, null);
assert.equal(err_, err); assert.strictEqual(err_, err);
})); }));
@ -48,6 +48,6 @@ stream.write(Buffer.allocUnsafe(256), function() {
console.error('first cb'); console.error('first cb');
stream.write(Buffer.allocUnsafe(256), common.mustCall(function(err_) { stream.write(Buffer.allocUnsafe(256), common.mustCall(function(err_) {
console.error('second cb'); console.error('second cb');
assert.equal(err_, err); assert.strictEqual(err_, err);
})); }));
}); });

2
test/parallel/test-fs-write-string-coerce.js

@ -17,7 +17,7 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
fs.write(fd, data, 0, 'utf8', common.mustCall(function(err, written) { fs.write(fd, data, 0, 'utf8', common.mustCall(function(err, written) {
console.log('write done'); console.log('write done');
assert.ifError(err); assert.ifError(err);
assert.equal(Buffer.byteLength(expected), written); assert.strictEqual(Buffer.byteLength(expected), written);
fs.closeSync(fd); fs.closeSync(fd);
const found = fs.readFileSync(fn, 'utf8'); const found = fs.readFileSync(fn, 'utf8');
console.log('expected: "%s"', expected); console.log('expected: "%s"', expected);

22
test/parallel/test-http-abort-queued.js

@ -8,7 +8,7 @@ let complete;
const server = http.createServer(function(req, res) { const server = http.createServer(function(req, res) {
// We should not see the queued /thatotherone request within the server // We should not see the queued /thatotherone request within the server
// as it should be aborted before it is sent. // as it should be aborted before it is sent.
assert.equal(req.url, '/'); assert.strictEqual(req.url, '/');
res.writeHead(200); res.writeHead(200);
res.write('foo'); res.write('foo');
@ -23,7 +23,7 @@ server.listen(0, function() {
console.log('listen', server.address().port); console.log('listen', server.address().port);
const agent = new http.Agent({maxSockets: 1}); const agent = new http.Agent({maxSockets: 1});
assert.equal(Object.keys(agent.sockets).length, 0); assert.strictEqual(Object.keys(agent.sockets).length, 0);
const options = { const options = {
hostname: 'localhost', hostname: 'localhost',
@ -35,8 +35,8 @@ server.listen(0, function() {
const req1 = http.request(options); const req1 = http.request(options);
req1.on('response', function(res1) { req1.on('response', function(res1) {
assert.equal(Object.keys(agent.sockets).length, 1); assert.strictEqual(Object.keys(agent.sockets).length, 1);
assert.equal(Object.keys(agent.requests).length, 0); assert.strictEqual(Object.keys(agent.requests).length, 0);
const req2 = http.request({ const req2 = http.request({
method: 'GET', method: 'GET',
@ -45,19 +45,19 @@ server.listen(0, function() {
path: '/thatotherone', path: '/thatotherone',
agent: agent agent: agent
}); });
assert.equal(Object.keys(agent.sockets).length, 1); assert.strictEqual(Object.keys(agent.sockets).length, 1);
assert.equal(Object.keys(agent.requests).length, 1); assert.strictEqual(Object.keys(agent.requests).length, 1);
req2.on('error', function(err) { req2.on('error', function(err) {
// This is expected in response to our explicit abort call // This is expected in response to our explicit abort call
assert.equal(err.code, 'ECONNRESET'); assert.strictEqual(err.code, 'ECONNRESET');
}); });
req2.end(); req2.end();
req2.abort(); req2.abort();
assert.equal(Object.keys(agent.sockets).length, 1); assert.strictEqual(Object.keys(agent.sockets).length, 1);
assert.equal(Object.keys(agent.requests).length, 1); assert.strictEqual(Object.keys(agent.requests).length, 1);
console.log('Got res: ' + res1.statusCode); console.log('Got res: ' + res1.statusCode);
console.dir(res1.headers); console.dir(res1.headers);
@ -72,8 +72,8 @@ server.listen(0, function() {
console.log('Response ended.'); console.log('Response ended.');
setTimeout(function() { setTimeout(function() {
assert.equal(Object.keys(agent.sockets).length, 0); assert.strictEqual(Object.keys(agent.sockets).length, 0);
assert.equal(Object.keys(agent.requests).length, 0); assert.strictEqual(Object.keys(agent.requests).length, 0);
server.close(); server.close();
}, 100); }, 100);

6
test/parallel/test-http-agent-error-on-idle.js

@ -23,12 +23,12 @@ server.listen(0, function() {
const socketKey = agent.getName(requestParams); const socketKey = agent.getName(requestParams);
get(function(res) { get(function(res) {
assert.equal(res.statusCode, 200); assert.strictEqual(res.statusCode, 200);
res.resume(); res.resume();
res.on('end', function() { res.on('end', function() {
process.nextTick(function() { process.nextTick(function() {
const freeSockets = agent.freeSockets[socketKey]; const freeSockets = agent.freeSockets[socketKey];
assert.equal(freeSockets.length, 1, assert.strictEqual(freeSockets.length, 1,
'expect a free socket on ' + socketKey); 'expect a free socket on ' + socketKey);
//generate a random error on the free socket //generate a random error on the free socket
@ -45,7 +45,7 @@ server.listen(0, function() {
} }
function done() { function done() {
assert.equal(Object.keys(agent.freeSockets).length, 0, assert.strictEqual(Object.keys(agent.freeSockets).length, 0,
'expect the freeSockets pool to be empty'); 'expect the freeSockets pool to be empty');
agent.destroy(); agent.destroy();

48
test/parallel/test-http-agent-keepalive.js

@ -37,22 +37,22 @@ function get(path, callback) {
} }
function checkDataAndSockets(body) { function checkDataAndSockets(body) {
assert.equal(body.toString(), 'hello world'); assert.strictEqual(body.toString(), 'hello world');
assert.equal(agent.sockets[name].length, 1); assert.strictEqual(agent.sockets[name].length, 1);
assert.equal(agent.freeSockets[name], undefined); assert.strictEqual(agent.freeSockets[name], undefined);
} }
function second() { function second() {
// request second, use the same socket // request second, use the same socket
get('/second', function(res) { get('/second', function(res) {
assert.equal(res.statusCode, 200); assert.strictEqual(res.statusCode, 200);
res.on('data', checkDataAndSockets); res.on('data', checkDataAndSockets);
res.on('end', function() { res.on('end', function() {
assert.equal(agent.sockets[name].length, 1); assert.strictEqual(agent.sockets[name].length, 1);
assert.equal(agent.freeSockets[name], undefined); assert.strictEqual(agent.freeSockets[name], undefined);
process.nextTick(function() { process.nextTick(function() {
assert.equal(agent.sockets[name], undefined); assert.strictEqual(agent.sockets[name], undefined);
assert.equal(agent.freeSockets[name].length, 1); assert.strictEqual(agent.freeSockets[name].length, 1);
remoteClose(); remoteClose();
}); });
}); });
@ -65,15 +65,15 @@ function remoteClose() {
assert.deepStrictEqual(res.statusCode, 200); assert.deepStrictEqual(res.statusCode, 200);
res.on('data', checkDataAndSockets); res.on('data', checkDataAndSockets);
res.on('end', function() { res.on('end', function() {
assert.equal(agent.sockets[name].length, 1); assert.strictEqual(agent.sockets[name].length, 1);
assert.equal(agent.freeSockets[name], undefined); assert.strictEqual(agent.freeSockets[name], undefined);
process.nextTick(function() { process.nextTick(function() {
assert.equal(agent.sockets[name], undefined); assert.strictEqual(agent.sockets[name], undefined);
assert.equal(agent.freeSockets[name].length, 1); assert.strictEqual(agent.freeSockets[name].length, 1);
// waitting remote server close the socket // waitting remote server close the socket
setTimeout(function() { setTimeout(function() {
assert.equal(agent.sockets[name], undefined); assert.strictEqual(agent.sockets[name], undefined);
assert.equal(agent.freeSockets[name], undefined, assert.strictEqual(agent.freeSockets[name], undefined,
'freeSockets is not empty'); 'freeSockets is not empty');
remoteError(); remoteError();
}, common.platformTimeout(200)); }, common.platformTimeout(200));
@ -89,13 +89,13 @@ function remoteError() {
}); });
req.on('error', function(err) { req.on('error', function(err) {
assert.ok(err); assert.ok(err);
assert.equal(err.message, 'socket hang up'); assert.strictEqual(err.message, 'socket hang up');
assert.equal(agent.sockets[name].length, 1); assert.strictEqual(agent.sockets[name].length, 1);
assert.equal(agent.freeSockets[name], undefined); assert.strictEqual(agent.freeSockets[name], undefined);
// Wait socket 'close' event emit // Wait socket 'close' event emit
setTimeout(function() { setTimeout(function() {
assert.equal(agent.sockets[name], undefined); assert.strictEqual(agent.sockets[name], undefined);
assert.equal(agent.freeSockets[name], undefined); assert.strictEqual(agent.freeSockets[name], undefined);
done(); done();
}, common.platformTimeout(1)); }, common.platformTimeout(1));
}); });
@ -110,14 +110,14 @@ server.listen(0, function() {
name = `localhost:${server.address().port}:`; name = `localhost:${server.address().port}:`;
// request first, and keep alive // request first, and keep alive
get('/first', function(res) { get('/first', function(res) {
assert.equal(res.statusCode, 200); assert.strictEqual(res.statusCode, 200);
res.on('data', checkDataAndSockets); res.on('data', checkDataAndSockets);
res.on('end', function() { res.on('end', function() {
assert.equal(agent.sockets[name].length, 1); assert.strictEqual(agent.sockets[name].length, 1);
assert.equal(agent.freeSockets[name], undefined); assert.strictEqual(agent.freeSockets[name], undefined);
process.nextTick(function() { process.nextTick(function() {
assert.equal(agent.sockets[name], undefined); assert.strictEqual(agent.sockets[name], undefined);
assert.equal(agent.freeSockets[name].length, 1); assert.strictEqual(agent.freeSockets[name].length, 1);
second(); second();
}); });
}); });

6
test/parallel/test-http-agent-maxsockets.js

@ -29,7 +29,7 @@ function done() {
return; return;
} }
const freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]]; const freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]];
assert.equal(freepool.length, 2, assert.strictEqual(freepool.length, 2,
'expect keep 2 free sockets, but got ' + freepool.length); 'expect keep 2 free sockets, but got ' + freepool.length);
agent.destroy(); agent.destroy();
server.close(); server.close();
@ -37,7 +37,7 @@ function done() {
server.listen(0, function() { server.listen(0, function() {
get('/1', function(res) { get('/1', function(res) {
assert.equal(res.statusCode, 200); assert.strictEqual(res.statusCode, 200);
res.resume(); res.resume();
res.on('end', function() { res.on('end', function() {
process.nextTick(done); process.nextTick(done);
@ -45,7 +45,7 @@ server.listen(0, function() {
}); });
get('/2', function(res) { get('/2', function(res) {
assert.equal(res.statusCode, 200); assert.strictEqual(res.statusCode, 200);
res.resume(); res.resume();
res.on('end', function() { res.on('end', function() {
process.nextTick(done); process.nextTick(done);

2
test/parallel/test-http-agent.js

@ -35,5 +35,5 @@ server.listen(0, function() {
process.on('exit', function() { process.on('exit', function() {
assert.equal(N * M, responses); assert.strictEqual(N * M, responses);
}); });

12
test/parallel/test-http-automatic-headers.js

@ -18,13 +18,13 @@ server.on('listening', function() {
path: '/hello', path: '/hello',
agent: agent agent: agent
}, function(res) { }, function(res) {
assert.equal(res.statusCode, 200); assert.strictEqual(res.statusCode, 200);
assert.equal(res.headers['x-date'], 'foo'); assert.strictEqual(res.headers['x-date'], 'foo');
assert.equal(res.headers['x-connection'], 'bar'); assert.strictEqual(res.headers['x-connection'], 'bar');
assert.equal(res.headers['x-content-length'], 'baz'); assert.strictEqual(res.headers['x-content-length'], 'baz');
assert(res.headers['date']); assert(res.headers['date']);
assert.equal(res.headers['connection'], 'keep-alive'); assert.strictEqual(res.headers['connection'], 'keep-alive');
assert.equal(res.headers['content-length'], '0'); assert.strictEqual(res.headers['content-length'], '0');
server.close(); server.close();
agent.destroy(); agent.destroy();
}); });

4
test/parallel/test-http-blank-header.js

@ -5,8 +5,8 @@ const http = require('http');
const net = require('net'); const net = require('net');
const server = http.createServer(common.mustCall(function(req, res) { const server = http.createServer(common.mustCall(function(req, res) {
assert.equal('GET', req.method); assert.strictEqual('GET', req.method);
assert.equal('/blah', req.url); assert.strictEqual('/blah', req.url);
assert.deepStrictEqual({ assert.deepStrictEqual({
host: 'mapdevel.trolologames.ru:443', host: 'mapdevel.trolologames.ru:443',
origin: 'http://mapdevel.trolologames.ru', origin: 'http://mapdevel.trolologames.ru',

6
test/parallel/test-http-buffer-sanity.js

@ -23,7 +23,7 @@ const web = http.Server(function(req, res) {
process.stdout.write(','); process.stdout.write(',');
measuredSize += d.length; measuredSize += d.length;
for (let j = 0; j < d.length; j++) { for (let j = 0; j < d.length; j++) {
assert.equal(buffer[i], d[j]); assert.strictEqual(buffer[i], d[j]);
i++; i++;
} }
}); });
@ -54,7 +54,7 @@ web.listen(0, common.mustCall(function() {
console.log('Got response'); console.log('Got response');
res.setEncoding('utf8'); res.setEncoding('utf8');
res.on('data', common.mustCall(function(string) { res.on('data', common.mustCall(function(string) {
assert.equal('thanks', string); assert.strictEqual('thanks', string);
})); }));
})); }));
req.end(buffer); req.end(buffer);
@ -62,5 +62,5 @@ web.listen(0, common.mustCall(function() {
process.on('exit', function() { process.on('exit', function() {
assert.equal(bufferSize, measuredSize); assert.strictEqual(bufferSize, measuredSize);
}); });

2
test/parallel/test-http-catch-uncaughtexception.js

@ -5,7 +5,7 @@ const assert = require('assert');
const http = require('http'); const http = require('http');
const uncaughtCallback = common.mustCall(function(er) { const uncaughtCallback = common.mustCall(function(er) {
assert.equal(er.message, 'get did fail'); assert.strictEqual(er.message, 'get did fail');
}); });
process.on('uncaughtException', uncaughtCallback); process.on('uncaughtException', uncaughtCallback);

2
test/parallel/test-http-chunk-problem.js

@ -52,7 +52,7 @@ function executeRequest(cb) {
'shasum' ].join(' '), 'shasum' ].join(' '),
(err, stdout, stderr) => { (err, stdout, stderr) => {
assert.ifError(err); assert.ifError(err);
assert.equal('8c206a1a87599f532ce68675536f0b1546900d7a', assert.strictEqual('8c206a1a87599f532ce68675536f0b1546900d7a',
stdout.slice(0, 40)); stdout.slice(0, 40));
cb(); cb();
} }

4
test/parallel/test-http-chunked.js

@ -30,9 +30,9 @@ server.listen(0, function() {
throw e; throw e;
}); });
x.on('end', function() { x.on('end', function() {
assert.equal('string', typeof data); assert.strictEqual('string', typeof data);
console.log('here is the response:'); console.log('here is the response:');
assert.equal(UTF8_STRING, data); assert.strictEqual(UTF8_STRING, data);
console.log(data); console.log(data);
server.close(); server.close();
}); });

2
test/parallel/test-http-client-abort.js

@ -51,5 +51,5 @@ server.listen(0, function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(N, clientAborts); assert.strictEqual(N, clientAborts);
}); });

4
test/parallel/test-http-client-agent.js

@ -34,7 +34,7 @@ function request(i) {
socket.on('close', function() { socket.on('close', function() {
++count; ++count;
if (count < max) { if (count < max) {
assert.equal(http.globalAgent.sockets[name].indexOf(socket), -1); assert.strictEqual(http.globalAgent.sockets[name].indexOf(socket), -1);
} else { } else {
assert(!http.globalAgent.sockets.hasOwnProperty(name)); assert(!http.globalAgent.sockets.hasOwnProperty(name));
assert(!http.globalAgent.requests.hasOwnProperty(name)); assert(!http.globalAgent.requests.hasOwnProperty(name));
@ -46,5 +46,5 @@ function request(i) {
} }
process.on('exit', function() { process.on('exit', function() {
assert.equal(count, max); assert.strictEqual(count, max);
}); });

4
test/parallel/test-http-client-get-url.js

@ -6,8 +6,8 @@ const url = require('url');
const URL = url.URL; const URL = url.URL;
const server = http.createServer(common.mustCall(function(req, res) { const server = http.createServer(common.mustCall(function(req, res) {
assert.equal('GET', req.method); assert.strictEqual('GET', req.method);
assert.equal('/foo?bar', req.url); assert.strictEqual('/foo?bar', req.url);
res.writeHead(200, {'Content-Type': 'text/plain'}); res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello\n'); res.write('hello\n');
res.end(); res.end();

6
test/parallel/test-http-client-parse-error.js

@ -27,13 +27,13 @@ net.createServer(function(c) {
}).on('error', function(e) { }).on('error', function(e) {
console.log('got error from client'); console.log('got error from client');
assert.ok(e.message.indexOf('Parse Error') >= 0); assert.ok(e.message.indexOf('Parse Error') >= 0);
assert.equal(e.code, 'HPE_INVALID_CONSTANT'); assert.strictEqual(e.code, 'HPE_INVALID_CONSTANT');
parseErrors++; parseErrors++;
}).end(); }).end();
} }
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(connects, 2); assert.strictEqual(connects, 2);
assert.equal(parseErrors, 2); assert.strictEqual(parseErrors, 2);
}); });

6
test/parallel/test-http-client-race-2.js

@ -83,7 +83,7 @@ server.on('listening', function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(body1_s, body1); assert.strictEqual(body1_s, body1);
assert.equal(body2_s, body2); assert.strictEqual(body2_s, body2);
assert.equal(body3_s, body3); assert.strictEqual(body3_s, body3);
}); });

4
test/parallel/test-http-client-race.js

@ -41,6 +41,6 @@ server.on('listening', function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(body1_s, body1); assert.strictEqual(body1_s, body1);
assert.equal(body2_s, body2); assert.strictEqual(body2_s, body2);
}); });

2
test/parallel/test-http-client-reject-chunked-with-content-length.js

@ -22,7 +22,7 @@ server.listen(0, () => {
}); });
req.on('error', common.mustCall((err) => { req.on('error', common.mustCall((err) => {
assert(/^Parse Error/.test(err.message)); assert(/^Parse Error/.test(err.message));
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
server.close(); server.close();
})); }));
}); });

2
test/parallel/test-http-client-reject-cr-no-lf.js

@ -21,7 +21,7 @@ server.listen(0, () => {
}); });
req.on('error', common.mustCall((err) => { req.on('error', common.mustCall((err) => {
assert(/^Parse Error/.test(err.message)); assert(/^Parse Error/.test(err.message));
assert.equal(err.code, 'HPE_LF_EXPECTED'); assert.strictEqual(err.code, 'HPE_LF_EXPECTED');
server.close(); server.close();
})); }));
}); });

2
test/parallel/test-http-client-response-domain.js

@ -23,7 +23,7 @@ server.listen(common.PIPE, function() {
function test() { function test() {
d.on('error', common.mustCall(function(err) { d.on('error', common.mustCall(function(err) {
assert.equal('should be caught by domain', err.message); assert.strictEqual('should be caught by domain', err.message);
})); }));
const req = http.get({ const req = http.get({

2
test/parallel/test-http-client-upload-buf.js

@ -6,7 +6,7 @@ const http = require('http');
const N = 1024; const N = 1024;
const server = http.createServer(common.mustCall(function(req, res) { const server = http.createServer(common.mustCall(function(req, res) {
assert.equal('POST', req.method); assert.strictEqual('POST', req.method);
let bytesReceived = 0; let bytesReceived = 0;

2
test/parallel/test-http-client-upload.js

@ -4,7 +4,7 @@ const assert = require('assert');
const http = require('http'); const http = require('http');
const server = http.createServer(common.mustCall(function(req, res) { const server = http.createServer(common.mustCall(function(req, res) {
assert.equal('POST', req.method); assert.strictEqual('POST', req.method);
req.setEncoding('utf8'); req.setEncoding('utf8');
let sent_body = ''; let sent_body = '';

2
test/parallel/test-http-conn-reset.js

@ -23,7 +23,7 @@ function onListen() {
assert.ok(false, 'this should never run'); assert.ok(false, 'this should never run');
}); });
req.on('error', common.mustCall(function(err) { req.on('error', common.mustCall(function(err) {
assert.equal(err.code, 'ECONNRESET'); assert.strictEqual(err.code, 'ECONNRESET');
})); }));
req.end(); req.end();
} }

12
test/parallel/test-http-connect-req-res.js

@ -5,8 +5,8 @@ const http = require('http');
const server = http.createServer(common.fail); const server = http.createServer(common.fail);
server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) { server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) {
assert.equal(req.method, 'CONNECT'); assert.strictEqual(req.method, 'CONNECT');
assert.equal(req.url, 'example.com:443'); assert.strictEqual(req.url, 'example.com:443');
console.error('Server got CONNECT request'); console.error('Server got CONNECT request');
// It is legal for the server to send some data intended for the client // It is legal for the server to send some data intended for the client
@ -46,19 +46,19 @@ server.listen(0, common.mustCall(function() {
// Make sure this socket has detached. // Make sure this socket has detached.
assert(!socket.ondata); assert(!socket.ondata);
assert(!socket.onend); assert(!socket.onend);
assert.equal(socket.listeners('connect').length, 0); assert.strictEqual(socket.listeners('connect').length, 0);
assert.equal(socket.listeners('data').length, 0); assert.strictEqual(socket.listeners('data').length, 0);
let data = firstBodyChunk.toString(); let data = firstBodyChunk.toString();
// test that the firstBodyChunk was not parsed as HTTP // test that the firstBodyChunk was not parsed as HTTP
assert.equal(data, 'Head'); assert.strictEqual(data, 'Head');
socket.on('data', function(buf) { socket.on('data', function(buf) {
data += buf.toString(); data += buf.toString();
}); });
socket.on('end', function() { socket.on('end', function() {
assert.equal(data, 'HeadRequestEnd'); assert.strictEqual(data, 'HeadRequestEnd');
server.close(); server.close();
}); });
socket.end('End'); socket.end('End');

2
test/parallel/test-http-createConnection.js

@ -23,7 +23,7 @@ const server = http.createServer(common.mustCall(function(req, res) {
http.get({ createConnection: fn }, function(res) { http.get({ createConnection: fn }, function(res) {
common.fail('Unexpected response callback'); common.fail('Unexpected response callback');
}).on('error', common.mustCall(function(err) { }).on('error', common.mustCall(function(err) {
assert.equal(err.message, 'Could not create socket'); assert.strictEqual(err.message, 'Could not create socket');
server.close(); server.close();
})); }));
}); });

2
test/parallel/test-http-default-encoding.js

@ -33,5 +33,5 @@ server.listen(0, function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(expected, result); assert.strictEqual(expected, result);
}); });

8
test/parallel/test-http-default-port.js

@ -29,8 +29,8 @@ process.on('exit', function() {
}); });
http.createServer(function(req, res) { http.createServer(function(req, res) {
assert.equal(req.headers.host, hostExpect); assert.strictEqual(req.headers.host, hostExpect);
assert.equal(req.headers['x-port'], this.address().port); assert.strictEqual(req.headers['x-port'], this.address().port.toString());
res.writeHead(200); res.writeHead(200);
res.end('ok'); res.end('ok');
this.close(); this.close();
@ -49,8 +49,8 @@ http.createServer(function(req, res) {
if (common.hasCrypto) { if (common.hasCrypto) {
https.createServer(options, function(req, res) { https.createServer(options, function(req, res) {
assert.equal(req.headers.host, hostExpect); assert.strictEqual(req.headers.host, hostExpect);
assert.equal(req.headers['x-port'], this.address().port); assert.strictEqual(req.headers['x-port'], this.address().port.toString());
res.writeHead(200); res.writeHead(200);
res.end('ok'); res.end('ok');
this.close(); this.close();

4
test/parallel/test-http-destroyed-socket-write2.js

@ -47,8 +47,8 @@ server.listen(0, function() {
break; break;
} }
assert.equal(req.output.length, 0); assert.strictEqual(req.output.length, 0);
assert.equal(req.outputEncodings.length, 0); assert.strictEqual(req.outputEncodings.length, 0);
server.close(); server.close();
})); }));

2
test/parallel/test-http-double-content-length.js

@ -13,7 +13,7 @@ const server = http.createServer((req, res) => {
}); });
server.on('clientError', common.mustCall((err, socket) => { server.on('clientError', common.mustCall((err, socket) => {
assert(/^Parse Error/.test(err.message)); assert(/^Parse Error/.test(err.message));
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
socket.destroy(); socket.destroy();
})); }));

11
test/parallel/test-http-expect-continue.js

@ -10,7 +10,8 @@ let sent_continue = false;
let got_continue = false; let got_continue = false;
function handler(req, res) { function handler(req, res) {
assert.equal(sent_continue, true, 'Full response sent before 100 Continue'); assert.strictEqual(sent_continue, true, 'Full response sent before ' +
'100 Continue');
console.error('Server sending full response...'); console.error('Server sending full response...');
res.writeHead(200, { res.writeHead(200, {
'Content-Type': 'text/plain', 'Content-Type': 'text/plain',
@ -47,15 +48,15 @@ server.on('listening', function() {
req.end(test_req_body); req.end(test_req_body);
}); });
req.on('response', function(res) { req.on('response', function(res) {
assert.equal(got_continue, true, assert.strictEqual(got_continue, true,
'Full response received before 100 Continue'); 'Full response received before 100 Continue');
assert.equal(200, res.statusCode, assert.strictEqual(200, res.statusCode, 'Final status code was ' +
'Final status code was ' + res.statusCode + ', not 200.'); res.statusCode + ', not 200.');
res.setEncoding('utf8'); res.setEncoding('utf8');
res.on('data', function(chunk) { body += chunk; }); res.on('data', function(chunk) { body += chunk; });
res.on('end', function() { res.on('end', function() {
console.error('Got full response.'); console.error('Got full response.');
assert.equal(body, test_res_body, 'Response body doesn\'t match.'); assert.strictEqual(body, test_res_body, 'Response body doesn\'t match.');
assert.ok('abcd' in res.headers, 'Response headers missing.'); assert.ok('abcd' in res.headers, 'Response headers missing.');
outstanding_reqs--; outstanding_reqs--;
if (outstanding_reqs === 0) { if (outstanding_reqs === 0) {

6
test/parallel/test-http-expect-handling.js

@ -37,8 +37,8 @@ function nextTest() {
http.get(options, function(response) { http.get(options, function(response) {
console.log('client: expected status: ' + test); console.log('client: expected status: ' + test);
console.log('client: statusCode: ' + response.statusCode); console.log('client: statusCode: ' + response.statusCode);
assert.equal(response.statusCode, test); assert.strictEqual(response.statusCode, test);
assert.equal(response.statusMessage, 'Expectation Failed'); assert.strictEqual(response.statusMessage, 'Expectation Failed');
response.on('end', function() { response.on('end', function() {
testsComplete++; testsComplete++;
@ -51,5 +51,5 @@ function nextTest() {
process.on('exit', function() { process.on('exit', function() {
assert.equal(2, testsComplete); assert.strictEqual(2, testsComplete);
}); });

4
test/parallel/test-http-extra-response.js

@ -36,7 +36,7 @@ const server = net.createServer(function(socket) {
}); });
socket.on('error', function(err) { socket.on('error', function(err) {
assert.equal(err.code, 'ECONNRESET'); assert.strictEqual(err.code, 'ECONNRESET');
}); });
}); });
@ -53,7 +53,7 @@ server.listen(0, common.mustCall(function() {
res.on('end', common.mustCall(function() { res.on('end', common.mustCall(function() {
console.log('Response ended, read ' + buffer.length + ' bytes'); console.log('Response ended, read ' + buffer.length + ' bytes');
assert.equal(body, buffer); assert.strictEqual(body, buffer);
server.close(); server.close();
})); }));
})); }));

2
test/parallel/test-http-flush-headers.js

@ -5,7 +5,7 @@ const http = require('http');
const server = http.createServer(); const server = http.createServer();
server.on('request', function(req, res) { server.on('request', function(req, res) {
assert.equal(req.headers['foo'], 'bar'); assert.strictEqual(req.headers['foo'], 'bar');
res.end('ok'); res.end('ok');
server.close(); server.close();
}); });

2
test/parallel/test-http-flush-response-headers.js

@ -20,7 +20,7 @@ server.listen(0, common.localhostIPv4, function() {
req.end(); req.end();
function onResponse(res) { function onResponse(res) {
assert.equal(res.headers['foo'], 'bar'); assert.strictEqual(res.headers['foo'], 'bar');
res.destroy(); res.destroy();
server.close(); server.close();
} }

4
test/parallel/test-http-full-response.js

@ -38,8 +38,8 @@ function runAb(opts, callback) {
m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout); m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout);
const htmlTransfered = parseInt(m[1]); const htmlTransfered = parseInt(m[1]);
assert.equal(bodyLength, documentLength); assert.strictEqual(bodyLength, documentLength);
assert.equal(completeRequests * documentLength, htmlTransfered); assert.strictEqual(completeRequests * documentLength, htmlTransfered);
if (callback) callback(); if (callback) callback();
}); });

6
test/parallel/test-http-get-pipeline-problem.js

@ -74,7 +74,7 @@ function checkFiles() {
const fn = i + '.jpg'; const fn = i + '.jpg';
assert.ok(files.indexOf(fn) >= 0, "couldn't find '" + fn + "'"); assert.ok(files.indexOf(fn) >= 0, "couldn't find '" + fn + "'");
const stat = fs.statSync(common.tmpDir + '/' + fn); const stat = fs.statSync(common.tmpDir + '/' + fn);
assert.equal(image.length, stat.size, assert.strictEqual(image.length, stat.size,
"size doesn't match on '" + fn + "size doesn't match on '" + fn +
"'. Got " + stat.size + ' bytes'); "'. Got " + stat.size + ' bytes');
} }
@ -84,7 +84,7 @@ function checkFiles() {
process.on('exit', function() { process.on('exit', function() {
assert.equal(total, requests); assert.strictEqual(total, requests);
assert.equal(total, responses); assert.strictEqual(total, responses);
assert.ok(checkedFiles); assert.ok(checkedFiles);
}); });

2
test/parallel/test-http-header-read.js

@ -18,7 +18,7 @@ const s = http.createServer(function(req, res) {
// and does not throw an exception (Issue 752) // and does not throw an exception (Issue 752)
assert.doesNotThrow( assert.doesNotThrow(
function() { function() {
assert.equal(plain, res.getHeader(contentType)); assert.strictEqual(plain, res.getHeader(contentType));
} }
); );
}); });

4
test/parallel/test-http-host-headers.js

@ -7,9 +7,9 @@ const httpServer = http.createServer(reqHandler);
function reqHandler(req, res) { function reqHandler(req, res) {
console.log('Got request: ' + req.headers.host + ' ' + req.url); console.log('Got request: ' + req.headers.host + ' ' + req.url);
if (req.url === '/setHostFalse5') { if (req.url === '/setHostFalse5') {
assert.equal(req.headers.host, undefined); assert.strictEqual(req.headers.host, undefined);
} else { } else {
assert.equal(req.headers.host, `localhost:${this.address().port}`, assert.strictEqual(req.headers.host, `localhost:${this.address().port}`,
'Wrong host header for req[' + req.url + ']: ' + 'Wrong host header for req[' + req.url + ']: ' +
req.headers.host); req.headers.host);
} }

8
test/parallel/test-http-keep-alive-close-on-header.js

@ -25,7 +25,7 @@ server.listen(0, function() {
port: this.address().port, port: this.address().port,
agent: agent agent: agent
}, function(res) { }, function(res) {
assert.equal(1, agent.sockets[name].length); assert.strictEqual(1, agent.sockets[name].length);
res.resume(); res.resume();
}); });
request.on('socket', function(s) { request.on('socket', function(s) {
@ -42,7 +42,7 @@ server.listen(0, function() {
port: this.address().port, port: this.address().port,
agent: agent agent: agent
}, function(res) { }, function(res) {
assert.equal(1, agent.sockets[name].length); assert.strictEqual(1, agent.sockets[name].length);
res.resume(); res.resume();
}); });
request.on('socket', function(s) { request.on('socket', function(s) {
@ -59,7 +59,7 @@ server.listen(0, function() {
agent: agent agent: agent
}, function(response) { }, function(response) {
response.on('end', function() { response.on('end', function() {
assert.equal(1, agent.sockets[name].length); assert.strictEqual(1, agent.sockets[name].length);
server.close(); server.close();
}); });
response.resume(); response.resume();
@ -73,5 +73,5 @@ server.listen(0, function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(3, connectCount); assert.strictEqual(3, connectCount);
}); });

8
test/parallel/test-http-keepalive-client.js

@ -9,7 +9,7 @@ let serverSocket = null;
const server = http.createServer(function(req, res) { const server = http.createServer(function(req, res) {
// They should all come in on the same server socket. // They should all come in on the same server socket.
if (serverSocket) { if (serverSocket) {
assert.equal(req.socket, serverSocket); assert.strictEqual(req.socket, serverSocket);
} else { } else {
serverSocket = req.socket; serverSocket = req.socket;
} }
@ -45,7 +45,7 @@ function makeRequest(n) {
req.on('socket', function(sock) { req.on('socket', function(sock) {
if (clientSocket) { if (clientSocket) {
assert.equal(sock, clientSocket); assert.strictEqual(sock, clientSocket);
} else { } else {
clientSocket = sock; clientSocket = sock;
} }
@ -58,7 +58,7 @@ function makeRequest(n) {
data += c; data += c;
}); });
res.on('end', function() { res.on('end', function() {
assert.equal(data, '/' + n); assert.strictEqual(data, '/' + n);
setTimeout(function() { setTimeout(function() {
actualRequests++; actualRequests++;
makeRequest(n - 1); makeRequest(n - 1);
@ -68,6 +68,6 @@ function makeRequest(n) {
} }
process.on('exit', function() { process.on('exit', function() {
assert.equal(actualRequests, expectRequests); assert.strictEqual(actualRequests, expectRequests);
console.log('ok'); console.log('ok');
}); });

14
test/parallel/test-http-keepalive-maxsockets.js

@ -22,17 +22,17 @@ server.listen(0, function() {
let closed = false; let closed = false;
makeReqs(10, function(er) { makeReqs(10, function(er) {
assert.ifError(er); assert.ifError(er);
assert.equal(count(agent.freeSockets), 2); assert.strictEqual(count(agent.freeSockets), 2);
assert.equal(count(agent.sockets), 0); assert.strictEqual(count(agent.sockets), 0);
assert.equal(serverSockets.length, 5); assert.strictEqual(serverSockets.length, 5);
// now make 10 more reqs. // now make 10 more reqs.
// should use the 2 free reqs from the pool first. // should use the 2 free reqs from the pool first.
makeReqs(10, function(er) { makeReqs(10, function(er) {
assert.ifError(er); assert.ifError(er);
assert.equal(count(agent.freeSockets), 2); assert.strictEqual(count(agent.freeSockets), 2);
assert.equal(count(agent.sockets), 0); assert.strictEqual(count(agent.sockets), 0);
assert.equal(serverSockets.length, 8); assert.strictEqual(serverSockets.length, 8);
agent.destroy(); agent.destroy();
server.close(function() { server.close(function() {
@ -72,7 +72,7 @@ server.listen(0, function() {
data += c; data += c;
}); });
res.on('end', function() { res.on('end', function() {
assert.equal(data, '/' + i); assert.strictEqual(data, '/' + i);
cb(); cb();
}); });
}).end(); }).end();

8
test/parallel/test-http-keepalive-request.js

@ -9,7 +9,7 @@ let serverSocket = null;
const server = http.createServer(function(req, res) { const server = http.createServer(function(req, res) {
// They should all come in on the same server socket. // They should all come in on the same server socket.
if (serverSocket) { if (serverSocket) {
assert.equal(req.socket, serverSocket); assert.strictEqual(req.socket, serverSocket);
} else { } else {
serverSocket = req.socket; serverSocket = req.socket;
} }
@ -45,7 +45,7 @@ function makeRequest(n) {
req.on('socket', function(sock) { req.on('socket', function(sock) {
if (clientSocket) { if (clientSocket) {
assert.equal(sock, clientSocket); assert.strictEqual(sock, clientSocket);
} else { } else {
clientSocket = sock; clientSocket = sock;
} }
@ -58,7 +58,7 @@ function makeRequest(n) {
data += c; data += c;
}); });
res.on('end', function() { res.on('end', function() {
assert.equal(data, '/' + n); assert.strictEqual(data, '/' + n);
setTimeout(function() { setTimeout(function() {
actualRequests++; actualRequests++;
makeRequest(n - 1); makeRequest(n - 1);
@ -68,6 +68,6 @@ function makeRequest(n) {
} }
process.on('exit', function() { process.on('exit', function() {
assert.equal(actualRequests, expectRequests); assert.strictEqual(actualRequests, expectRequests);
console.log('ok'); console.log('ok');
}); });

2
test/parallel/test-http-localaddress.js

@ -10,7 +10,7 @@ if (!common.hasMultiLocalhost()) {
const server = http.createServer(function(req, res) { const server = http.createServer(function(req, res) {
console.log('Connect from: ' + req.connection.remoteAddress); console.log('Connect from: ' + req.connection.remoteAddress);
assert.equal('127.0.0.2', req.connection.remoteAddress); assert.strictEqual('127.0.0.2', req.connection.remoteAddress);
req.on('end', function() { req.on('end', function() {
res.writeHead(200, { 'Content-Type': 'text/plain' }); res.writeHead(200, { 'Content-Type': 'text/plain' });

2
test/parallel/test-http-malformed-request.js

@ -31,5 +31,5 @@ server.on('listening', function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(nrequests_expected, nrequests_completed); assert.strictEqual(nrequests_expected, nrequests_completed);
}); });

8
test/parallel/test-http-max-headers-count.js

@ -21,7 +21,7 @@ let max = maxAndExpected[requests][0];
let expected = maxAndExpected[requests][1]; let expected = maxAndExpected[requests][1];
const server = http.createServer(function(req, res) { const server = http.createServer(function(req, res) {
assert.equal(Object.keys(req.headers).length, expected); assert.strictEqual(Object.keys(req.headers).length, expected);
if (++requests < maxAndExpected.length) { if (++requests < maxAndExpected.length) {
max = maxAndExpected[requests][0]; max = maxAndExpected[requests][0];
expected = maxAndExpected[requests][1]; expected = maxAndExpected[requests][1];
@ -47,7 +47,7 @@ server.listen(0, function() {
port: server.address().port, port: server.address().port,
headers: headers headers: headers
}, function(res) { }, function(res) {
assert.equal(Object.keys(res.headers).length, expected); assert.strictEqual(Object.keys(res.headers).length, expected);
res.on('end', function() { res.on('end', function() {
if (++responses < maxAndExpected.length) { if (++responses < maxAndExpected.length) {
doRequest(); doRequest();
@ -63,6 +63,6 @@ server.listen(0, function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(requests, maxAndExpected.length); assert.strictEqual(requests, maxAndExpected.length);
assert.equal(responses, maxAndExpected.length); assert.strictEqual(responses, maxAndExpected.length);
}); });

2
test/parallel/test-http-multi-line-headers.js

@ -27,7 +27,7 @@ server.listen(0, common.mustCall(function() {
host: '127.0.0.1', host: '127.0.0.1',
port: this.address().port port: this.address().port
}, common.mustCall(function(res) { }, common.mustCall(function(res) {
assert.equal(res.headers['content-type'], assert.strictEqual(res.headers['content-type'],
'text/plain; x-unix-mode=0600; name="hello.txt"'); 'text/plain; x-unix-mode=0600; name="hello.txt"');
res.destroy(); res.destroy();
})); }));

4
test/parallel/test-http-parser-bad-ref.js

@ -83,7 +83,7 @@ demoBug('POST /1/22 HTTP/1.1\r\n' +
/* eslint-enable align-function-arguments */ /* eslint-enable align-function-arguments */
process.on('exit', function() { process.on('exit', function() {
assert.equal(2, headersComplete); assert.strictEqual(2, headersComplete);
assert.equal(2, messagesComplete); assert.strictEqual(2, messagesComplete);
console.log('done!'); console.log('done!');
}); });

2
test/parallel/test-http-parser-free.js

@ -31,5 +31,5 @@ server.listen(0, function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(responses, N); assert.strictEqual(responses, N);
}); });

12
test/parallel/test-http-parser.js

@ -51,7 +51,7 @@ function mustCall(f, times) {
process.setMaxListeners(256); process.setMaxListeners(256);
process.on('exit', function() { process.on('exit', function() {
assert.equal(actual, times || 1); assert.strictEqual(actual, times || 1);
}); });
return function() { return function() {
@ -64,7 +64,7 @@ function mustCall(f, times) {
function expectBody(expected) { function expectBody(expected) {
return mustCall(function(buf, start, len) { return mustCall(function(buf, start, len) {
const body = '' + buf.slice(start, start + len); const body = '' + buf.slice(start, start + len);
assert.equal(body, expected); assert.strictEqual(body, expected);
}); });
} }
@ -535,10 +535,10 @@ function expectBody(expected) {
const onHeadersComplete1 = function(versionMajor, versionMinor, headers, const onHeadersComplete1 = function(versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage, method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) { upgrade, shouldKeepAlive) {
assert.equal(method, methods.indexOf('PUT')); assert.strictEqual(method, methods.indexOf('PUT'));
assert.equal(url, '/this'); assert.strictEqual(url, '/this');
assert.equal(versionMajor, 1); assert.strictEqual(versionMajor, 1);
assert.equal(versionMinor, 1); assert.strictEqual(versionMinor, 1);
assert.deepStrictEqual( assert.deepStrictEqual(
headers, headers,
['Content-Type', 'text/plain', 'Transfer-Encoding', 'chunked']); ['Content-Type', 'text/plain', 'Transfer-Encoding', 'chunked']);

4
test/parallel/test-http-pause.js

@ -50,6 +50,6 @@ server.listen(0, function() {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(expectedServer, resultServer); assert.strictEqual(expectedServer, resultServer);
assert.equal(expectedClient, resultClient); assert.strictEqual(expectedClient, resultClient);
}); });

2
test/parallel/test-http-pipeline-regr-2639.js

@ -29,5 +29,5 @@ const server = http.createServer(function(req, res) {
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(received, COUNT); assert.strictEqual(received, COUNT);
}); });

2
test/parallel/test-http-pipeline-regr-3332.js

@ -36,5 +36,5 @@ process.on('exit', function() {
// The server should pause connection on pipeline flood, but it shoul still // The server should pause connection on pipeline flood, but it shoul still
// resume it and finish processing the requests, when its output queue will // resume it and finish processing the requests, when its output queue will
// be empty again. // be empty again.
assert.equal(received, COUNT); assert.strictEqual(received, COUNT);
}); });

12
test/parallel/test-http-proxy.js

@ -29,8 +29,8 @@ const proxy = http.createServer(function(req, res) {
console.error('proxy res headers: ' + JSON.stringify(proxy_res.headers)); console.error('proxy res headers: ' + JSON.stringify(proxy_res.headers));
assert.equal('world', proxy_res.headers['hello']); assert.strictEqual('world', proxy_res.headers['hello']);
assert.equal('text/plain', proxy_res.headers['content-type']); assert.strictEqual('text/plain', proxy_res.headers['content-type']);
assert.deepStrictEqual(cookies, proxy_res.headers['set-cookie']); assert.deepStrictEqual(cookies, proxy_res.headers['set-cookie']);
res.writeHead(proxy_res.statusCode, proxy_res.headers); res.writeHead(proxy_res.statusCode, proxy_res.headers);
@ -58,10 +58,10 @@ function startReq() {
path: '/test' path: '/test'
}, function(res) { }, function(res) {
console.error('got res'); console.error('got res');
assert.equal(200, res.statusCode); assert.strictEqual(200, res.statusCode);
assert.equal('world', res.headers['hello']); assert.strictEqual('world', res.headers['hello']);
assert.equal('text/plain', res.headers['content-type']); assert.strictEqual('text/plain', res.headers['content-type']);
assert.deepStrictEqual(cookies, res.headers['set-cookie']); assert.deepStrictEqual(cookies, res.headers['set-cookie']);
res.setEncoding('utf8'); res.setEncoding('utf8');
@ -82,5 +82,5 @@ console.error('listen backend');
backend.listen(0, startReq); backend.listen(0, startReq);
process.on('exit', function() { process.on('exit', function() {
assert.equal(body, 'hello world\n'); assert.strictEqual(body, 'hello world\n');
}); });

4
test/parallel/test-http-remove-header-stays-removed.js

@ -23,13 +23,13 @@ const server = http.createServer(function(request, response) {
let response = ''; let response = '';
process.on('exit', function() { process.on('exit', function() {
assert.equal('beep boop\n', response); assert.strictEqual('beep boop\n', response);
console.log('ok'); console.log('ok');
}); });
server.listen(0, function() { server.listen(0, function() {
http.get({ port: this.address().port }, function(res) { http.get({ port: this.address().port }, function(res) {
assert.equal(200, res.statusCode); assert.strictEqual(200, res.statusCode);
assert.deepStrictEqual(res.headers, { date: 'coffee o clock' }); assert.deepStrictEqual(res.headers, { date: 'coffee o clock' });
res.setEncoding('ascii'); res.setEncoding('ascii');

2
test/parallel/test-http-request-dont-override-options.js

@ -33,7 +33,7 @@ http.createServer(function(req, res) {
}).end(); }).end();
process.on('exit', function() { process.on('exit', function() {
assert.equal(requests, 1); assert.strictEqual(requests, 1);
assert.strictEqual(options.host, undefined); assert.strictEqual(options.host, undefined);
assert.strictEqual(options.hostname, common.localhostIPv4); assert.strictEqual(options.hostname, common.localhostIPv4);

2
test/parallel/test-http-res-write-after-end.js

@ -12,7 +12,7 @@ const server = http.Server(common.mustCall(function(req, res) {
res.end(); res.end();
const r = res.write('This should raise an error.'); const r = res.write('This should raise an error.');
assert.equal(r, true, 'write after end should return true'); assert.strictEqual(r, true, 'write after end should return true');
})); }));
server.listen(0, function() { server.listen(0, function() {

4
test/parallel/test-http-response-multi-content-length.js

@ -39,7 +39,7 @@ server.listen(0, common.mustCall(() => {
} }
).on('error', common.mustCall((err) => { ).on('error', common.mustCall((err) => {
assert(/^Parse Error/.test(err.message)); assert(/^Parse Error/.test(err.message));
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
count++; count++;
if (count === MAX_COUNT) if (count === MAX_COUNT)
server.close(); server.close();
@ -48,5 +48,5 @@ server.listen(0, common.mustCall(() => {
})); }));
process.on('exit', () => { process.on('exit', () => {
assert.equal(count, MAX_COUNT); assert.strictEqual(count, MAX_COUNT);
}); });

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save