mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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>
This commit is contained in:
1 parent
81fef918d5
commit
3d2aef3979
331 files changed
+1704
-1665
No files matched your search
@@ -9,14 +9,14 @@ const path = require('path'),
|
||||
message = 'Large File';
|
||||
|
||||
fs.truncateSync(fd, offset);
|
||||
assert.equal(fs.statSync(filepath).size, offset);
|
||||
assert.strictEqual(fs.statSync(filepath).size, offset);
|
||||
var writeBuf = Buffer.from(message);
|
||||
fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset);
|
||||
var readBuf = Buffer.allocUnsafe(writeBuf.length);
|
||||
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);
|
||||
assert.equal(readBuf[0], 0);
|
||||
assert.strictEqual(readBuf[0], 0);
|
||||
|
||||
var exceptionRaised = false;
|
||||
try {
|
||||
@@ -24,7 +24,7 @@ try {
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
exceptionRaised = true;
|
||||
assert.equal(err.message, 'Not an integer');
|
||||
assert.strictEqual(err.message, 'Not an integer');
|
||||
}
|
||||
assert.ok(exceptionRaised);
|
||||
fs.close(fd);
|
||||
|
||||
@@ -36,6 +36,6 @@ s.listen(common.PORT, function() {
|
||||
|
||||
process.on('exit', function() {
|
||||
assert(aborted);
|
||||
assert.equal(size, maxSize);
|
||||
assert.strictEqual(size, maxSize);
|
||||
console.log('ok');
|
||||
});
|
||||
@@ -49,12 +49,12 @@ var rl = readlineFakeStream();
|
||||
var written_bytes_length, refreshed;
|
||||
|
||||
rl.write('foo');
|
||||
assert.equal(3, rl.cursor);
|
||||
assert.strictEqual(3, rl.cursor);
|
||||
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) {
|
||||
rl.write.apply(rl, key.home);
|
||||
assert.equal(0, rl.cursor);
|
||||
assert.strictEqual(0, rl.cursor);
|
||||
rl.write.apply(rl, key.end);
|
||||
assert.equal(3, rl.cursor);
|
||||
assert.strictEqual(3, rl.cursor);
|
||||
});
|
||||
|
||||
rl = readlineFakeStream();
|
||||
@@ -76,9 +76,9 @@ rl.write.apply(rl, key.xterm.home);
|
||||
].forEach(function(action) {
|
||||
written_bytes_length = rl.written_bytes.length;
|
||||
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;
|
||||
assert.equal(true, refreshed);
|
||||
assert.strictEqual(true, refreshed);
|
||||
});
|
||||
|
||||
rl = readlineFakeStream();
|
||||
@@ -93,7 +93,7 @@ rl.write.apply(rl, key.xterm.home);
|
||||
''
|
||||
].forEach(function(expectedLine) {
|
||||
rl.write.apply(rl, key.xterm.metad);
|
||||
assert.equal(0, rl.cursor);
|
||||
assert.equal(expectedLine, rl.line);
|
||||
assert.strictEqual(0, rl.cursor);
|
||||
assert.strictEqual(expectedLine, rl.line);
|
||||
});
|
||||
rl.close();
|
||||
@@ -63,7 +63,7 @@ var logChild = function(d) {
|
||||
// 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.
|
||||
var pipeFDs = netBinding.pipe();
|
||||
assert.equal(pipeFDs.length, 2);
|
||||
assert.strictEqual(pipeFDs.length, 2);
|
||||
|
||||
var seenOrdinals = [];
|
||||
|
||||
@@ -72,8 +72,8 @@ pipeReadStream.on('data', function(data) {
|
||||
data.toString('utf8').trim().split('\n').forEach(function(d) {
|
||||
var rd = JSON.parse(d);
|
||||
|
||||
assert.equal(rd.pid, cpp);
|
||||
assert.equal(seenOrdinals.indexOf(rd.ord), -1);
|
||||
assert.strictEqual(rd.pid, cpp);
|
||||
assert.strictEqual(seenOrdinals.indexOf(rd.ord), -1);
|
||||
|
||||
seenOrdinals.unshift(rd.ord);
|
||||
});
|
||||
@@ -119,8 +119,8 @@ cp.on('exit', function(code, signal) {
|
||||
srv.close();
|
||||
// fs.unlinkSync(SOCK_PATH);
|
||||
|
||||
assert.equal(code, 0);
|
||||
assert.equal(seenOrdinals.length, 2);
|
||||
assert.strictEqual(code, 0);
|
||||
assert.strictEqual(seenOrdinals.length, 2);
|
||||
});
|
||||
|
||||
// vim:ts=2 sw=2 et
|
||||
@@ -16,7 +16,7 @@ assert.notStrictEqual(newuid, olduid, 'uids expected to be different');
|
||||
try {
|
||||
process.setuid('nobody1234');
|
||||
} catch (e) {
|
||||
assert.equal(e.message,
|
||||
assert.strictEqual(e.message,
|
||||
'failed to resolve group',
|
||||
'unexpected error message'
|
||||
);
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ var options = {
|
||||
};
|
||||
|
||||
var req = https.request(options, function(res) {
|
||||
assert.equal(200, res.statusCode);
|
||||
assert.strictEqual(200, res.statusCode);
|
||||
gotResponse = true;
|
||||
console.error('DONE');
|
||||
res.resume();
|
||||
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@ const assert = require('assert');
|
||||
|
||||
const package = require('./package');
|
||||
|
||||
assert.equal('world', package.hello);
|
||||
assert.strictEqual('world', package.hello);
|
||||
|
||||
console.error('load fixtures/b/c.js');
|
||||
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ console.error(__filename);
|
||||
console.error(module.paths.join('\n') + '\n');
|
||||
// this should work, and get the one that doesn't throw
|
||||
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
|
||||
assert.equal(require('asdf'), require('./node_modules/asdf.js'));
|
||||
assert.strictEqual(require('asdf'), require('./node_modules/asdf.js'));
|
||||
|
||||
module.exports = 'eye catcher';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
console.error(__filename);
|
||||
console.error(module.paths.join('\n') + '\n');
|
||||
const assert = require('assert');
|
||||
assert.equal(require('baz'), require('./baz/index.js'));
|
||||
assert.strictEqual(require('baz'), require('./baz/index.js'));
|
||||
@@ -4,6 +4,6 @@ const assert = require('assert');
|
||||
const dns = require('dns');
|
||||
|
||||
dns.resolveTxt('www.microsoft.com', function(err, records) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(records.length, 0);
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(records.length, 0);
|
||||
});
|
||||
@@ -6,4 +6,4 @@ process.on('exit', function(code) {
|
||||
console.error('Exiting with code=%d', code);
|
||||
});
|
||||
|
||||
assert.equal(1, 2);
|
||||
assert.strictEqual(1, 2);
|
||||
@@ -3,7 +3,7 @@ Exiting with code=1
|
||||
assert.js:*
|
||||
throw new assert.AssertionError({
|
||||
^
|
||||
AssertionError: 1 == 2
|
||||
AssertionError: 1 === 2
|
||||
at Object.<anonymous> (*test*message*error_exit.js:*:*)
|
||||
at Module._compile (module.js:*:*)
|
||||
at Object.Module._extensions..js (module.js:*:*)
|
||||
|
||||
@@ -333,9 +333,9 @@ try {
|
||||
threw = true;
|
||||
assert.ok(e instanceof TypeError, 'type');
|
||||
}
|
||||
assert.equal(true, threw,
|
||||
'a.throws with an explicit error is eating extra errors',
|
||||
a.AssertionError);
|
||||
assert.strictEqual(true, threw,
|
||||
'a.throws with an explicit error is eating extra errors',
|
||||
a.AssertionError);
|
||||
threw = false;
|
||||
|
||||
// doesNotThrow should pass through all errors
|
||||
@@ -345,8 +345,8 @@ try {
|
||||
threw = true;
|
||||
assert.ok(e instanceof TypeError);
|
||||
}
|
||||
assert.equal(true, threw,
|
||||
'a.doesNotThrow with an explicit error is eating extra errors');
|
||||
assert.strictEqual(true, threw, 'a.doesNotThrow with an explicit error is ' +
|
||||
'eating extra errors');
|
||||
|
||||
// key difference is that throwing our correct error makes an assertion error
|
||||
try {
|
||||
@@ -355,8 +355,8 @@ try {
|
||||
threw = true;
|
||||
assert.ok(e instanceof a.AssertionError);
|
||||
}
|
||||
assert.equal(true, threw,
|
||||
'a.doesNotThrow is not catching type matching errors');
|
||||
assert.strictEqual(true, threw,
|
||||
'a.doesNotThrow is not catching type matching errors');
|
||||
|
||||
assert.throws(function() { assert.ifError(new Error('test error')); });
|
||||
assert.doesNotThrow(function() { assert.ifError(null); });
|
||||
@@ -461,10 +461,10 @@ circular.x = circular;
|
||||
|
||||
function testAssertionMessage(actual, expected) {
|
||||
try {
|
||||
assert.equal(actual, '');
|
||||
assert.strictEqual(actual, '');
|
||||
} catch (e) {
|
||||
assert.equal(e.toString(),
|
||||
['AssertionError:', expected, '==', '\'\''].join(' '));
|
||||
assert.strictEqual(e.toString(),
|
||||
['AssertionError:', expected, '===', '\'\''].join(' '));
|
||||
assert.ok(e.generatedMessage, 'Message not marked as generated');
|
||||
}
|
||||
}
|
||||
@@ -499,24 +499,24 @@ try {
|
||||
});
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
assert.equal(e.message, 'Missing expected exception..');
|
||||
assert.strictEqual(e.message, 'Missing expected exception..');
|
||||
}
|
||||
assert.ok(threw);
|
||||
|
||||
// #5292
|
||||
try {
|
||||
assert.equal(1, 2);
|
||||
assert.strictEqual(1, 2);
|
||||
} 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');
|
||||
}
|
||||
|
||||
try {
|
||||
assert.equal(1, 2, 'oh no');
|
||||
assert.strictEqual(1, 2, 'oh no');
|
||||
} catch (e) {
|
||||
assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no');
|
||||
assert.equal(e.generatedMessage, false,
|
||||
'Message incorrectly marked as generated');
|
||||
assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: oh no');
|
||||
assert.strictEqual(e.generatedMessage, false,
|
||||
'Message incorrectly marked as generated');
|
||||
}
|
||||
|
||||
// Verify that throws() and doesNotThrow() throw on non-function block
|
||||
@@ -527,8 +527,8 @@ function testBlockTypeError(method, block) {
|
||||
method(block);
|
||||
threw = false;
|
||||
} catch (e) {
|
||||
assert.equal(e.toString(),
|
||||
'TypeError: "block" argument must be a function');
|
||||
assert.strictEqual(e.toString(),
|
||||
'TypeError: "block" argument must be a function');
|
||||
}
|
||||
|
||||
assert.ok(threw);
|
||||
|
||||
@@ -71,12 +71,12 @@ assert.strictEqual(b.indexOf('f', 5), 5);
|
||||
assert.strictEqual(b.indexOf('f', -1), 5);
|
||||
assert.strictEqual(b.indexOf('f', 6), -1);
|
||||
|
||||
assert.equal(b.indexOf(Buffer.from('d'), 2), 3);
|
||||
assert.equal(b.indexOf(Buffer.from('f'), 5), 5);
|
||||
assert.equal(b.indexOf(Buffer.from('f'), -1), 5);
|
||||
assert.equal(b.indexOf(Buffer.from('f'), 6), -1);
|
||||
assert.strictEqual(b.indexOf(Buffer.from('d'), 2), 3);
|
||||
assert.strictEqual(b.indexOf(Buffer.from('f'), 5), 5);
|
||||
assert.strictEqual(b.indexOf(Buffer.from('f'), -1), 5);
|
||||
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
|
||||
assert.strictEqual(b.indexOf('b', 'utf8'), 1);
|
||||
@@ -176,62 +176,67 @@ assert.strictEqual(
|
||||
|
||||
|
||||
// test optional offset with passed encoding
|
||||
assert.equal(Buffer.from('aaaa0').indexOf('30', 'hex'), 4);
|
||||
assert.equal(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4);
|
||||
assert.strictEqual(Buffer.from('aaaa0').indexOf('30', 'hex'), 4);
|
||||
assert.strictEqual(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4);
|
||||
|
||||
{
|
||||
// test usc2 encoding
|
||||
const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
|
||||
|
||||
assert.equal(8, twoByteString.indexOf('\u0395', 4, 'ucs2'));
|
||||
assert.equal(6, twoByteString.indexOf('\u03a3', -4, 'ucs2'));
|
||||
assert.equal(4, twoByteString.indexOf('\u03a3', -6, 'ucs2'));
|
||||
assert.equal(4, twoByteString.indexOf(
|
||||
assert.strictEqual(8, twoByteString.indexOf('\u0395', 4, 'ucs2'));
|
||||
assert.strictEqual(6, twoByteString.indexOf('\u03a3', -4, 'ucs2'));
|
||||
assert.strictEqual(4, twoByteString.indexOf('\u03a3', -6, 'ucs2'));
|
||||
assert.strictEqual(4, twoByteString.indexOf(
|
||||
Buffer.from('\u03a3', 'ucs2'), -6, 'ucs2'));
|
||||
assert.equal(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2'));
|
||||
assert.strictEqual(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2'));
|
||||
}
|
||||
|
||||
const mixedByteStringUcs2 =
|
||||
Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395', 'ucs2');
|
||||
assert.equal(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2'));
|
||||
assert.equal(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2'));
|
||||
assert.equal(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2'));
|
||||
assert.strictEqual(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2'));
|
||||
assert.strictEqual(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2'));
|
||||
assert.strictEqual(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2'));
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
6, mixedByteStringUcs2.indexOf(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
10, mixedByteStringUcs2.indexOf(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'));
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
-1, mixedByteStringUcs2.indexOf(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'));
|
||||
|
||||
{
|
||||
const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
|
||||
|
||||
// Test single char pattern
|
||||
assert.equal(0, twoByteString.indexOf('\u039a', 0, 'ucs2'));
|
||||
assert.equal(2, twoByteString.indexOf('\u0391', 0, 'ucs2'), 'Alpha');
|
||||
assert.equal(4, twoByteString.indexOf('\u03a3', 0, 'ucs2'), 'First Sigma');
|
||||
assert.equal(6, twoByteString.indexOf('\u03a3', 6, 'ucs2'), 'Second Sigma');
|
||||
assert.equal(8, twoByteString.indexOf('\u0395', 0, 'ucs2'), 'Epsilon');
|
||||
assert.equal(-1, twoByteString.indexOf('\u0392', 0, 'ucs2'), 'Not beta');
|
||||
assert.strictEqual(0, twoByteString.indexOf('\u039a', 0, 'ucs2'));
|
||||
assert.strictEqual(2, twoByteString.indexOf('\u0391', 0, 'ucs2'),
|
||||
'Alpha');
|
||||
assert.strictEqual(4, twoByteString.indexOf('\u03a3', 0, 'ucs2'),
|
||||
'First Sigma');
|
||||
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
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
0, twoByteString.indexOf('\u039a\u0391', 0, 'ucs2'), 'Lambda Alpha');
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
2, twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2'), 'Alpha Sigma');
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
4, twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2'), 'Sigma Sigma');
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
6, twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2'), 'Sigma Epsilon');
|
||||
}
|
||||
|
||||
const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395');
|
||||
assert.equal(5, mixedByteStringUtf8.indexOf('bc'));
|
||||
assert.equal(5, mixedByteStringUtf8.indexOf('bc', 5));
|
||||
assert.equal(5, mixedByteStringUtf8.indexOf('bc', -8));
|
||||
assert.equal(7, mixedByteStringUtf8.indexOf('\u03a3'));
|
||||
assert.equal(-1, mixedByteStringUtf8.indexOf('\u0396'));
|
||||
assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc'));
|
||||
assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc', 5));
|
||||
assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc', -8));
|
||||
assert.strictEqual(7, mixedByteStringUtf8.indexOf('\u03a3'));
|
||||
assert.strictEqual(-1, mixedByteStringUtf8.indexOf('\u0396'));
|
||||
|
||||
|
||||
// Test complex string indexOf algorithms. Only trigger for long strings.
|
||||
@@ -247,23 +252,25 @@ const longBufferString = Buffer.from(longString);
|
||||
let pattern = 'ABACABADABACABA';
|
||||
for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
|
||||
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.equal(
|
||||
assert.strictEqual(510, longBufferString.indexOf('AJABACA'),
|
||||
'Long AJABACA, First J');
|
||||
assert.strictEqual(
|
||||
1534, longBufferString.indexOf('AJABACA', 511), 'Long AJABACA, Second J');
|
||||
|
||||
pattern = 'JABACABADABACABA';
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
511, longBufferString.indexOf(pattern), 'Long JABACABA..., First J');
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
1535, longBufferString.indexOf(pattern, 512), 'Long JABACABA..., Second J');
|
||||
|
||||
// Search for a non-ASCII string in a pure ASCII string.
|
||||
const asciiString = Buffer.from(
|
||||
'arglebargleglopglyfarglebargleglopglyfarglebargleglopglyf');
|
||||
assert.equal(-1, asciiString.indexOf('\x2061'));
|
||||
assert.equal(3, asciiString.indexOf('leb', 0));
|
||||
assert.strictEqual(-1, asciiString.indexOf('\x2061'));
|
||||
assert.strictEqual(3, asciiString.indexOf('leb', 0));
|
||||
|
||||
// Search in string containing many non-ASCII chars.
|
||||
const allCodePoints = [];
|
||||
@@ -274,8 +281,8 @@ const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2');
|
||||
|
||||
// Search for string long enough to trigger complex search with ASCII pattern
|
||||
// and UC16 subject.
|
||||
assert.equal(-1, allCharsBufferUtf8.indexOf('notfound'));
|
||||
assert.equal(-1, allCharsBufferUcs2.indexOf('notfound'));
|
||||
assert.strictEqual(-1, allCharsBufferUtf8.indexOf('notfound'));
|
||||
assert.strictEqual(-1, allCharsBufferUcs2.indexOf('notfound'));
|
||||
|
||||
// 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);
|
||||
@@ -308,10 +315,10 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
|
||||
}
|
||||
|
||||
const patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length);
|
||||
assert.equal(index, allCharsBufferUtf8.indexOf(patternBufferUtf8));
|
||||
assert.strictEqual(index, allCharsBufferUtf8.indexOf(patternBufferUtf8));
|
||||
|
||||
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 =
|
||||
allCharsBufferUcs2.slice(index, index + length);
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
index, allCharsBufferUcs2.indexOf(patternBufferUcs2, 0, 'ucs2'));
|
||||
|
||||
const patternStringUcs2 = patternBufferUcs2.toString('ucs2');
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
index, allCharsBufferUcs2.indexOf(patternStringUcs2, 0, 'ucs2'));
|
||||
}
|
||||
}
|
||||
@@ -352,62 +359,62 @@ assert.throws(function() {
|
||||
|
||||
// Test lastIndexOf basic functionality; Buffer b contains 'abcdef'.
|
||||
// lastIndexOf string:
|
||||
assert.equal(b.lastIndexOf('a'), 0);
|
||||
assert.equal(b.lastIndexOf('a', 1), 0);
|
||||
assert.equal(b.lastIndexOf('b', 1), 1);
|
||||
assert.equal(b.lastIndexOf('c', 1), -1);
|
||||
assert.equal(b.lastIndexOf('a', -1), 0);
|
||||
assert.equal(b.lastIndexOf('a', -4), 0);
|
||||
assert.equal(b.lastIndexOf('a', -b.length), 0);
|
||||
assert.equal(b.lastIndexOf('a', -b.length - 1), -1);
|
||||
assert.equal(b.lastIndexOf('a', NaN), 0);
|
||||
assert.equal(b.lastIndexOf('a', -Infinity), -1);
|
||||
assert.equal(b.lastIndexOf('a', Infinity), 0);
|
||||
assert.strictEqual(b.lastIndexOf('a'), 0);
|
||||
assert.strictEqual(b.lastIndexOf('a', 1), 0);
|
||||
assert.strictEqual(b.lastIndexOf('b', 1), 1);
|
||||
assert.strictEqual(b.lastIndexOf('c', 1), -1);
|
||||
assert.strictEqual(b.lastIndexOf('a', -1), 0);
|
||||
assert.strictEqual(b.lastIndexOf('a', -4), 0);
|
||||
assert.strictEqual(b.lastIndexOf('a', -b.length), 0);
|
||||
assert.strictEqual(b.lastIndexOf('a', -b.length - 1), -1);
|
||||
assert.strictEqual(b.lastIndexOf('a', NaN), 0);
|
||||
assert.strictEqual(b.lastIndexOf('a', -Infinity), -1);
|
||||
assert.strictEqual(b.lastIndexOf('a', Infinity), 0);
|
||||
// lastIndexOf Buffer:
|
||||
assert.equal(b.lastIndexOf(buf_a), 0);
|
||||
assert.equal(b.lastIndexOf(buf_a, 1), 0);
|
||||
assert.equal(b.lastIndexOf(buf_a, -1), 0);
|
||||
assert.equal(b.lastIndexOf(buf_a, -4), 0);
|
||||
assert.equal(b.lastIndexOf(buf_a, -b.length), 0);
|
||||
assert.equal(b.lastIndexOf(buf_a, -b.length - 1), -1);
|
||||
assert.equal(b.lastIndexOf(buf_a, NaN), 0);
|
||||
assert.equal(b.lastIndexOf(buf_a, -Infinity), -1);
|
||||
assert.equal(b.lastIndexOf(buf_a, Infinity), 0);
|
||||
assert.equal(b.lastIndexOf(buf_bc), 1);
|
||||
assert.equal(b.lastIndexOf(buf_bc, 2), 1);
|
||||
assert.equal(b.lastIndexOf(buf_bc, -1), 1);
|
||||
assert.equal(b.lastIndexOf(buf_bc, -3), 1);
|
||||
assert.equal(b.lastIndexOf(buf_bc, -5), 1);
|
||||
assert.equal(b.lastIndexOf(buf_bc, -6), -1);
|
||||
assert.equal(b.lastIndexOf(buf_bc, NaN), 1);
|
||||
assert.equal(b.lastIndexOf(buf_bc, -Infinity), -1);
|
||||
assert.equal(b.lastIndexOf(buf_bc, Infinity), 1);
|
||||
assert.equal(b.lastIndexOf(buf_f), b.length - 1);
|
||||
assert.equal(b.lastIndexOf(buf_z), -1);
|
||||
assert.equal(b.lastIndexOf(buf_empty), -1);
|
||||
assert.equal(b.lastIndexOf(buf_empty, 1), -1);
|
||||
assert.equal(b.lastIndexOf(buf_empty, b.length + 1), -1);
|
||||
assert.equal(b.lastIndexOf(buf_empty, Infinity), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a), 0);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a, 1), 0);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a, -1), 0);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a, -4), 0);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a, -b.length), 0);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a, -b.length - 1), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a, NaN), 0);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a, -Infinity), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_a, Infinity), 0);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc), 1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc, 2), 1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc, -1), 1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc, -3), 1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc, -5), 1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc, -6), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc, NaN), 1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc, -Infinity), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_bc, Infinity), 1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_f), b.length - 1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_z), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_empty), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_empty, 1), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_empty, b.length + 1), -1);
|
||||
assert.strictEqual(b.lastIndexOf(buf_empty, Infinity), -1);
|
||||
// lastIndexOf number:
|
||||
assert.equal(b.lastIndexOf(0x61), 0);
|
||||
assert.equal(b.lastIndexOf(0x61, 1), 0);
|
||||
assert.equal(b.lastIndexOf(0x61, -1), 0);
|
||||
assert.equal(b.lastIndexOf(0x61, -4), 0);
|
||||
assert.equal(b.lastIndexOf(0x61, -b.length), 0);
|
||||
assert.equal(b.lastIndexOf(0x61, -b.length - 1), -1);
|
||||
assert.equal(b.lastIndexOf(0x61, NaN), 0);
|
||||
assert.equal(b.lastIndexOf(0x61, -Infinity), -1);
|
||||
assert.equal(b.lastIndexOf(0x61, Infinity), 0);
|
||||
assert.equal(b.lastIndexOf(0x0), -1);
|
||||
assert.strictEqual(b.lastIndexOf(0x61), 0);
|
||||
assert.strictEqual(b.lastIndexOf(0x61, 1), 0);
|
||||
assert.strictEqual(b.lastIndexOf(0x61, -1), 0);
|
||||
assert.strictEqual(b.lastIndexOf(0x61, -4), 0);
|
||||
assert.strictEqual(b.lastIndexOf(0x61, -b.length), 0);
|
||||
assert.strictEqual(b.lastIndexOf(0x61, -b.length - 1), -1);
|
||||
assert.strictEqual(b.lastIndexOf(0x61, NaN), 0);
|
||||
assert.strictEqual(b.lastIndexOf(0x61, -Infinity), -1);
|
||||
assert.strictEqual(b.lastIndexOf(0x61, Infinity), 0);
|
||||
assert.strictEqual(b.lastIndexOf(0x0), -1);
|
||||
|
||||
// Test weird offset arguments.
|
||||
// Behaviour should match String.lastIndexOf:
|
||||
assert.equal(b.lastIndexOf('b', 0), -1);
|
||||
assert.equal(b.lastIndexOf('b', undefined), 1);
|
||||
assert.equal(b.lastIndexOf('b', null), -1);
|
||||
assert.equal(b.lastIndexOf('b', {}), 1);
|
||||
assert.equal(b.lastIndexOf('b', []), -1);
|
||||
assert.equal(b.lastIndexOf('b', [2]), 1);
|
||||
assert.strictEqual(b.lastIndexOf('b', 0), -1);
|
||||
assert.strictEqual(b.lastIndexOf('b', undefined), 1);
|
||||
assert.strictEqual(b.lastIndexOf('b', null), -1);
|
||||
assert.strictEqual(b.lastIndexOf('b', {}), 1);
|
||||
assert.strictEqual(b.lastIndexOf('b', []), -1);
|
||||
assert.strictEqual(b.lastIndexOf('b', [2]), 1);
|
||||
|
||||
// Test needles longer than the haystack.
|
||||
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:
|
||||
const bufferString = new Buffer('a man a plan a canal panama');
|
||||
assert.equal(15, bufferString.lastIndexOf('canal'));
|
||||
assert.equal(21, bufferString.lastIndexOf('panama'));
|
||||
assert.equal(0, bufferString.lastIndexOf('a man a plan a canal panama'));
|
||||
assert.equal(-1, bufferString.lastIndexOf('a man a plan a canal mexico'));
|
||||
assert.equal(-1, bufferString.lastIndexOf('a man a plan a canal mexico city'));
|
||||
assert.equal(-1, bufferString.lastIndexOf(Buffer.from('a'.repeat(1000))));
|
||||
assert.equal(0, bufferString.lastIndexOf('a man a plan', 4));
|
||||
assert.equal(13, bufferString.lastIndexOf('a '));
|
||||
assert.equal(13, bufferString.lastIndexOf('a ', 13));
|
||||
assert.equal(6, bufferString.lastIndexOf('a ', 12));
|
||||
assert.equal(0, bufferString.lastIndexOf('a ', 5));
|
||||
assert.equal(13, bufferString.lastIndexOf('a ', -1));
|
||||
assert.equal(0, bufferString.lastIndexOf('a ', -27));
|
||||
assert.equal(-1, bufferString.lastIndexOf('a ', -28));
|
||||
assert.strictEqual(15, bufferString.lastIndexOf('canal'));
|
||||
assert.strictEqual(21, bufferString.lastIndexOf('panama'));
|
||||
assert.strictEqual(0, bufferString.lastIndexOf('a man a plan a canal panama'));
|
||||
assert.strictEqual(-1, bufferString.lastIndexOf('a man a plan a canal mexico'));
|
||||
assert.strictEqual(-1, bufferString
|
||||
.lastIndexOf('a man a plan a canal mexico city'));
|
||||
assert.strictEqual(-1, bufferString.lastIndexOf(Buffer.from('a'.repeat(1000))));
|
||||
assert.strictEqual(0, bufferString.lastIndexOf('a man a plan', 4));
|
||||
assert.strictEqual(13, bufferString.lastIndexOf('a '));
|
||||
assert.strictEqual(13, bufferString.lastIndexOf('a ', 13));
|
||||
assert.strictEqual(6, bufferString.lastIndexOf('a ', 12));
|
||||
assert.strictEqual(0, bufferString.lastIndexOf('a ', 5));
|
||||
assert.strictEqual(13, bufferString.lastIndexOf('a ', -1));
|
||||
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,
|
||||
// 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.
|
||||
// Test lastIndexOf on a long buffer w multiple matches:
|
||||
pattern = 'JABACABADABACABA';
|
||||
assert.equal(1535, longBufferString.lastIndexOf(pattern));
|
||||
assert.equal(1535, longBufferString.lastIndexOf(pattern, 1535));
|
||||
assert.equal(511, longBufferString.lastIndexOf(pattern, 1534));
|
||||
assert.strictEqual(1535, longBufferString.lastIndexOf(pattern));
|
||||
assert.strictEqual(1535, longBufferString.lastIndexOf(pattern, 1535));
|
||||
assert.strictEqual(511, longBufferString.lastIndexOf(pattern, 1534));
|
||||
|
||||
// Finally, give it a really long input to trigger fallback from BMH to
|
||||
// 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');
|
||||
}
|
||||
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:
|
||||
pattern = reallyLong.slice(0, 100000); // First 1/50th of the pattern.
|
||||
assert.equal(4751360, reallyLong.lastIndexOf(pattern));
|
||||
assert.equal(3932160, reallyLong.lastIndexOf(pattern, 4000000));
|
||||
assert.equal(2949120, reallyLong.lastIndexOf(pattern, 3000000));
|
||||
assert.strictEqual(4751360, reallyLong.lastIndexOf(pattern));
|
||||
assert.strictEqual(3932160, reallyLong.lastIndexOf(pattern, 4000000));
|
||||
assert.strictEqual(2949120, reallyLong.lastIndexOf(pattern, 3000000));
|
||||
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.
|
||||
assert.equal(3932160, reallyLong.lastIndexOf(pattern));
|
||||
assert.strictEqual(3932160, reallyLong.lastIndexOf(pattern));
|
||||
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
|
||||
{
|
||||
|
||||
@@ -153,7 +153,7 @@ if (process.argv[2] === 'child') {
|
||||
});
|
||||
connect.on('close', function() {
|
||||
console.log('CLIENT: closed');
|
||||
assert.equal(store, 'echo');
|
||||
assert.strictEqual(store, 'echo');
|
||||
server.close();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -135,7 +135,7 @@ if (process.argv[2] === 'child') {
|
||||
};
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(disconnected, count);
|
||||
assert.equal(connected, count);
|
||||
assert.strictEqual(disconnected, count);
|
||||
assert.strictEqual(connected, count);
|
||||
});
|
||||
}
|
||||
@@ -33,6 +33,6 @@ if (process.argv[2] === 'child') {
|
||||
|
||||
child.once('exit', function() {
|
||||
assert.deepStrictEqual(ipc, ['1', '2']);
|
||||
assert.equal(stdout, '3');
|
||||
assert.strictEqual(stdout, '3');
|
||||
});
|
||||
}
|
||||
@@ -30,7 +30,7 @@ child.stdout.on('data', function(data) {
|
||||
child.stdin.write('echo me\r\n');
|
||||
} else {
|
||||
console.error('testing for echo me');
|
||||
assert.equal('echo me\r\n', data);
|
||||
assert.strictEqual('echo me\r\n', data);
|
||||
gotEcho = true;
|
||||
child.stdin.end();
|
||||
}
|
||||
|
||||
@@ -10,5 +10,5 @@ const cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], {
|
||||
});
|
||||
|
||||
cp.on('exit', common.mustCall(function(code) {
|
||||
assert.equal(0, code);
|
||||
assert.strictEqual(0, code);
|
||||
}));
|
||||
@@ -11,5 +11,5 @@ if (process.argv[2] === 'child') {
|
||||
env: Object.assign(process.env, { foo: expected })
|
||||
});
|
||||
|
||||
assert.equal(child.stdout.toString().trim(), expected);
|
||||
assert.strictEqual(child.stdout.toString().trim(), expected);
|
||||
}
|
||||
@@ -19,9 +19,9 @@ let key2 = dh2.generateKeys('hex');
|
||||
let secret1 = dh1.computeSecret(key2, 'hex', 'base64');
|
||||
let secret2 = dh2.computeSecret(key1, 'latin1', 'buffer');
|
||||
|
||||
assert.equal(secret1, secret2.toString('base64'));
|
||||
assert.equal(dh1.verifyError, 0);
|
||||
assert.equal(dh2.verifyError, 0);
|
||||
assert.strictEqual(secret1, secret2.toString('base64'));
|
||||
assert.strictEqual(dh1.verifyError, 0);
|
||||
assert.strictEqual(dh2.verifyError, 0);
|
||||
|
||||
assert.throws(function() {
|
||||
crypto.createDiffieHellman([0x1, 0x2]);
|
||||
@@ -50,11 +50,11 @@ assert.deepStrictEqual(dh1.getPrime(), dh3.getPrime());
|
||||
assert.deepStrictEqual(dh1.getGenerator(), dh3.getGenerator());
|
||||
assert.deepStrictEqual(dh1.getPublicKey(), dh3.getPublicKey());
|
||||
assert.deepStrictEqual(dh1.getPrivateKey(), dh3.getPrivateKey());
|
||||
assert.equal(dh3.verifyError, 0);
|
||||
assert.strictEqual(dh3.verifyError, 0);
|
||||
|
||||
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
|
||||
{
|
||||
@@ -78,9 +78,9 @@ alice.generateKeys();
|
||||
bob.generateKeys();
|
||||
const aSecret = alice.computeSecret(bob.getPublicKey()).toString('hex');
|
||||
const bSecret = bob.computeSecret(alice.getPublicKey()).toString('hex');
|
||||
assert.equal(aSecret, bSecret);
|
||||
assert.equal(alice.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.equal(bob.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.strictEqual(aSecret, bSecret);
|
||||
assert.strictEqual(alice.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.strictEqual(bob.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
|
||||
/* Ensure specific generator (buffer) works as expected.
|
||||
* 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');
|
||||
const exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey())
|
||||
.toString('hex');
|
||||
assert.equal(modp2Secret, exmodp2Secret);
|
||||
assert.equal(modp2.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.equal(exmodp2.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.strictEqual(modp2Secret, exmodp2Secret);
|
||||
assert.strictEqual(modp2.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.strictEqual(exmodp2.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
|
||||
|
||||
// Ensure specific generator (string with encoding) works as expected.
|
||||
@@ -118,8 +118,8 @@ exmodp2_2.generateKeys();
|
||||
modp2Secret = modp2.computeSecret(exmodp2_2.getPublicKey()).toString('hex');
|
||||
const exmodp2_2Secret = exmodp2_2.computeSecret(modp2.getPublicKey())
|
||||
.toString('hex');
|
||||
assert.equal(modp2Secret, exmodp2_2Secret);
|
||||
assert.equal(exmodp2_2.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.strictEqual(modp2Secret, exmodp2_2Secret);
|
||||
assert.strictEqual(exmodp2_2.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
|
||||
|
||||
// Ensure specific generator (string without encoding) works as expected.
|
||||
@@ -128,8 +128,8 @@ exmodp2_3.generateKeys();
|
||||
modp2Secret = modp2.computeSecret(exmodp2_3.getPublicKey()).toString('hex');
|
||||
const exmodp2_3Secret = exmodp2_3.computeSecret(modp2.getPublicKey())
|
||||
.toString('hex');
|
||||
assert.equal(modp2Secret, exmodp2_3Secret);
|
||||
assert.equal(exmodp2_3.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.strictEqual(modp2Secret, exmodp2_3Secret);
|
||||
assert.strictEqual(exmodp2_3.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
|
||||
|
||||
// Ensure specific generator (numeric) works as expected.
|
||||
@@ -138,8 +138,8 @@ exmodp2_4.generateKeys();
|
||||
modp2Secret = modp2.computeSecret(exmodp2_4.getPublicKey()).toString('hex');
|
||||
const exmodp2_4Secret = exmodp2_4.computeSecret(modp2.getPublicKey())
|
||||
.toString('hex');
|
||||
assert.equal(modp2Secret, exmodp2_4Secret);
|
||||
assert.equal(exmodp2_4.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
assert.strictEqual(modp2Secret, exmodp2_4Secret);
|
||||
assert.strictEqual(exmodp2_4.verifyError, DH_NOT_SUITABLE_GENERATOR);
|
||||
|
||||
|
||||
const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
|
||||
@@ -147,7 +147,7 @@ const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
|
||||
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
|
||||
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF';
|
||||
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
|
||||
@@ -158,7 +158,7 @@ key2 = ecdh2.generateKeys('hex');
|
||||
secret1 = ecdh1.computeSecret(key2, 'hex', 'base64');
|
||||
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
|
||||
// when accessing other OpenSSL APIs afterwards.
|
||||
@@ -166,7 +166,7 @@ crypto.createECDH('Oakley-EC2N-3');
|
||||
crypto.createHash('sha256');
|
||||
|
||||
// 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];
|
||||
assert(firstByte === 2 || firstByte === 3);
|
||||
firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0];
|
||||
@@ -210,9 +210,9 @@ const cafebabePubPtUnComp =
|
||||
'04672a31bfc59d3f04548ec9b7daeeba2f61814e8ccc40448045007f5479f693a3' +
|
||||
'2e02c7f93d13dc2732b760ca377a5897b9dd41a1c1b29dc0442fdce6d0a04d1d';
|
||||
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.
|
||||
assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
|
||||
assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
|
||||
|
||||
// Compressed and uncompressed public points/keys for other party's private key
|
||||
// 0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF
|
||||
@@ -225,24 +225,26 @@ const peerPubPtUnComp =
|
||||
const sharedSecret =
|
||||
'1da220b5329bbe8bfd19ceef5a5898593f411a6f12ea40f2a8eead9a5cf59970';
|
||||
|
||||
assert.equal(ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'), sharedSecret);
|
||||
assert.equal(ecdh5.computeSecret(peerPubPtUnComp, 'hex', 'hex'), sharedSecret);
|
||||
assert.strictEqual(ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'),
|
||||
sharedSecret);
|
||||
assert.strictEqual(ecdh5.computeSecret(peerPubPtUnComp, 'hex', 'hex'),
|
||||
sharedSecret);
|
||||
|
||||
// Verify that we still have the same key pair as before the computation.
|
||||
assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey);
|
||||
assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
|
||||
assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey);
|
||||
assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
|
||||
|
||||
// Verify setting and getting compressed and non-compressed serializations.
|
||||
ecdh5.setPublicKey(cafebabePubPtComp, 'hex');
|
||||
assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
|
||||
assert.equal(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp);
|
||||
assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
|
||||
assert.strictEqual(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp);
|
||||
ecdh5.setPublicKey(cafebabePubPtUnComp, 'hex');
|
||||
assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
|
||||
assert.equal(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp);
|
||||
assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp);
|
||||
assert.strictEqual(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp);
|
||||
|
||||
// Show why allowing the public key to be set on this type does not make sense.
|
||||
ecdh5.setPublicKey(peerPubPtComp, 'hex');
|
||||
assert.equal(ecdh5.getPublicKey('hex'), peerPubPtUnComp);
|
||||
assert.strictEqual(ecdh5.getPublicKey('hex'), peerPubPtUnComp);
|
||||
assert.throws(function() {
|
||||
// Error because the public key does not match the private key anymore.
|
||||
ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex');
|
||||
@@ -261,5 +263,5 @@ ecdh5.setPrivateKey(cafebabeKey, 'hex');
|
||||
ecdh5.setPrivateKey(element, 'hex');
|
||||
}, /Private key is not valid for specified curve/);
|
||||
// Verify object state did not change.
|
||||
assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey);
|
||||
assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey);
|
||||
});
|
||||
@@ -12,7 +12,7 @@ if (!common.hasCrypto) {
|
||||
const crypto = require('crypto');
|
||||
|
||||
d.on('error', common.mustCall(function(e) {
|
||||
assert.equal(e.message, expect.shift());
|
||||
assert.strictEqual(e.message, expect.shift());
|
||||
}, 3));
|
||||
|
||||
d.run(function() {
|
||||
|
||||
@@ -85,7 +85,7 @@ const p = crypto.createDiffieHellman(
|
||||
p.setPublicKey(apub, 'hex');
|
||||
p.setPrivateKey(apriv, 'hex');
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
p.computeSecret(bpub, 'hex', 'hex').toString('hex'),
|
||||
secret
|
||||
);
|
||||
@@ -6,7 +6,7 @@ const assert = require('assert');
|
||||
const domain = require('domain');
|
||||
|
||||
process.on('exit', function(c) {
|
||||
assert.equal(domain._stack.length, 0);
|
||||
assert.strictEqual(domain._stack.length, 0);
|
||||
});
|
||||
|
||||
domain.create().run(function() {
|
||||
|
||||
@@ -7,13 +7,14 @@ const assert = require('assert');
|
||||
const myEE = new EventEmitter();
|
||||
let m = 0;
|
||||
// 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.
|
||||
myEE.prependListener('foo', common.mustCall(() => assert.equal(m++, 1)));
|
||||
myEE.prependListener('foo', common.mustCall(() => assert.strictEqual(m++, 1)));
|
||||
|
||||
// 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');
|
||||
|
||||
|
||||
@@ -43,4 +43,4 @@ const ee2 = new MyEE2();
|
||||
|
||||
ee1.on('x', function() {});
|
||||
|
||||
assert.equal(ee2.listenerCount('x'), 0);
|
||||
assert.strictEqual(ee2.listenerCount('x'), 0);
|
||||
@@ -12,7 +12,7 @@ const existingDir2 = path.join(common.fixturesDir, 'keys');
|
||||
// ASYNC_CALL
|
||||
|
||||
fs.stat(fn, function(err) {
|
||||
assert.equal(fn, err.path);
|
||||
assert.strictEqual(fn, err.path);
|
||||
assert.ok(0 <= err.message.indexOf(fn));
|
||||
});
|
||||
|
||||
@@ -204,7 +204,7 @@ try {
|
||||
}
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(expected, errors.length,
|
||||
'Test fs sync exceptions raised, got ' + errors.length +
|
||||
assert.strictEqual(expected, errors.length,
|
||||
'Test fs sync exceptions raised, got ' + errors.length +
|
||||
' expected ' + expected);
|
||||
});
|
||||
@@ -29,8 +29,8 @@ fs.mkdir(d, 0o666, function(err) {
|
||||
|
||||
fs.mkdir(d, 0o666, function(err) {
|
||||
assert.ok(err.message.match(/^EEXIST/), 'got EEXIST message');
|
||||
assert.equal(err.code, 'EEXIST', 'got EEXIST code');
|
||||
assert.equal(err.path, d, 'got proper path for EEXIST');
|
||||
assert.strictEqual(err.code, 'EEXIST', 'got EEXIST code');
|
||||
assert.strictEqual(err.path, d, 'got proper path for EEXIST');
|
||||
|
||||
fs.rmdir(d, assert.ifError);
|
||||
});
|
||||
|
||||
@@ -33,8 +33,8 @@ common.refreshTmpDir();
|
||||
unlink(pathname);
|
||||
|
||||
fs.mkdir(pathname, 0o777, common.mustCall(function(err) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(common.fileExists(pathname), true);
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(common.fileExists(pathname), true);
|
||||
}));
|
||||
|
||||
process.on('exit', function() {
|
||||
|
||||
@@ -14,8 +14,8 @@ assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length);
|
||||
assert(common.fileExists(tmpFolder));
|
||||
|
||||
const utf8 = fs.mkdtempSync(path.join(common.tmpDir, '\u0222abc.'));
|
||||
assert.equal(Buffer.byteLength(path.basename(utf8)),
|
||||
Buffer.byteLength('\u0222abc.XXXXXX'));
|
||||
assert.strictEqual(Buffer.byteLength(path.basename(utf8)),
|
||||
Buffer.byteLength('\u0222abc.XXXXXX'));
|
||||
assert(common.fileExists(utf8));
|
||||
|
||||
function handler(err, folder) {
|
||||
|
||||
@@ -15,21 +15,21 @@ const O_WRONLY = fs.constants.O_WRONLY || 0;
|
||||
|
||||
const { stringToFlags } = require('internal/fs');
|
||||
|
||||
assert.equal(stringToFlags('r'), O_RDONLY);
|
||||
assert.equal(stringToFlags('r+'), O_RDWR);
|
||||
assert.equal(stringToFlags('w'), O_TRUNC | O_CREAT | O_WRONLY);
|
||||
assert.equal(stringToFlags('w+'), O_TRUNC | O_CREAT | O_RDWR);
|
||||
assert.equal(stringToFlags('a'), O_APPEND | O_CREAT | O_WRONLY);
|
||||
assert.equal(stringToFlags('a+'), O_APPEND | O_CREAT | O_RDWR);
|
||||
assert.strictEqual(stringToFlags('r'), O_RDONLY);
|
||||
assert.strictEqual(stringToFlags('r+'), O_RDWR);
|
||||
assert.strictEqual(stringToFlags('w'), O_TRUNC | O_CREAT | O_WRONLY);
|
||||
assert.strictEqual(stringToFlags('w+'), O_TRUNC | O_CREAT | O_RDWR);
|
||||
assert.strictEqual(stringToFlags('a'), O_APPEND | O_CREAT | O_WRONLY);
|
||||
assert.strictEqual(stringToFlags('a+'), O_APPEND | O_CREAT | O_RDWR);
|
||||
|
||||
assert.equal(stringToFlags('wx'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL);
|
||||
assert.equal(stringToFlags('xw'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL);
|
||||
assert.equal(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
|
||||
assert.equal(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
|
||||
assert.equal(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
|
||||
assert.equal(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
|
||||
assert.equal(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('wx'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL);
|
||||
assert.strictEqual(stringToFlags('xw'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL);
|
||||
assert.strictEqual(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
|
||||
assert.strictEqual(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
|
||||
assert.strictEqual(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
|
||||
assert.strictEqual(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
|
||||
assert.strictEqual(stringToFlags('ax+'), 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')
|
||||
.split(' ')
|
||||
|
||||
@@ -61,7 +61,7 @@ file.on('close', function() {
|
||||
assert.strictEqual(file.bytesRead, fileSize);
|
||||
callbacks.close++;
|
||||
|
||||
//assert.equal(fs.readFileSync(fn), fileContent);
|
||||
//assert.strictEqual(fs.readFileSync(fn), fileContent);
|
||||
});
|
||||
|
||||
const file3 = fs.createReadStream(fn, {encoding: 'utf8'});
|
||||
|
||||
@@ -10,10 +10,10 @@ const bufferAsync = Buffer.alloc(0);
|
||||
const bufferSync = Buffer.alloc(0);
|
||||
|
||||
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));
|
||||
}));
|
||||
|
||||
const r = fs.readSync(fd, bufferSync, 0, 0, 0);
|
||||
assert.deepStrictEqual(bufferSync, Buffer.alloc(0));
|
||||
assert.equal(r, 0);
|
||||
assert.strictEqual(r, 0);
|
||||
@@ -20,7 +20,7 @@ fs.closeSync(fs.openSync(fullpath, 'w+'));
|
||||
|
||||
fs.readdir(common.tmpDir, 'ucs2', (err, list) => {
|
||||
assert.ifError(err);
|
||||
assert.equal(1, list.length);
|
||||
assert.strictEqual(1, list.length);
|
||||
const fn = list[0];
|
||||
assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2'));
|
||||
assert.strictEqual(fn, filename);
|
||||
|
||||
@@ -31,5 +31,5 @@ assert.throws(function() {
|
||||
}, /Error: ENOTDIR: not a directory/);
|
||||
|
||||
fs.readdir(__filename, common.mustCall(function(e) {
|
||||
assert.equal(e.code, 'ENOTDIR');
|
||||
assert.strictEqual(e.code, 'ENOTDIR');
|
||||
}));
|
||||
@@ -508,6 +508,6 @@ function runTest() {
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(numtests, testsRun);
|
||||
assert.equal(async_completed, async_expected);
|
||||
assert.strictEqual(numtests, testsRun);
|
||||
assert.strictEqual(async_completed, async_expected);
|
||||
});
|
||||
@@ -57,25 +57,25 @@ fs.stat(__filename, common.mustCall(function(err, s) {
|
||||
console.dir(s);
|
||||
|
||||
console.log('isDirectory: ' + JSON.stringify(s.isDirectory()));
|
||||
assert.equal(false, s.isDirectory());
|
||||
assert.strictEqual(false, s.isDirectory());
|
||||
|
||||
console.log('isFile: ' + JSON.stringify(s.isFile()));
|
||||
assert.equal(true, s.isFile());
|
||||
assert.strictEqual(true, s.isFile());
|
||||
|
||||
console.log('isSocket: ' + JSON.stringify(s.isSocket()));
|
||||
assert.equal(false, s.isSocket());
|
||||
assert.strictEqual(false, s.isSocket());
|
||||
|
||||
console.log('isBlockDevice: ' + JSON.stringify(s.isBlockDevice()));
|
||||
assert.equal(false, s.isBlockDevice());
|
||||
assert.strictEqual(false, s.isBlockDevice());
|
||||
|
||||
console.log('isCharacterDevice: ' + JSON.stringify(s.isCharacterDevice()));
|
||||
assert.equal(false, s.isCharacterDevice());
|
||||
assert.strictEqual(false, s.isCharacterDevice());
|
||||
|
||||
console.log('isFIFO: ' + JSON.stringify(s.isFIFO()));
|
||||
assert.equal(false, s.isFIFO());
|
||||
assert.strictEqual(false, s.isFIFO());
|
||||
|
||||
console.log('isSymbolicLink: ' + JSON.stringify(s.isSymbolicLink()));
|
||||
assert.equal(false, s.isSymbolicLink());
|
||||
assert.strictEqual(false, s.isSymbolicLink());
|
||||
|
||||
assert.ok(s.mtime instanceof Date);
|
||||
}));
|
||||
@@ -8,7 +8,7 @@ fs.openSync = function() {
|
||||
return 42;
|
||||
};
|
||||
fs.closeSync = function(fd) {
|
||||
assert.equal(fd, 42);
|
||||
assert.strictEqual(fd, 42);
|
||||
close_called++;
|
||||
};
|
||||
fs.readSync = function() {
|
||||
@@ -40,10 +40,10 @@ function ensureThrows(cb) {
|
||||
try {
|
||||
cb();
|
||||
} catch (e) {
|
||||
assert.equal(e.message, 'BAM');
|
||||
assert.strictEqual(e.message, 'BAM');
|
||||
got_exception = true;
|
||||
}
|
||||
|
||||
assert.equal(close_called, 1);
|
||||
assert.equal(got_exception, true);
|
||||
assert.strictEqual(close_called, 1);
|
||||
assert.strictEqual(got_exception, true);
|
||||
}
|
||||
@@ -8,7 +8,7 @@ assert.throws(function() {
|
||||
}, function(err) {
|
||||
assert(err);
|
||||
assert(/non-existent-file/.test(err));
|
||||
assert.equal(err.filename, 'non-existent-file');
|
||||
assert.strictEqual(err.filename, 'non-existent-file');
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -16,6 +16,6 @@ const watcher = fs.watch(__filename);
|
||||
watcher.on('error', common.mustCall(function(err) {
|
||||
assert(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');
|
||||
@@ -12,8 +12,8 @@ const listener = common.mustCall(() => {
|
||||
triggered = false;
|
||||
watch.once('stop', listener); // Should trigger.
|
||||
watch.stop();
|
||||
assert.equal(triggered, false);
|
||||
assert.strictEqual(triggered, false);
|
||||
setImmediate(() => {
|
||||
assert.equal(triggered, true);
|
||||
assert.strictEqual(triggered, true);
|
||||
watch.removeListener('stop', listener);
|
||||
});
|
||||
@@ -29,5 +29,5 @@ stream.write('foo');
|
||||
stream.end();
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(fs.open, _fs_open);
|
||||
assert.strictEqual(fs.open, _fs_open);
|
||||
});
|
||||
@@ -33,14 +33,14 @@ fs.write = function() {
|
||||
|
||||
fs.close = common.mustCall(function(fd_, cb) {
|
||||
console.error('fs.close', fd_, stream.fd);
|
||||
assert.equal(fd_, stream.fd);
|
||||
assert.strictEqual(fd_, stream.fd);
|
||||
process.nextTick(cb);
|
||||
});
|
||||
|
||||
stream.on('error', common.mustCall(function(err_) {
|
||||
console.error('error handler');
|
||||
assert.equal(stream.fd, null);
|
||||
assert.equal(err_, err);
|
||||
assert.strictEqual(stream.fd, null);
|
||||
assert.strictEqual(err_, err);
|
||||
}));
|
||||
|
||||
|
||||
@@ -48,6 +48,6 @@ stream.write(Buffer.allocUnsafe(256), function() {
|
||||
console.error('first cb');
|
||||
stream.write(Buffer.allocUnsafe(256), common.mustCall(function(err_) {
|
||||
console.error('second cb');
|
||||
assert.equal(err_, err);
|
||||
assert.strictEqual(err_, err);
|
||||
}));
|
||||
});
|
||||
@@ -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) {
|
||||
console.log('write done');
|
||||
assert.ifError(err);
|
||||
assert.equal(Buffer.byteLength(expected), written);
|
||||
assert.strictEqual(Buffer.byteLength(expected), written);
|
||||
fs.closeSync(fd);
|
||||
const found = fs.readFileSync(fn, 'utf8');
|
||||
console.log('expected: "%s"', expected);
|
||||
|
||||
@@ -8,7 +8,7 @@ let complete;
|
||||
const server = http.createServer(function(req, res) {
|
||||
// We should not see the queued /thatotherone request within the server
|
||||
// as it should be aborted before it is sent.
|
||||
assert.equal(req.url, '/');
|
||||
assert.strictEqual(req.url, '/');
|
||||
|
||||
res.writeHead(200);
|
||||
res.write('foo');
|
||||
@@ -23,7 +23,7 @@ server.listen(0, function() {
|
||||
console.log('listen', server.address().port);
|
||||
|
||||
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 = {
|
||||
hostname: 'localhost',
|
||||
@@ -35,8 +35,8 @@ server.listen(0, function() {
|
||||
|
||||
const req1 = http.request(options);
|
||||
req1.on('response', function(res1) {
|
||||
assert.equal(Object.keys(agent.sockets).length, 1);
|
||||
assert.equal(Object.keys(agent.requests).length, 0);
|
||||
assert.strictEqual(Object.keys(agent.sockets).length, 1);
|
||||
assert.strictEqual(Object.keys(agent.requests).length, 0);
|
||||
|
||||
const req2 = http.request({
|
||||
method: 'GET',
|
||||
@@ -45,19 +45,19 @@ server.listen(0, function() {
|
||||
path: '/thatotherone',
|
||||
agent: agent
|
||||
});
|
||||
assert.equal(Object.keys(agent.sockets).length, 1);
|
||||
assert.equal(Object.keys(agent.requests).length, 1);
|
||||
assert.strictEqual(Object.keys(agent.sockets).length, 1);
|
||||
assert.strictEqual(Object.keys(agent.requests).length, 1);
|
||||
|
||||
req2.on('error', function(err) {
|
||||
// This is expected in response to our explicit abort call
|
||||
assert.equal(err.code, 'ECONNRESET');
|
||||
assert.strictEqual(err.code, 'ECONNRESET');
|
||||
});
|
||||
|
||||
req2.end();
|
||||
req2.abort();
|
||||
|
||||
assert.equal(Object.keys(agent.sockets).length, 1);
|
||||
assert.equal(Object.keys(agent.requests).length, 1);
|
||||
assert.strictEqual(Object.keys(agent.sockets).length, 1);
|
||||
assert.strictEqual(Object.keys(agent.requests).length, 1);
|
||||
|
||||
console.log('Got res: ' + res1.statusCode);
|
||||
console.dir(res1.headers);
|
||||
@@ -72,8 +72,8 @@ server.listen(0, function() {
|
||||
console.log('Response ended.');
|
||||
|
||||
setTimeout(function() {
|
||||
assert.equal(Object.keys(agent.sockets).length, 0);
|
||||
assert.equal(Object.keys(agent.requests).length, 0);
|
||||
assert.strictEqual(Object.keys(agent.sockets).length, 0);
|
||||
assert.strictEqual(Object.keys(agent.requests).length, 0);
|
||||
|
||||
server.close();
|
||||
}, 100);
|
||||
|
||||
@@ -23,13 +23,13 @@ server.listen(0, function() {
|
||||
const socketKey = agent.getName(requestParams);
|
||||
|
||||
get(function(res) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
res.resume();
|
||||
res.on('end', function() {
|
||||
process.nextTick(function() {
|
||||
const freeSockets = agent.freeSockets[socketKey];
|
||||
assert.equal(freeSockets.length, 1,
|
||||
'expect a free socket on ' + socketKey);
|
||||
assert.strictEqual(freeSockets.length, 1,
|
||||
'expect a free socket on ' + socketKey);
|
||||
|
||||
//generate a random error on the free socket
|
||||
const freeSocket = freeSockets[0];
|
||||
@@ -45,8 +45,8 @@ server.listen(0, function() {
|
||||
}
|
||||
|
||||
function done() {
|
||||
assert.equal(Object.keys(agent.freeSockets).length, 0,
|
||||
'expect the freeSockets pool to be empty');
|
||||
assert.strictEqual(Object.keys(agent.freeSockets).length, 0,
|
||||
'expect the freeSockets pool to be empty');
|
||||
|
||||
agent.destroy();
|
||||
server.close();
|
||||
|
||||
@@ -37,22 +37,22 @@ function get(path, callback) {
|
||||
}
|
||||
|
||||
function checkDataAndSockets(body) {
|
||||
assert.equal(body.toString(), 'hello world');
|
||||
assert.equal(agent.sockets[name].length, 1);
|
||||
assert.equal(agent.freeSockets[name], undefined);
|
||||
assert.strictEqual(body.toString(), 'hello world');
|
||||
assert.strictEqual(agent.sockets[name].length, 1);
|
||||
assert.strictEqual(agent.freeSockets[name], undefined);
|
||||
}
|
||||
|
||||
function second() {
|
||||
// request second, use the same socket
|
||||
get('/second', function(res) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
res.on('data', checkDataAndSockets);
|
||||
res.on('end', function() {
|
||||
assert.equal(agent.sockets[name].length, 1);
|
||||
assert.equal(agent.freeSockets[name], undefined);
|
||||
assert.strictEqual(agent.sockets[name].length, 1);
|
||||
assert.strictEqual(agent.freeSockets[name], undefined);
|
||||
process.nextTick(function() {
|
||||
assert.equal(agent.sockets[name], undefined);
|
||||
assert.equal(agent.freeSockets[name].length, 1);
|
||||
assert.strictEqual(agent.sockets[name], undefined);
|
||||
assert.strictEqual(agent.freeSockets[name].length, 1);
|
||||
remoteClose();
|
||||
});
|
||||
});
|
||||
@@ -65,16 +65,16 @@ function remoteClose() {
|
||||
assert.deepStrictEqual(res.statusCode, 200);
|
||||
res.on('data', checkDataAndSockets);
|
||||
res.on('end', function() {
|
||||
assert.equal(agent.sockets[name].length, 1);
|
||||
assert.equal(agent.freeSockets[name], undefined);
|
||||
assert.strictEqual(agent.sockets[name].length, 1);
|
||||
assert.strictEqual(agent.freeSockets[name], undefined);
|
||||
process.nextTick(function() {
|
||||
assert.equal(agent.sockets[name], undefined);
|
||||
assert.equal(agent.freeSockets[name].length, 1);
|
||||
assert.strictEqual(agent.sockets[name], undefined);
|
||||
assert.strictEqual(agent.freeSockets[name].length, 1);
|
||||
// waitting remote server close the socket
|
||||
setTimeout(function() {
|
||||
assert.equal(agent.sockets[name], undefined);
|
||||
assert.equal(agent.freeSockets[name], undefined,
|
||||
'freeSockets is not empty');
|
||||
assert.strictEqual(agent.sockets[name], undefined);
|
||||
assert.strictEqual(agent.freeSockets[name], undefined,
|
||||
'freeSockets is not empty');
|
||||
remoteError();
|
||||
}, common.platformTimeout(200));
|
||||
});
|
||||
@@ -89,13 +89,13 @@ function remoteError() {
|
||||
});
|
||||
req.on('error', function(err) {
|
||||
assert.ok(err);
|
||||
assert.equal(err.message, 'socket hang up');
|
||||
assert.equal(agent.sockets[name].length, 1);
|
||||
assert.equal(agent.freeSockets[name], undefined);
|
||||
assert.strictEqual(err.message, 'socket hang up');
|
||||
assert.strictEqual(agent.sockets[name].length, 1);
|
||||
assert.strictEqual(agent.freeSockets[name], undefined);
|
||||
// Wait socket 'close' event emit
|
||||
setTimeout(function() {
|
||||
assert.equal(agent.sockets[name], undefined);
|
||||
assert.equal(agent.freeSockets[name], undefined);
|
||||
assert.strictEqual(agent.sockets[name], undefined);
|
||||
assert.strictEqual(agent.freeSockets[name], undefined);
|
||||
done();
|
||||
}, common.platformTimeout(1));
|
||||
});
|
||||
@@ -110,14 +110,14 @@ server.listen(0, function() {
|
||||
name = `localhost:${server.address().port}:`;
|
||||
// request first, and keep alive
|
||||
get('/first', function(res) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
res.on('data', checkDataAndSockets);
|
||||
res.on('end', function() {
|
||||
assert.equal(agent.sockets[name].length, 1);
|
||||
assert.equal(agent.freeSockets[name], undefined);
|
||||
assert.strictEqual(agent.sockets[name].length, 1);
|
||||
assert.strictEqual(agent.freeSockets[name], undefined);
|
||||
process.nextTick(function() {
|
||||
assert.equal(agent.sockets[name], undefined);
|
||||
assert.equal(agent.freeSockets[name].length, 1);
|
||||
assert.strictEqual(agent.sockets[name], undefined);
|
||||
assert.strictEqual(agent.freeSockets[name].length, 1);
|
||||
second();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,15 +29,15 @@ function done() {
|
||||
return;
|
||||
}
|
||||
const freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]];
|
||||
assert.equal(freepool.length, 2,
|
||||
'expect keep 2 free sockets, but got ' + freepool.length);
|
||||
assert.strictEqual(freepool.length, 2,
|
||||
'expect keep 2 free sockets, but got ' + freepool.length);
|
||||
agent.destroy();
|
||||
server.close();
|
||||
}
|
||||
|
||||
server.listen(0, function() {
|
||||
get('/1', function(res) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
res.resume();
|
||||
res.on('end', function() {
|
||||
process.nextTick(done);
|
||||
@@ -45,7 +45,7 @@ server.listen(0, function() {
|
||||
});
|
||||
|
||||
get('/2', function(res) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
res.resume();
|
||||
res.on('end', function() {
|
||||
process.nextTick(done);
|
||||
|
||||
@@ -35,5 +35,5 @@ server.listen(0, function() {
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(N * M, responses);
|
||||
assert.strictEqual(N * M, responses);
|
||||
});
|
||||
@@ -18,13 +18,13 @@ server.on('listening', function() {
|
||||
path: '/hello',
|
||||
agent: agent
|
||||
}, function(res) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(res.headers['x-date'], 'foo');
|
||||
assert.equal(res.headers['x-connection'], 'bar');
|
||||
assert.equal(res.headers['x-content-length'], 'baz');
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
assert.strictEqual(res.headers['x-date'], 'foo');
|
||||
assert.strictEqual(res.headers['x-connection'], 'bar');
|
||||
assert.strictEqual(res.headers['x-content-length'], 'baz');
|
||||
assert(res.headers['date']);
|
||||
assert.equal(res.headers['connection'], 'keep-alive');
|
||||
assert.equal(res.headers['content-length'], '0');
|
||||
assert.strictEqual(res.headers['connection'], 'keep-alive');
|
||||
assert.strictEqual(res.headers['content-length'], '0');
|
||||
server.close();
|
||||
agent.destroy();
|
||||
});
|
||||
|
||||
@@ -5,8 +5,8 @@ const http = require('http');
|
||||
const net = require('net');
|
||||
|
||||
const server = http.createServer(common.mustCall(function(req, res) {
|
||||
assert.equal('GET', req.method);
|
||||
assert.equal('/blah', req.url);
|
||||
assert.strictEqual('GET', req.method);
|
||||
assert.strictEqual('/blah', req.url);
|
||||
assert.deepStrictEqual({
|
||||
host: 'mapdevel.trolologames.ru:443',
|
||||
origin: 'http://mapdevel.trolologames.ru',
|
||||
|
||||
@@ -23,7 +23,7 @@ const web = http.Server(function(req, res) {
|
||||
process.stdout.write(',');
|
||||
measuredSize += d.length;
|
||||
for (let j = 0; j < d.length; j++) {
|
||||
assert.equal(buffer[i], d[j]);
|
||||
assert.strictEqual(buffer[i], d[j]);
|
||||
i++;
|
||||
}
|
||||
});
|
||||
@@ -54,7 +54,7 @@ web.listen(0, common.mustCall(function() {
|
||||
console.log('Got response');
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', common.mustCall(function(string) {
|
||||
assert.equal('thanks', string);
|
||||
assert.strictEqual('thanks', string);
|
||||
}));
|
||||
}));
|
||||
req.end(buffer);
|
||||
@@ -62,5 +62,5 @@ web.listen(0, common.mustCall(function() {
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(bufferSize, measuredSize);
|
||||
assert.strictEqual(bufferSize, measuredSize);
|
||||
});
|
||||
@@ -5,7 +5,7 @@ const assert = require('assert');
|
||||
const http = require('http');
|
||||
|
||||
const uncaughtCallback = common.mustCall(function(er) {
|
||||
assert.equal(er.message, 'get did fail');
|
||||
assert.strictEqual(er.message, 'get did fail');
|
||||
});
|
||||
|
||||
process.on('uncaughtException', uncaughtCallback);
|
||||
|
||||
@@ -52,8 +52,8 @@ function executeRequest(cb) {
|
||||
'shasum' ].join(' '),
|
||||
(err, stdout, stderr) => {
|
||||
assert.ifError(err);
|
||||
assert.equal('8c206a1a87599f532ce68675536f0b1546900d7a',
|
||||
stdout.slice(0, 40));
|
||||
assert.strictEqual('8c206a1a87599f532ce68675536f0b1546900d7a',
|
||||
stdout.slice(0, 40));
|
||||
cb();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -30,9 +30,9 @@ server.listen(0, function() {
|
||||
throw e;
|
||||
});
|
||||
x.on('end', function() {
|
||||
assert.equal('string', typeof data);
|
||||
assert.strictEqual('string', typeof data);
|
||||
console.log('here is the response:');
|
||||
assert.equal(UTF8_STRING, data);
|
||||
assert.strictEqual(UTF8_STRING, data);
|
||||
console.log(data);
|
||||
server.close();
|
||||
});
|
||||
|
||||
@@ -51,5 +51,5 @@ server.listen(0, function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(N, clientAborts);
|
||||
assert.strictEqual(N, clientAborts);
|
||||
});
|
||||
@@ -34,7 +34,7 @@ function request(i) {
|
||||
socket.on('close', function() {
|
||||
++count;
|
||||
if (count < max) {
|
||||
assert.equal(http.globalAgent.sockets[name].indexOf(socket), -1);
|
||||
assert.strictEqual(http.globalAgent.sockets[name].indexOf(socket), -1);
|
||||
} else {
|
||||
assert(!http.globalAgent.sockets.hasOwnProperty(name));
|
||||
assert(!http.globalAgent.requests.hasOwnProperty(name));
|
||||
@@ -46,5 +46,5 @@ function request(i) {
|
||||
}
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(count, max);
|
||||
assert.strictEqual(count, max);
|
||||
});
|
||||
@@ -6,8 +6,8 @@ const url = require('url');
|
||||
const URL = url.URL;
|
||||
|
||||
const server = http.createServer(common.mustCall(function(req, res) {
|
||||
assert.equal('GET', req.method);
|
||||
assert.equal('/foo?bar', req.url);
|
||||
assert.strictEqual('GET', req.method);
|
||||
assert.strictEqual('/foo?bar', req.url);
|
||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||
res.write('hello\n');
|
||||
res.end();
|
||||
|
||||
@@ -27,13 +27,13 @@ net.createServer(function(c) {
|
||||
}).on('error', function(e) {
|
||||
console.log('got error from client');
|
||||
assert.ok(e.message.indexOf('Parse Error') >= 0);
|
||||
assert.equal(e.code, 'HPE_INVALID_CONSTANT');
|
||||
assert.strictEqual(e.code, 'HPE_INVALID_CONSTANT');
|
||||
parseErrors++;
|
||||
}).end();
|
||||
}
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(connects, 2);
|
||||
assert.equal(parseErrors, 2);
|
||||
assert.strictEqual(connects, 2);
|
||||
assert.strictEqual(parseErrors, 2);
|
||||
});
|
||||
@@ -83,7 +83,7 @@ server.on('listening', function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(body1_s, body1);
|
||||
assert.equal(body2_s, body2);
|
||||
assert.equal(body3_s, body3);
|
||||
assert.strictEqual(body1_s, body1);
|
||||
assert.strictEqual(body2_s, body2);
|
||||
assert.strictEqual(body3_s, body3);
|
||||
});
|
||||
@@ -41,6 +41,6 @@ server.on('listening', function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(body1_s, body1);
|
||||
assert.equal(body2_s, body2);
|
||||
assert.strictEqual(body1_s, body1);
|
||||
assert.strictEqual(body2_s, body2);
|
||||
});
|
||||
@@ -22,7 +22,7 @@ server.listen(0, () => {
|
||||
});
|
||||
req.on('error', common.mustCall((err) => {
|
||||
assert(/^Parse Error/.test(err.message));
|
||||
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||
server.close();
|
||||
}));
|
||||
});
|
||||
@@ -21,7 +21,7 @@ server.listen(0, () => {
|
||||
});
|
||||
req.on('error', common.mustCall((err) => {
|
||||
assert(/^Parse Error/.test(err.message));
|
||||
assert.equal(err.code, 'HPE_LF_EXPECTED');
|
||||
assert.strictEqual(err.code, 'HPE_LF_EXPECTED');
|
||||
server.close();
|
||||
}));
|
||||
});
|
||||
@@ -23,7 +23,7 @@ server.listen(common.PIPE, function() {
|
||||
function test() {
|
||||
|
||||
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({
|
||||
|
||||
@@ -6,7 +6,7 @@ const http = require('http');
|
||||
const N = 1024;
|
||||
|
||||
const server = http.createServer(common.mustCall(function(req, res) {
|
||||
assert.equal('POST', req.method);
|
||||
assert.strictEqual('POST', req.method);
|
||||
|
||||
let bytesReceived = 0;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const assert = require('assert');
|
||||
const http = require('http');
|
||||
|
||||
const server = http.createServer(common.mustCall(function(req, res) {
|
||||
assert.equal('POST', req.method);
|
||||
assert.strictEqual('POST', req.method);
|
||||
req.setEncoding('utf8');
|
||||
|
||||
let sent_body = '';
|
||||
|
||||
@@ -23,7 +23,7 @@ function onListen() {
|
||||
assert.ok(false, 'this should never run');
|
||||
});
|
||||
req.on('error', common.mustCall(function(err) {
|
||||
assert.equal(err.code, 'ECONNRESET');
|
||||
assert.strictEqual(err.code, 'ECONNRESET');
|
||||
}));
|
||||
req.end();
|
||||
}
|
||||
@@ -5,8 +5,8 @@ const http = require('http');
|
||||
|
||||
const server = http.createServer(common.fail);
|
||||
server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) {
|
||||
assert.equal(req.method, 'CONNECT');
|
||||
assert.equal(req.url, 'example.com:443');
|
||||
assert.strictEqual(req.method, 'CONNECT');
|
||||
assert.strictEqual(req.url, 'example.com:443');
|
||||
console.error('Server got CONNECT request');
|
||||
|
||||
// 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.
|
||||
assert(!socket.ondata);
|
||||
assert(!socket.onend);
|
||||
assert.equal(socket.listeners('connect').length, 0);
|
||||
assert.equal(socket.listeners('data').length, 0);
|
||||
assert.strictEqual(socket.listeners('connect').length, 0);
|
||||
assert.strictEqual(socket.listeners('data').length, 0);
|
||||
|
||||
let data = firstBodyChunk.toString();
|
||||
|
||||
// test that the firstBodyChunk was not parsed as HTTP
|
||||
assert.equal(data, 'Head');
|
||||
assert.strictEqual(data, 'Head');
|
||||
|
||||
socket.on('data', function(buf) {
|
||||
data += buf.toString();
|
||||
});
|
||||
socket.on('end', function() {
|
||||
assert.equal(data, 'HeadRequestEnd');
|
||||
assert.strictEqual(data, 'HeadRequestEnd');
|
||||
server.close();
|
||||
});
|
||||
socket.end('End');
|
||||
|
||||
@@ -23,7 +23,7 @@ const server = http.createServer(common.mustCall(function(req, res) {
|
||||
http.get({ createConnection: fn }, function(res) {
|
||||
common.fail('Unexpected response callback');
|
||||
}).on('error', common.mustCall(function(err) {
|
||||
assert.equal(err.message, 'Could not create socket');
|
||||
assert.strictEqual(err.message, 'Could not create socket');
|
||||
server.close();
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -33,5 +33,5 @@ server.listen(0, function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(expected, result);
|
||||
assert.strictEqual(expected, result);
|
||||
});
|
||||
@@ -29,8 +29,8 @@ process.on('exit', function() {
|
||||
});
|
||||
|
||||
http.createServer(function(req, res) {
|
||||
assert.equal(req.headers.host, hostExpect);
|
||||
assert.equal(req.headers['x-port'], this.address().port);
|
||||
assert.strictEqual(req.headers.host, hostExpect);
|
||||
assert.strictEqual(req.headers['x-port'], this.address().port.toString());
|
||||
res.writeHead(200);
|
||||
res.end('ok');
|
||||
this.close();
|
||||
@@ -49,8 +49,8 @@ http.createServer(function(req, res) {
|
||||
|
||||
if (common.hasCrypto) {
|
||||
https.createServer(options, function(req, res) {
|
||||
assert.equal(req.headers.host, hostExpect);
|
||||
assert.equal(req.headers['x-port'], this.address().port);
|
||||
assert.strictEqual(req.headers.host, hostExpect);
|
||||
assert.strictEqual(req.headers['x-port'], this.address().port.toString());
|
||||
res.writeHead(200);
|
||||
res.end('ok');
|
||||
this.close();
|
||||
|
||||
@@ -47,8 +47,8 @@ server.listen(0, function() {
|
||||
break;
|
||||
}
|
||||
|
||||
assert.equal(req.output.length, 0);
|
||||
assert.equal(req.outputEncodings.length, 0);
|
||||
assert.strictEqual(req.output.length, 0);
|
||||
assert.strictEqual(req.outputEncodings.length, 0);
|
||||
server.close();
|
||||
}));
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const server = http.createServer((req, res) => {
|
||||
});
|
||||
server.on('clientError', common.mustCall((err, socket) => {
|
||||
assert(/^Parse Error/.test(err.message));
|
||||
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||
socket.destroy();
|
||||
}));
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ let sent_continue = false;
|
||||
let got_continue = false;
|
||||
|
||||
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...');
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'text/plain',
|
||||
@@ -47,15 +48,15 @@ server.on('listening', function() {
|
||||
req.end(test_req_body);
|
||||
});
|
||||
req.on('response', function(res) {
|
||||
assert.equal(got_continue, true,
|
||||
'Full response received before 100 Continue');
|
||||
assert.equal(200, res.statusCode,
|
||||
'Final status code was ' + res.statusCode + ', not 200.');
|
||||
assert.strictEqual(got_continue, true,
|
||||
'Full response received before 100 Continue');
|
||||
assert.strictEqual(200, res.statusCode, 'Final status code was ' +
|
||||
res.statusCode + ', not 200.');
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', function(chunk) { body += chunk; });
|
||||
res.on('end', function() {
|
||||
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.');
|
||||
outstanding_reqs--;
|
||||
if (outstanding_reqs === 0) {
|
||||
|
||||
@@ -37,8 +37,8 @@ function nextTest() {
|
||||
http.get(options, function(response) {
|
||||
console.log('client: expected status: ' + test);
|
||||
console.log('client: statusCode: ' + response.statusCode);
|
||||
assert.equal(response.statusCode, test);
|
||||
assert.equal(response.statusMessage, 'Expectation Failed');
|
||||
assert.strictEqual(response.statusCode, test);
|
||||
assert.strictEqual(response.statusMessage, 'Expectation Failed');
|
||||
|
||||
response.on('end', function() {
|
||||
testsComplete++;
|
||||
@@ -51,5 +51,5 @@ function nextTest() {
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(2, testsComplete);
|
||||
assert.strictEqual(2, testsComplete);
|
||||
});
|
||||
@@ -36,7 +36,7 @@ const server = net.createServer(function(socket) {
|
||||
});
|
||||
|
||||
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() {
|
||||
console.log('Response ended, read ' + buffer.length + ' bytes');
|
||||
assert.equal(body, buffer);
|
||||
assert.strictEqual(body, buffer);
|
||||
server.close();
|
||||
}));
|
||||
}));
|
||||
|
||||
@@ -5,7 +5,7 @@ const http = require('http');
|
||||
|
||||
const server = http.createServer();
|
||||
server.on('request', function(req, res) {
|
||||
assert.equal(req.headers['foo'], 'bar');
|
||||
assert.strictEqual(req.headers['foo'], 'bar');
|
||||
res.end('ok');
|
||||
server.close();
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ server.listen(0, common.localhostIPv4, function() {
|
||||
req.end();
|
||||
|
||||
function onResponse(res) {
|
||||
assert.equal(res.headers['foo'], 'bar');
|
||||
assert.strictEqual(res.headers['foo'], 'bar');
|
||||
res.destroy();
|
||||
server.close();
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ function runAb(opts, callback) {
|
||||
m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout);
|
||||
const htmlTransfered = parseInt(m[1]);
|
||||
|
||||
assert.equal(bodyLength, documentLength);
|
||||
assert.equal(completeRequests * documentLength, htmlTransfered);
|
||||
assert.strictEqual(bodyLength, documentLength);
|
||||
assert.strictEqual(completeRequests * documentLength, htmlTransfered);
|
||||
|
||||
if (callback) callback();
|
||||
});
|
||||
|
||||
@@ -74,8 +74,8 @@ function checkFiles() {
|
||||
const fn = i + '.jpg';
|
||||
assert.ok(files.indexOf(fn) >= 0, "couldn't find '" + fn + "'");
|
||||
const stat = fs.statSync(common.tmpDir + '/' + fn);
|
||||
assert.equal(image.length, stat.size,
|
||||
"size doesn't match on '" + fn +
|
||||
assert.strictEqual(image.length, stat.size,
|
||||
"size doesn't match on '" + fn +
|
||||
"'. Got " + stat.size + ' bytes');
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ function checkFiles() {
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(total, requests);
|
||||
assert.equal(total, responses);
|
||||
assert.strictEqual(total, requests);
|
||||
assert.strictEqual(total, responses);
|
||||
assert.ok(checkedFiles);
|
||||
});
|
||||
@@ -18,7 +18,7 @@ const s = http.createServer(function(req, res) {
|
||||
// and does not throw an exception (Issue 752)
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
assert.equal(plain, res.getHeader(contentType));
|
||||
assert.strictEqual(plain, res.getHeader(contentType));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -7,10 +7,10 @@ const httpServer = http.createServer(reqHandler);
|
||||
function reqHandler(req, res) {
|
||||
console.log('Got request: ' + req.headers.host + ' ' + req.url);
|
||||
if (req.url === '/setHostFalse5') {
|
||||
assert.equal(req.headers.host, undefined);
|
||||
assert.strictEqual(req.headers.host, undefined);
|
||||
} else {
|
||||
assert.equal(req.headers.host, `localhost:${this.address().port}`,
|
||||
'Wrong host header for req[' + req.url + ']: ' +
|
||||
assert.strictEqual(req.headers.host, `localhost:${this.address().port}`,
|
||||
'Wrong host header for req[' + req.url + ']: ' +
|
||||
req.headers.host);
|
||||
}
|
||||
res.writeHead(200, {});
|
||||
|
||||
@@ -25,7 +25,7 @@ server.listen(0, function() {
|
||||
port: this.address().port,
|
||||
agent: agent
|
||||
}, function(res) {
|
||||
assert.equal(1, agent.sockets[name].length);
|
||||
assert.strictEqual(1, agent.sockets[name].length);
|
||||
res.resume();
|
||||
});
|
||||
request.on('socket', function(s) {
|
||||
@@ -42,7 +42,7 @@ server.listen(0, function() {
|
||||
port: this.address().port,
|
||||
agent: agent
|
||||
}, function(res) {
|
||||
assert.equal(1, agent.sockets[name].length);
|
||||
assert.strictEqual(1, agent.sockets[name].length);
|
||||
res.resume();
|
||||
});
|
||||
request.on('socket', function(s) {
|
||||
@@ -59,7 +59,7 @@ server.listen(0, function() {
|
||||
agent: agent
|
||||
}, function(response) {
|
||||
response.on('end', function() {
|
||||
assert.equal(1, agent.sockets[name].length);
|
||||
assert.strictEqual(1, agent.sockets[name].length);
|
||||
server.close();
|
||||
});
|
||||
response.resume();
|
||||
@@ -73,5 +73,5 @@ server.listen(0, function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(3, connectCount);
|
||||
assert.strictEqual(3, connectCount);
|
||||
});
|
||||
@@ -9,7 +9,7 @@ let serverSocket = null;
|
||||
const server = http.createServer(function(req, res) {
|
||||
// They should all come in on the same server socket.
|
||||
if (serverSocket) {
|
||||
assert.equal(req.socket, serverSocket);
|
||||
assert.strictEqual(req.socket, serverSocket);
|
||||
} else {
|
||||
serverSocket = req.socket;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ function makeRequest(n) {
|
||||
|
||||
req.on('socket', function(sock) {
|
||||
if (clientSocket) {
|
||||
assert.equal(sock, clientSocket);
|
||||
assert.strictEqual(sock, clientSocket);
|
||||
} else {
|
||||
clientSocket = sock;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ function makeRequest(n) {
|
||||
data += c;
|
||||
});
|
||||
res.on('end', function() {
|
||||
assert.equal(data, '/' + n);
|
||||
assert.strictEqual(data, '/' + n);
|
||||
setTimeout(function() {
|
||||
actualRequests++;
|
||||
makeRequest(n - 1);
|
||||
@@ -68,6 +68,6 @@ function makeRequest(n) {
|
||||
}
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(actualRequests, expectRequests);
|
||||
assert.strictEqual(actualRequests, expectRequests);
|
||||
console.log('ok');
|
||||
});
|
||||
@@ -22,17 +22,17 @@ server.listen(0, function() {
|
||||
let closed = false;
|
||||
makeReqs(10, function(er) {
|
||||
assert.ifError(er);
|
||||
assert.equal(count(agent.freeSockets), 2);
|
||||
assert.equal(count(agent.sockets), 0);
|
||||
assert.equal(serverSockets.length, 5);
|
||||
assert.strictEqual(count(agent.freeSockets), 2);
|
||||
assert.strictEqual(count(agent.sockets), 0);
|
||||
assert.strictEqual(serverSockets.length, 5);
|
||||
|
||||
// now make 10 more reqs.
|
||||
// should use the 2 free reqs from the pool first.
|
||||
makeReqs(10, function(er) {
|
||||
assert.ifError(er);
|
||||
assert.equal(count(agent.freeSockets), 2);
|
||||
assert.equal(count(agent.sockets), 0);
|
||||
assert.equal(serverSockets.length, 8);
|
||||
assert.strictEqual(count(agent.freeSockets), 2);
|
||||
assert.strictEqual(count(agent.sockets), 0);
|
||||
assert.strictEqual(serverSockets.length, 8);
|
||||
|
||||
agent.destroy();
|
||||
server.close(function() {
|
||||
@@ -72,7 +72,7 @@ server.listen(0, function() {
|
||||
data += c;
|
||||
});
|
||||
res.on('end', function() {
|
||||
assert.equal(data, '/' + i);
|
||||
assert.strictEqual(data, '/' + i);
|
||||
cb();
|
||||
});
|
||||
}).end();
|
||||
|
||||
@@ -9,7 +9,7 @@ let serverSocket = null;
|
||||
const server = http.createServer(function(req, res) {
|
||||
// They should all come in on the same server socket.
|
||||
if (serverSocket) {
|
||||
assert.equal(req.socket, serverSocket);
|
||||
assert.strictEqual(req.socket, serverSocket);
|
||||
} else {
|
||||
serverSocket = req.socket;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ function makeRequest(n) {
|
||||
|
||||
req.on('socket', function(sock) {
|
||||
if (clientSocket) {
|
||||
assert.equal(sock, clientSocket);
|
||||
assert.strictEqual(sock, clientSocket);
|
||||
} else {
|
||||
clientSocket = sock;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ function makeRequest(n) {
|
||||
data += c;
|
||||
});
|
||||
res.on('end', function() {
|
||||
assert.equal(data, '/' + n);
|
||||
assert.strictEqual(data, '/' + n);
|
||||
setTimeout(function() {
|
||||
actualRequests++;
|
||||
makeRequest(n - 1);
|
||||
@@ -68,6 +68,6 @@ function makeRequest(n) {
|
||||
}
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(actualRequests, expectRequests);
|
||||
assert.strictEqual(actualRequests, expectRequests);
|
||||
console.log('ok');
|
||||
});
|
||||
@@ -10,7 +10,7 @@ if (!common.hasMultiLocalhost()) {
|
||||
|
||||
const server = http.createServer(function(req, res) {
|
||||
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() {
|
||||
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||
|
||||
@@ -31,5 +31,5 @@ server.on('listening', function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(nrequests_expected, nrequests_completed);
|
||||
assert.strictEqual(nrequests_expected, nrequests_completed);
|
||||
});
|
||||
@@ -21,7 +21,7 @@ let max = maxAndExpected[requests][0];
|
||||
let expected = maxAndExpected[requests][1];
|
||||
|
||||
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) {
|
||||
max = maxAndExpected[requests][0];
|
||||
expected = maxAndExpected[requests][1];
|
||||
@@ -47,7 +47,7 @@ server.listen(0, function() {
|
||||
port: server.address().port,
|
||||
headers: headers
|
||||
}, function(res) {
|
||||
assert.equal(Object.keys(res.headers).length, expected);
|
||||
assert.strictEqual(Object.keys(res.headers).length, expected);
|
||||
res.on('end', function() {
|
||||
if (++responses < maxAndExpected.length) {
|
||||
doRequest();
|
||||
@@ -63,6 +63,6 @@ server.listen(0, function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(requests, maxAndExpected.length);
|
||||
assert.equal(responses, maxAndExpected.length);
|
||||
assert.strictEqual(requests, maxAndExpected.length);
|
||||
assert.strictEqual(responses, maxAndExpected.length);
|
||||
});
|
||||
@@ -27,8 +27,8 @@ server.listen(0, common.mustCall(function() {
|
||||
host: '127.0.0.1',
|
||||
port: this.address().port
|
||||
}, common.mustCall(function(res) {
|
||||
assert.equal(res.headers['content-type'],
|
||||
'text/plain; x-unix-mode=0600; name="hello.txt"');
|
||||
assert.strictEqual(res.headers['content-type'],
|
||||
'text/plain; x-unix-mode=0600; name="hello.txt"');
|
||||
res.destroy();
|
||||
}));
|
||||
}));
|
||||
@@ -83,7 +83,7 @@ demoBug('POST /1/22 HTTP/1.1\r\n' +
|
||||
/* eslint-enable align-function-arguments */
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(2, headersComplete);
|
||||
assert.equal(2, messagesComplete);
|
||||
assert.strictEqual(2, headersComplete);
|
||||
assert.strictEqual(2, messagesComplete);
|
||||
console.log('done!');
|
||||
});
|
||||
@@ -31,5 +31,5 @@ server.listen(0, function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(responses, N);
|
||||
assert.strictEqual(responses, N);
|
||||
});
|
||||
@@ -51,7 +51,7 @@ function mustCall(f, times) {
|
||||
|
||||
process.setMaxListeners(256);
|
||||
process.on('exit', function() {
|
||||
assert.equal(actual, times || 1);
|
||||
assert.strictEqual(actual, times || 1);
|
||||
});
|
||||
|
||||
return function() {
|
||||
@@ -64,7 +64,7 @@ function mustCall(f, times) {
|
||||
function expectBody(expected) {
|
||||
return mustCall(function(buf, 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,
|
||||
method, url, statusCode, statusMessage,
|
||||
upgrade, shouldKeepAlive) {
|
||||
assert.equal(method, methods.indexOf('PUT'));
|
||||
assert.equal(url, '/this');
|
||||
assert.equal(versionMajor, 1);
|
||||
assert.equal(versionMinor, 1);
|
||||
assert.strictEqual(method, methods.indexOf('PUT'));
|
||||
assert.strictEqual(url, '/this');
|
||||
assert.strictEqual(versionMajor, 1);
|
||||
assert.strictEqual(versionMinor, 1);
|
||||
assert.deepStrictEqual(
|
||||
headers,
|
||||
['Content-Type', 'text/plain', 'Transfer-Encoding', 'chunked']);
|
||||
|
||||
@@ -50,6 +50,6 @@ server.listen(0, function() {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(expectedServer, resultServer);
|
||||
assert.equal(expectedClient, resultClient);
|
||||
assert.strictEqual(expectedServer, resultServer);
|
||||
assert.strictEqual(expectedClient, resultClient);
|
||||
});
|
||||
@@ -29,5 +29,5 @@ const server = http.createServer(function(req, res) {
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(received, COUNT);
|
||||
assert.strictEqual(received, COUNT);
|
||||
});
|
||||
@@ -36,5 +36,5 @@ process.on('exit', function() {
|
||||
// The server should pause connection on pipeline flood, but it shoul still
|
||||
// resume it and finish processing the requests, when its output queue will
|
||||
// be empty again.
|
||||
assert.equal(received, COUNT);
|
||||
assert.strictEqual(received, COUNT);
|
||||
});
|
||||
@@ -29,8 +29,8 @@ const proxy = http.createServer(function(req, res) {
|
||||
|
||||
console.error('proxy res headers: ' + JSON.stringify(proxy_res.headers));
|
||||
|
||||
assert.equal('world', proxy_res.headers['hello']);
|
||||
assert.equal('text/plain', proxy_res.headers['content-type']);
|
||||
assert.strictEqual('world', proxy_res.headers['hello']);
|
||||
assert.strictEqual('text/plain', proxy_res.headers['content-type']);
|
||||
assert.deepStrictEqual(cookies, proxy_res.headers['set-cookie']);
|
||||
|
||||
res.writeHead(proxy_res.statusCode, proxy_res.headers);
|
||||
@@ -58,10 +58,10 @@ function startReq() {
|
||||
path: '/test'
|
||||
}, function(res) {
|
||||
console.error('got res');
|
||||
assert.equal(200, res.statusCode);
|
||||
assert.strictEqual(200, res.statusCode);
|
||||
|
||||
assert.equal('world', res.headers['hello']);
|
||||
assert.equal('text/plain', res.headers['content-type']);
|
||||
assert.strictEqual('world', res.headers['hello']);
|
||||
assert.strictEqual('text/plain', res.headers['content-type']);
|
||||
assert.deepStrictEqual(cookies, res.headers['set-cookie']);
|
||||
|
||||
res.setEncoding('utf8');
|
||||
@@ -82,5 +82,5 @@ console.error('listen backend');
|
||||
backend.listen(0, startReq);
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(body, 'hello world\n');
|
||||
assert.strictEqual(body, 'hello world\n');
|
||||
});
|
||||
@@ -23,13 +23,13 @@ const server = http.createServer(function(request, response) {
|
||||
let response = '';
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal('beep boop\n', response);
|
||||
assert.strictEqual('beep boop\n', response);
|
||||
console.log('ok');
|
||||
});
|
||||
|
||||
server.listen(0, function() {
|
||||
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' });
|
||||
|
||||
res.setEncoding('ascii');
|
||||
|
||||
@@ -33,7 +33,7 @@ http.createServer(function(req, res) {
|
||||
}).end();
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(requests, 1);
|
||||
assert.strictEqual(requests, 1);
|
||||
|
||||
assert.strictEqual(options.host, undefined);
|
||||
assert.strictEqual(options.hostname, common.localhostIPv4);
|
||||
|
||||
@@ -12,7 +12,7 @@ const server = http.Server(common.mustCall(function(req, res) {
|
||||
res.end();
|
||||
|
||||
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() {
|
||||
|
||||
@@ -39,7 +39,7 @@ server.listen(0, common.mustCall(() => {
|
||||
}
|
||||
).on('error', common.mustCall((err) => {
|
||||
assert(/^Parse Error/.test(err.message));
|
||||
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||
count++;
|
||||
if (count === MAX_COUNT)
|
||||
server.close();
|
||||
@@ -48,5 +48,5 @@ server.listen(0, common.mustCall(() => {
|
||||
}));
|
||||
|
||||
process.on('exit', () => {
|
||||
assert.equal(count, MAX_COUNT);
|
||||
assert.strictEqual(count, MAX_COUNT);
|
||||
});
|
||||
Loaded 100 of 331 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user