mirror of https://github.com/nodejs/node.git
test: avoid deep comparisons with literals
Comparing any value to any non-RegExp literal or undefined using strictEqual (or notStrictEqual) passes if and only if deepStrictEqual (or notDeepStrictEqual, respectively) passes. Unnecessarily using deep comparisons adds confusion. This patch adds an ESLint rule that forbids the use of deepStrictEqual and notDeepStrictEqual when the expected value (i.e., the second argument) is a non-RegExp literal or undefined. For reference, an ESTree literal is defined as follows. extend interface Literal <: Expression { type: "Literal"; value: string | boolean | null | number | RegExp | bigint; } The value `undefined` is an `Identifier` with `name: 'undefined'`. PR-URL: https://github.com/nodejs/node/pull/40634 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Voltrex <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
parent
229a182823
commit
dd52c05046
|
@ -13,6 +13,10 @@ rules:
|
||||||
no-restricted-syntax:
|
no-restricted-syntax:
|
||||||
# Config copied from .eslintrc.js
|
# Config copied from .eslintrc.js
|
||||||
- error
|
- error
|
||||||
|
- selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])"
|
||||||
|
message: "Use strictEqual instead of deepStrictEqual for literals or undefined."
|
||||||
|
- selector: "CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])"
|
||||||
|
message: "Use notStrictEqual instead of notDeepStrictEqual for literals or undefined."
|
||||||
- selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.2.type='Literal']"
|
- selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.2.type='Literal']"
|
||||||
message: "Do not use a literal for the third argument of assert.deepStrictEqual()"
|
message: "Do not use a literal for the third argument of assert.deepStrictEqual()"
|
||||||
- selector: "CallExpression:matches([callee.name='doesNotThrow'], [callee.property.name='doesNotThrow'])"
|
- selector: "CallExpression:matches([callee.name='doesNotThrow'], [callee.property.name='doesNotThrow'])"
|
||||||
|
|
|
@ -15,7 +15,7 @@ function createBase64URL(mime, body) {
|
||||||
const plainESMURL = createURL('text/javascript', body);
|
const plainESMURL = createURL('text/javascript', body);
|
||||||
const ns = await import(plainESMURL);
|
const ns = await import(plainESMURL);
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default.a, 'aaa');
|
assert.strictEqual(ns.default.a, 'aaa');
|
||||||
const importerOfURL = createURL(
|
const importerOfURL = createURL(
|
||||||
'text/javascript',
|
'text/javascript',
|
||||||
`export {default as default} from ${JSON.stringify(plainESMURL)}`
|
`export {default as default} from ${JSON.stringify(plainESMURL)}`
|
||||||
|
@ -35,40 +35,40 @@ function createBase64URL(mime, body) {
|
||||||
const plainESMURL = createURL('text/javascript', body);
|
const plainESMURL = createURL('text/javascript', body);
|
||||||
const ns = await import(plainESMURL);
|
const ns = await import(plainESMURL);
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default, plainESMURL);
|
assert.strictEqual(ns.default, plainESMURL);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const body = 'export default import.meta.url;';
|
const body = 'export default import.meta.url;';
|
||||||
const plainESMURL = createURL('text/javascript;charset=UTF-8', body);
|
const plainESMURL = createURL('text/javascript;charset=UTF-8', body);
|
||||||
const ns = await import(plainESMURL);
|
const ns = await import(plainESMURL);
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default, plainESMURL);
|
assert.strictEqual(ns.default, plainESMURL);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const body = 'export default import.meta.url;';
|
const body = 'export default import.meta.url;';
|
||||||
const plainESMURL = createURL('text/javascript;charset="UTF-8"', body);
|
const plainESMURL = createURL('text/javascript;charset="UTF-8"', body);
|
||||||
const ns = await import(plainESMURL);
|
const ns = await import(plainESMURL);
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default, plainESMURL);
|
assert.strictEqual(ns.default, plainESMURL);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const body = 'export default import.meta.url;';
|
const body = 'export default import.meta.url;';
|
||||||
const plainESMURL = createURL('text/javascript;;a=a;b=b;;', body);
|
const plainESMURL = createURL('text/javascript;;a=a;b=b;;', body);
|
||||||
const ns = await import(plainESMURL);
|
const ns = await import(plainESMURL);
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default, plainESMURL);
|
assert.strictEqual(ns.default, plainESMURL);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const ns = await import('data:application/json;foo="test,"this"');
|
const ns = await import('data:application/json;foo="test,"this"');
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default, 'this');
|
assert.strictEqual(ns.default, 'this');
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const ns = await import(`data:application/json;foo=${
|
const ns = await import(`data:application/json;foo=${
|
||||||
encodeURIComponent('test,')
|
encodeURIComponent('test,')
|
||||||
},0`);
|
},0`);
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default, 0);
|
assert.strictEqual(ns.default, 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
await assert.rejects(async () => {
|
await assert.rejects(async () => {
|
||||||
|
@ -83,14 +83,14 @@ function createBase64URL(mime, body) {
|
||||||
const plainESMURL = createURL('application/json', body);
|
const plainESMURL = createURL('application/json', body);
|
||||||
const ns = await import(plainESMURL);
|
const ns = await import(plainESMURL);
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default.x, 1);
|
assert.strictEqual(ns.default.x, 1);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const body = '{"default": 2}';
|
const body = '{"default": 2}';
|
||||||
const plainESMURL = createURL('application/json', body);
|
const plainESMURL = createURL('application/json', body);
|
||||||
const ns = await import(plainESMURL);
|
const ns = await import(plainESMURL);
|
||||||
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
assert.deepStrictEqual(Object.keys(ns), ['default']);
|
||||||
assert.deepStrictEqual(ns.default.default, 2);
|
assert.strictEqual(ns.default.default, 2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const body = 'null';
|
const body = 'null';
|
||||||
|
|
|
@ -118,10 +118,10 @@ assert.deepStrictEqual(new String(''), test.toObject(''));
|
||||||
assert.deepStrictEqual(new Number(0), test.toObject(0));
|
assert.deepStrictEqual(new Number(0), test.toObject(0));
|
||||||
assert.deepStrictEqual(new Number(Number.NaN), test.toObject(Number.NaN));
|
assert.deepStrictEqual(new Number(Number.NaN), test.toObject(Number.NaN));
|
||||||
assert.deepStrictEqual(new Object(testSym), test.toObject(testSym));
|
assert.deepStrictEqual(new Object(testSym), test.toObject(testSym));
|
||||||
assert.notDeepStrictEqual(test.toObject(false), false);
|
assert.notStrictEqual(test.toObject(false), false);
|
||||||
assert.notDeepStrictEqual(test.toObject(true), true);
|
assert.notStrictEqual(test.toObject(true), true);
|
||||||
assert.notDeepStrictEqual(test.toObject(''), '');
|
assert.notStrictEqual(test.toObject(''), '');
|
||||||
assert.notDeepStrictEqual(test.toObject(0), 0);
|
assert.notStrictEqual(test.toObject(0), 0);
|
||||||
assert.ok(!Number.isNaN(test.toObject(Number.NaN)));
|
assert.ok(!Number.isNaN(test.toObject(Number.NaN)));
|
||||||
|
|
||||||
assert.strictEqual(test.toString(''), '');
|
assert.strictEqual(test.toString(''), '');
|
||||||
|
|
|
@ -856,11 +856,13 @@ assert.throws(
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
() => assert.deepStrictEqual(4, '4'),
|
() => assert.deepStrictEqual(4, '4'),
|
||||||
{ message: `${defaultMsgStart}\n4 !== '4'\n` }
|
{ message: `${defaultMsgStart}\n4 !== '4'\n` }
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
() => assert.deepStrictEqual(true, 1),
|
() => assert.deepStrictEqual(true, 1),
|
||||||
{ message: `${defaultMsgStart}\ntrue !== 1\n` }
|
{ message: `${defaultMsgStart}\ntrue !== 1\n` }
|
||||||
);
|
);
|
||||||
|
|
|
@ -1243,6 +1243,7 @@ assert.throws(
|
||||||
{
|
{
|
||||||
let threw = false;
|
let threw = false;
|
||||||
try {
|
try {
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
assert.deepStrictEqual(Array(100).fill(1), 'foobar');
|
assert.deepStrictEqual(Array(100).fill(1), 'foobar');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
threw = true;
|
threw = true;
|
||||||
|
|
|
@ -422,8 +422,8 @@ assert.strictEqual(
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const h = crypto.createHmac('sha1', 'key').update('data');
|
const h = crypto.createHmac('sha1', 'key').update('data');
|
||||||
assert.deepStrictEqual(h.digest('latin1'), expected);
|
assert.strictEqual(h.digest('latin1'), expected);
|
||||||
assert.deepStrictEqual(h.digest('latin1'), '');
|
assert.strictEqual(h.digest('latin1'), '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,8 +440,8 @@ assert.strictEqual(
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const h = crypto.createHmac('sha1', 'key');
|
const h = crypto.createHmac('sha1', 'key');
|
||||||
assert.deepStrictEqual(h.digest('latin1'), expected);
|
assert.strictEqual(h.digest('latin1'), expected);
|
||||||
assert.deepStrictEqual(h.digest('latin1'), '');
|
assert.strictEqual(h.digest('latin1'), '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ dns.lookup('127.0.0.1', {
|
||||||
family: 4,
|
family: 4,
|
||||||
all: false
|
all: false
|
||||||
}, common.mustSucceed((result, addressType) => {
|
}, common.mustSucceed((result, addressType) => {
|
||||||
assert.deepStrictEqual(result, '127.0.0.1');
|
assert.strictEqual(result, '127.0.0.1');
|
||||||
assert.strictEqual(addressType, 4);
|
assert.strictEqual(addressType, 4);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -336,10 +336,10 @@ assert.throws(() => {
|
||||||
|
|
||||||
{
|
{
|
||||||
dns.resolveMx('foo.onion', function(err) {
|
dns.resolveMx('foo.onion', function(err) {
|
||||||
assert.deepStrictEqual(err.code, 'ENOTFOUND');
|
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||||
assert.deepStrictEqual(err.syscall, 'queryMx');
|
assert.strictEqual(err.syscall, 'queryMx');
|
||||||
assert.deepStrictEqual(err.hostname, 'foo.onion');
|
assert.strictEqual(err.hostname, 'foo.onion');
|
||||||
assert.deepStrictEqual(err.message, 'queryMx ENOTFOUND foo.onion');
|
assert.strictEqual(err.message, 'queryMx ENOTFOUND foo.onion');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,5 +64,5 @@ assert.strictEqual(cycle(Function), '[Function: Function]');
|
||||||
}
|
}
|
||||||
|
|
||||||
serializeError(new DynamicError());
|
serializeError(new DynamicError());
|
||||||
assert.deepStrictEqual(called, true);
|
assert.strictEqual(called, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ async function validateFilePermission() {
|
||||||
const fileHandle = await open(filePath, 'w+', 0o444);
|
const fileHandle = await open(filePath, 'w+', 0o444);
|
||||||
// File created with r--r--r-- 444
|
// File created with r--r--r-- 444
|
||||||
const statsBeforeMod = fs.statSync(filePath);
|
const statsBeforeMod = fs.statSync(filePath);
|
||||||
assert.deepStrictEqual(statsBeforeMod.mode & 0o444, 0o444);
|
assert.strictEqual(statsBeforeMod.mode & 0o444, 0o444);
|
||||||
|
|
||||||
let expectedAccess;
|
let expectedAccess;
|
||||||
const newPermissions = 0o765;
|
const newPermissions = 0o765;
|
||||||
|
|
|
@ -16,10 +16,10 @@ async function validateTruncate() {
|
||||||
const buffer = Buffer.from(text, 'utf8');
|
const buffer = Buffer.from(text, 'utf8');
|
||||||
await fileHandle.write(buffer, 0, buffer.length);
|
await fileHandle.write(buffer, 0, buffer.length);
|
||||||
|
|
||||||
assert.deepStrictEqual((await readFile(filename)).toString(), text);
|
assert.strictEqual((await readFile(filename)).toString(), text);
|
||||||
|
|
||||||
await fileHandle.truncate(5);
|
await fileHandle.truncate(5);
|
||||||
assert.deepStrictEqual((await readFile(filename)).toString(), 'Hello');
|
assert.strictEqual((await readFile(filename)).toString(), 'Hello');
|
||||||
|
|
||||||
await fileHandle.close();
|
await fileHandle.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ async function readFileTest() {
|
||||||
const buf = Buffer.alloc(5);
|
const buf = Buffer.alloc(5);
|
||||||
const { bytesRead } = await handle.read(buf, 0, 5, null);
|
const { bytesRead } = await handle.read(buf, 0, 5, null);
|
||||||
assert.strictEqual(bytesRead, 5);
|
assert.strictEqual(bytesRead, 5);
|
||||||
assert.deepStrictEqual(buf.toString(), 'Hello');
|
assert.strictEqual(buf.toString(), 'Hello');
|
||||||
|
|
||||||
/* readFile() should read from position five, instead of zero. */
|
/* readFile() should read from position five, instead of zero. */
|
||||||
assert.deepStrictEqual((await handle.readFile()).toString(), ' World');
|
assert.strictEqual((await handle.readFile()).toString(), ' World');
|
||||||
|
|
||||||
await handle.close();
|
await handle.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ async function writeFileTest() {
|
||||||
await handle.writeFile('World');
|
await handle.writeFile('World');
|
||||||
|
|
||||||
/* New content should be written at position five, instead of zero. */
|
/* New content should be written at position five, instead of zero. */
|
||||||
assert.deepStrictEqual(readFileSync(fn).toString(), 'HelloWorld');
|
assert.strictEqual(readFileSync(fn).toString(), 'HelloWorld');
|
||||||
|
|
||||||
await handle.close();
|
await handle.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ async function executeOnHandle(dest, func) {
|
||||||
assert.strictEqual(ret.bytesRead, bufLen);
|
assert.strictEqual(ret.bytesRead, bufLen);
|
||||||
assert.deepStrictEqual(ret.buffer, buf);
|
assert.deepStrictEqual(ret.buffer, buf);
|
||||||
await truncate(dest, 5);
|
await truncate(dest, 5);
|
||||||
assert.deepStrictEqual((await readFile(dest)).toString(), 'hello');
|
assert.strictEqual((await readFile(dest)).toString(), 'hello');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,11 +64,11 @@ function tempFdSync(callback) {
|
||||||
|
|
||||||
// Read only five bytes, so that the position moves to five.
|
// Read only five bytes, so that the position moves to five.
|
||||||
const buf = Buffer.alloc(5);
|
const buf = Buffer.alloc(5);
|
||||||
assert.deepStrictEqual(fs.readSync(fd, buf, 0, 5), 5);
|
assert.strictEqual(fs.readSync(fd, buf, 0, 5), 5);
|
||||||
assert.deepStrictEqual(buf.toString(), 'Hello');
|
assert.strictEqual(buf.toString(), 'Hello');
|
||||||
|
|
||||||
// readFileSync() should read from position five, instead of zero.
|
// readFileSync() should read from position five, instead of zero.
|
||||||
assert.deepStrictEqual(fs.readFileSync(fd).toString(), ' World');
|
assert.strictEqual(fs.readFileSync(fd).toString(), ' World');
|
||||||
|
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
}
|
}
|
||||||
|
@ -81,11 +81,11 @@ function tempFdSync(callback) {
|
||||||
// Read only five bytes, so that the position moves to five.
|
// Read only five bytes, so that the position moves to five.
|
||||||
fs.read(fd, buf, 0, 5, null, common.mustSucceed((bytes) => {
|
fs.read(fd, buf, 0, 5, null, common.mustSucceed((bytes) => {
|
||||||
assert.strictEqual(bytes, 5);
|
assert.strictEqual(bytes, 5);
|
||||||
assert.deepStrictEqual(buf.toString(), 'Hello');
|
assert.strictEqual(buf.toString(), 'Hello');
|
||||||
|
|
||||||
fs.readFile(fd, common.mustSucceed((data) => {
|
fs.readFile(fd, common.mustSucceed((data) => {
|
||||||
// readFile() should read from position five, instead of zero.
|
// readFile() should read from position five, instead of zero.
|
||||||
assert.deepStrictEqual(data.toString(), ' World');
|
assert.strictEqual(data.toString(), ' World');
|
||||||
|
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -35,11 +35,11 @@ const allocateEmptyBuffers = (combinedLength) => {
|
||||||
|
|
||||||
let { bytesRead, buffers } = await handle.readv([Buffer.from('')],
|
let { bytesRead, buffers } = await handle.readv([Buffer.from('')],
|
||||||
null);
|
null);
|
||||||
assert.deepStrictEqual(bytesRead, 0);
|
assert.strictEqual(bytesRead, 0);
|
||||||
assert.deepStrictEqual(buffers, [Buffer.from('')]);
|
assert.deepStrictEqual(buffers, [Buffer.from('')]);
|
||||||
|
|
||||||
({ bytesRead, buffers } = await handle.readv(bufferArr, null));
|
({ bytesRead, buffers } = await handle.readv(bufferArr, null));
|
||||||
assert.deepStrictEqual(bytesRead, expectedLength);
|
assert.strictEqual(bytesRead, expectedLength);
|
||||||
assert.deepStrictEqual(buffers, bufferArr);
|
assert.deepStrictEqual(buffers, bufferArr);
|
||||||
assert(Buffer.concat(bufferArr).equals(await fs.readFile(filename)));
|
assert(Buffer.concat(bufferArr).equals(await fs.readFile(filename)));
|
||||||
handle.close();
|
handle.close();
|
||||||
|
@ -54,11 +54,11 @@ const allocateEmptyBuffers = (combinedLength) => {
|
||||||
const expectedLength = exptectedBuff.length;
|
const expectedLength = exptectedBuff.length;
|
||||||
|
|
||||||
let { bytesRead, buffers } = await handle.readv([Buffer.from('')]);
|
let { bytesRead, buffers } = await handle.readv([Buffer.from('')]);
|
||||||
assert.deepStrictEqual(bytesRead, 0);
|
assert.strictEqual(bytesRead, 0);
|
||||||
assert.deepStrictEqual(buffers, [Buffer.from('')]);
|
assert.deepStrictEqual(buffers, [Buffer.from('')]);
|
||||||
|
|
||||||
({ bytesRead, buffers } = await handle.readv(bufferArr));
|
({ bytesRead, buffers } = await handle.readv(bufferArr));
|
||||||
assert.deepStrictEqual(bytesRead, expectedLength);
|
assert.strictEqual(bytesRead, expectedLength);
|
||||||
assert.deepStrictEqual(buffers, bufferArr);
|
assert.deepStrictEqual(buffers, bufferArr);
|
||||||
assert(Buffer.concat(bufferArr).equals(await fs.readFile(filename)));
|
assert(Buffer.concat(bufferArr).equals(await fs.readFile(filename)));
|
||||||
handle.close();
|
handle.close();
|
||||||
|
|
|
@ -32,10 +32,10 @@ const allocateEmptyBuffers = (combinedLength) => {
|
||||||
const bufferArr = allocateEmptyBuffers(exptectedBuff.length);
|
const bufferArr = allocateEmptyBuffers(exptectedBuff.length);
|
||||||
|
|
||||||
let read = fs.readvSync(fd, [Buffer.from('')], 0);
|
let read = fs.readvSync(fd, [Buffer.from('')], 0);
|
||||||
assert.deepStrictEqual(read, 0);
|
assert.strictEqual(read, 0);
|
||||||
|
|
||||||
read = fs.readvSync(fd, bufferArr, 0);
|
read = fs.readvSync(fd, bufferArr, 0);
|
||||||
assert.deepStrictEqual(read, expectedLength);
|
assert.strictEqual(read, expectedLength);
|
||||||
|
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ const allocateEmptyBuffers = (combinedLength) => {
|
||||||
const bufferArr = allocateEmptyBuffers(exptectedBuff.length);
|
const bufferArr = allocateEmptyBuffers(exptectedBuff.length);
|
||||||
|
|
||||||
let read = fs.readvSync(fd, [Buffer.from('')]);
|
let read = fs.readvSync(fd, [Buffer.from('')]);
|
||||||
assert.deepStrictEqual(read, 0);
|
assert.strictEqual(read, 0);
|
||||||
|
|
||||||
read = fs.readvSync(fd, bufferArr);
|
read = fs.readvSync(fd, bufferArr);
|
||||||
assert.deepStrictEqual(read, expectedLength);
|
assert.strictEqual(read, expectedLength);
|
||||||
|
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,14 @@ tmpdir.refresh();
|
||||||
const fd = fs.openSync(filename, 'w');
|
const fd = fs.openSync(filename, 'w');
|
||||||
try {
|
try {
|
||||||
/* Write only five characters, so that the position moves to five. */
|
/* Write only five characters, so that the position moves to five. */
|
||||||
assert.deepStrictEqual(fs.writeSync(fd, 'Hello'), 5);
|
assert.strictEqual(fs.writeSync(fd, 'Hello'), 5);
|
||||||
assert.deepStrictEqual(fs.readFileSync(filename).toString(), 'Hello');
|
assert.strictEqual(fs.readFileSync(filename).toString(), 'Hello');
|
||||||
|
|
||||||
/* Write some more with writeFileSync(). */
|
/* Write some more with writeFileSync(). */
|
||||||
fs.writeFileSync(fd, 'World');
|
fs.writeFileSync(fd, 'World');
|
||||||
|
|
||||||
/* New content should be written at position five, instead of zero. */
|
/* New content should be written at position five, instead of zero. */
|
||||||
assert.deepStrictEqual(fs.readFileSync(filename).toString(), 'HelloWorld');
|
assert.strictEqual(fs.readFileSync(filename).toString(), 'HelloWorld');
|
||||||
} finally {
|
} finally {
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,12 @@ process.on('beforeExit', common.mustCall(() => {
|
||||||
/* Write only five characters, so that the position moves to five. */
|
/* Write only five characters, so that the position moves to five. */
|
||||||
fs.write(fd, 'Hello', common.mustSucceed((bytes) => {
|
fs.write(fd, 'Hello', common.mustSucceed((bytes) => {
|
||||||
assert.strictEqual(bytes, 5);
|
assert.strictEqual(bytes, 5);
|
||||||
assert.deepStrictEqual(fs.readFileSync(file).toString(), 'Hello');
|
assert.strictEqual(fs.readFileSync(file).toString(), 'Hello');
|
||||||
|
|
||||||
/* Write some more with writeFile(). */
|
/* Write some more with writeFile(). */
|
||||||
fs.writeFile(fd, 'World', common.mustSucceed(() => {
|
fs.writeFile(fd, 'World', common.mustSucceed(() => {
|
||||||
/* New content should be written at position five, instead of zero. */
|
/* New content should be written at position five, instead of zero. */
|
||||||
assert.deepStrictEqual(fs.readFileSync(file).toString(), 'HelloWorld');
|
assert.strictEqual(fs.readFileSync(file).toString(), 'HelloWorld');
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -22,7 +22,7 @@ tmpdir.refresh();
|
||||||
const expectedLength = bufferArr.length * buffer.byteLength;
|
const expectedLength = bufferArr.length * buffer.byteLength;
|
||||||
let { bytesWritten, buffers } = await handle.writev([Buffer.from('')],
|
let { bytesWritten, buffers } = await handle.writev([Buffer.from('')],
|
||||||
null);
|
null);
|
||||||
assert.deepStrictEqual(bytesWritten, 0);
|
assert.strictEqual(bytesWritten, 0);
|
||||||
assert.deepStrictEqual(buffers, [Buffer.from('')]);
|
assert.deepStrictEqual(buffers, [Buffer.from('')]);
|
||||||
({ bytesWritten, buffers } = await handle.writev(bufferArr, null));
|
({ bytesWritten, buffers } = await handle.writev(bufferArr, null));
|
||||||
assert.deepStrictEqual(bytesWritten, expectedLength);
|
assert.deepStrictEqual(bytesWritten, expectedLength);
|
||||||
|
@ -39,7 +39,7 @@ tmpdir.refresh();
|
||||||
const bufferArr = [buffer, buffer, buffer];
|
const bufferArr = [buffer, buffer, buffer];
|
||||||
const expectedLength = bufferArr.length * buffer.byteLength;
|
const expectedLength = bufferArr.length * buffer.byteLength;
|
||||||
let { bytesWritten, buffers } = await handle.writev([Buffer.from('')]);
|
let { bytesWritten, buffers } = await handle.writev([Buffer.from('')]);
|
||||||
assert.deepStrictEqual(bytesWritten, 0);
|
assert.strictEqual(bytesWritten, 0);
|
||||||
assert.deepStrictEqual(buffers, [Buffer.from('')]);
|
assert.deepStrictEqual(buffers, [Buffer.from('')]);
|
||||||
({ bytesWritten, buffers } = await handle.writev(bufferArr));
|
({ bytesWritten, buffers } = await handle.writev(bufferArr));
|
||||||
assert.deepStrictEqual(bytesWritten, expectedLength);
|
assert.deepStrictEqual(bytesWritten, expectedLength);
|
||||||
|
|
|
@ -26,10 +26,10 @@ const getFileName = (i) => path.join(tmpdir.path, `writev_sync_${i}.txt`);
|
||||||
const expectedLength = bufferArr.length * buffer.byteLength;
|
const expectedLength = bufferArr.length * buffer.byteLength;
|
||||||
|
|
||||||
let written = fs.writevSync(fd, [Buffer.from('')], null);
|
let written = fs.writevSync(fd, [Buffer.from('')], null);
|
||||||
assert.deepStrictEqual(written, 0);
|
assert.strictEqual(written, 0);
|
||||||
|
|
||||||
written = fs.writevSync(fd, bufferArr, null);
|
written = fs.writevSync(fd, bufferArr, null);
|
||||||
assert.deepStrictEqual(written, expectedLength);
|
assert.strictEqual(written, expectedLength);
|
||||||
|
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ const getFileName = (i) => path.join(tmpdir.path, `writev_sync_${i}.txt`);
|
||||||
const expectedLength = bufferArr.length * buffer.byteLength;
|
const expectedLength = bufferArr.length * buffer.byteLength;
|
||||||
|
|
||||||
let written = fs.writevSync(fd, [Buffer.from('')]);
|
let written = fs.writevSync(fd, [Buffer.from('')]);
|
||||||
assert.deepStrictEqual(written, 0);
|
assert.strictEqual(written, 0);
|
||||||
|
|
||||||
written = fs.writevSync(fd, bufferArr);
|
written = fs.writevSync(fd, bufferArr);
|
||||||
assert.deepStrictEqual(written, expectedLength);
|
assert.strictEqual(written, expectedLength);
|
||||||
|
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,8 @@ function second() {
|
||||||
function remoteClose() {
|
function remoteClose() {
|
||||||
// Mock remote server close the socket
|
// Mock remote server close the socket
|
||||||
const req = get('/remote_close', common.mustCall((res) => {
|
const req = get('/remote_close', common.mustCall((res) => {
|
||||||
assert.deepStrictEqual(req.reusedSocket, true);
|
assert.strictEqual(req.reusedSocket, true);
|
||||||
assert.deepStrictEqual(res.statusCode, 200);
|
assert.strictEqual(res.statusCode, 200);
|
||||||
res.on('data', checkDataAndSockets);
|
res.on('data', checkDataAndSockets);
|
||||||
res.on('end', common.mustCall(() => {
|
res.on('end', common.mustCall(() => {
|
||||||
assert.strictEqual(agent.sockets[name].length, 1);
|
assert.strictEqual(agent.sockets[name].length, 1);
|
||||||
|
|
|
@ -48,8 +48,8 @@ const s = http.createServer(common.mustCall((req, res) => {
|
||||||
assert.deepStrictEqual(headers, exoticObj);
|
assert.deepStrictEqual(headers, exoticObj);
|
||||||
assert.deepStrictEqual(res.getHeaderNames(), []);
|
assert.deepStrictEqual(res.getHeaderNames(), []);
|
||||||
assert.deepStrictEqual(res.getRawHeaderNames(), []);
|
assert.deepStrictEqual(res.getRawHeaderNames(), []);
|
||||||
assert.deepStrictEqual(res.hasHeader('Connection'), false);
|
assert.strictEqual(res.hasHeader('Connection'), false);
|
||||||
assert.deepStrictEqual(res.getHeader('Connection'), undefined);
|
assert.strictEqual(res.getHeader('Connection'), undefined);
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => res.setHeader(),
|
() => res.setHeader(),
|
||||||
|
|
|
@ -43,7 +43,7 @@ const server = http.Server(common.mustCall((req, res) => {
|
||||||
break;
|
break;
|
||||||
case '/world':
|
case '/world':
|
||||||
assert.strictEqual(req.method, 'POST');
|
assert.strictEqual(req.method, 'POST');
|
||||||
assert.deepStrictEqual(req.headers.cookie, 'abc=123; def=456; ghi=789');
|
assert.strictEqual(req.headers.cookie, 'abc=123; def=456; ghi=789');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false, `Unexpected request for ${req.url}`);
|
assert(false, `Unexpected request for ${req.url}`);
|
||||||
|
|
|
@ -22,8 +22,8 @@ server.on('close', common.mustCall());
|
||||||
server.listen(0, () => {
|
server.listen(0, () => {
|
||||||
const client = http2.connect(`http://localhost:${server.address().port}`);
|
const client = http2.connect(`http://localhost:${server.address().port}`);
|
||||||
client.once('goaway', common.mustCall((code, lastStreamID, buf) => {
|
client.once('goaway', common.mustCall((code, lastStreamID, buf) => {
|
||||||
assert.deepStrictEqual(code, 0);
|
assert.strictEqual(code, 0);
|
||||||
assert.deepStrictEqual(lastStreamID, 1);
|
assert.strictEqual(lastStreamID, 1);
|
||||||
assert.deepStrictEqual(data, buf);
|
assert.deepStrictEqual(data, buf);
|
||||||
session.close();
|
session.close();
|
||||||
server.close();
|
server.close();
|
||||||
|
|
|
@ -29,16 +29,13 @@ src.__PROTO__ = 'bar';
|
||||||
src.__Proto__ = 'baz';
|
src.__Proto__ = 'baz';
|
||||||
|
|
||||||
function checkHeaders(headers) {
|
function checkHeaders(headers) {
|
||||||
assert.deepStrictEqual(headers.accept,
|
assert.strictEqual(headers.accept, 'abc, def, ghijklmnop');
|
||||||
'abc, def, ghijklmnop');
|
assert.strictEqual(headers['www-authenticate'], 'foo, bar, baz');
|
||||||
assert.deepStrictEqual(headers['www-authenticate'],
|
assert.strictEqual(headers['proxy-authenticate'], 'foo, bar, baz');
|
||||||
'foo, bar, baz');
|
assert.strictEqual(headers['x-foo'], 'foo, bar, baz');
|
||||||
assert.deepStrictEqual(headers['proxy-authenticate'],
|
assert.strictEqual(headers.constructor, 'foo, bar, baz');
|
||||||
'foo, bar, baz');
|
|
||||||
assert.deepStrictEqual(headers['x-foo'], 'foo, bar, baz');
|
|
||||||
assert.deepStrictEqual(headers.constructor, 'foo, bar, baz');
|
|
||||||
// eslint-disable-next-line no-proto
|
// eslint-disable-next-line no-proto
|
||||||
assert.deepStrictEqual(headers.__proto__, 'foo, bar, baz');
|
assert.strictEqual(headers.__proto__, 'foo, bar, baz');
|
||||||
}
|
}
|
||||||
|
|
||||||
server.on('stream', common.mustCall((stream, headers) => {
|
server.on('stream', common.mustCall((stream, headers) => {
|
||||||
|
|
|
@ -13,7 +13,7 @@ server.listen(0, common.mustCall(() => {
|
||||||
const session = http2.connect(`http://localhost:${server.address().port}`);
|
const session = http2.connect(`http://localhost:${server.address().port}`);
|
||||||
const req = session.request();
|
const req = session.request();
|
||||||
req.on('response', (headers, flags) => {
|
req.on('response', (headers, flags) => {
|
||||||
assert.deepStrictEqual(headers.date, 'snacks o clock');
|
assert.strictEqual(headers.date, 'snacks o clock');
|
||||||
});
|
});
|
||||||
req.on('end', () => {
|
req.on('end', () => {
|
||||||
session.close();
|
session.close();
|
||||||
|
|
|
@ -92,7 +92,7 @@ function testSampleDebugSession() {
|
||||||
});
|
});
|
||||||
|
|
||||||
debuggedFunction();
|
debuggedFunction();
|
||||||
assert.deepStrictEqual(cbAsSecondArgCalled, true);
|
assert.strictEqual(cbAsSecondArgCalled, true);
|
||||||
assert.deepStrictEqual(failures, []);
|
assert.deepStrictEqual(failures, []);
|
||||||
assert.strictEqual(cur, 5);
|
assert.strictEqual(cur, 5);
|
||||||
scopeCallback = null;
|
scopeCallback = null;
|
||||||
|
|
|
@ -42,7 +42,7 @@ assert.throws(() => mark(Symbol('a')), {
|
||||||
const m = mark('a', { detail });
|
const m = mark('a', { detail });
|
||||||
assert.strictEqual(m.name, 'a');
|
assert.strictEqual(m.name, 'a');
|
||||||
assert.strictEqual(m.entryType, 'mark');
|
assert.strictEqual(m.entryType, 'mark');
|
||||||
assert.deepStrictEqual(m.detail, null);
|
assert.strictEqual(m.detail, null);
|
||||||
});
|
});
|
||||||
[1, 'any', {}, []].forEach((detail) => {
|
[1, 'any', {}, []].forEach((detail) => {
|
||||||
const m = mark('a', { detail });
|
const m = mark('a', { detail });
|
||||||
|
|
|
@ -4,13 +4,13 @@ const assert = require('assert');
|
||||||
|
|
||||||
const qs = require('querystring');
|
const qs = require('querystring');
|
||||||
|
|
||||||
assert.deepStrictEqual(qs.escape(5), '5');
|
assert.strictEqual(qs.escape(5), '5');
|
||||||
assert.deepStrictEqual(qs.escape('test'), 'test');
|
assert.strictEqual(qs.escape('test'), 'test');
|
||||||
assert.deepStrictEqual(qs.escape({}), '%5Bobject%20Object%5D');
|
assert.strictEqual(qs.escape({}), '%5Bobject%20Object%5D');
|
||||||
assert.deepStrictEqual(qs.escape([5, 10]), '5%2C10');
|
assert.strictEqual(qs.escape([5, 10]), '5%2C10');
|
||||||
assert.deepStrictEqual(qs.escape('Ŋōđĕ'), '%C5%8A%C5%8D%C4%91%C4%95');
|
assert.strictEqual(qs.escape('Ŋōđĕ'), '%C5%8A%C5%8D%C4%91%C4%95');
|
||||||
assert.deepStrictEqual(qs.escape('testŊōđĕ'), 'test%C5%8A%C5%8D%C4%91%C4%95');
|
assert.strictEqual(qs.escape('testŊōđĕ'), 'test%C5%8A%C5%8D%C4%91%C4%95');
|
||||||
assert.deepStrictEqual(qs.escape(`${String.fromCharCode(0xD800 + 1)}test`),
|
assert.strictEqual(qs.escape(`${String.fromCharCode(0xD800 + 1)}test`),
|
||||||
'%F0%90%91%B4est');
|
'%F0%90%91%B4est');
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
|
|
@ -43,7 +43,7 @@ class TestWritable extends Writable {
|
||||||
|
|
||||||
writable.data = '';
|
writable.data = '';
|
||||||
await readline.clearScreenDown().rollback();
|
await readline.clearScreenDown().rollback();
|
||||||
assert.deepStrictEqual(writable.data, '');
|
assert.strictEqual(writable.data, '');
|
||||||
|
|
||||||
writable.data = '';
|
writable.data = '';
|
||||||
await readline.clearLine(-1).commit();
|
await readline.clearLine(-1).commit();
|
||||||
|
|
|
@ -66,7 +66,7 @@ const kArrayBuffer =
|
||||||
|
|
||||||
text(passthrough).then(common.mustCall(async (str) => {
|
text(passthrough).then(common.mustCall(async (str) => {
|
||||||
assert.strictEqual(str.length, 10);
|
assert.strictEqual(str.length, 10);
|
||||||
assert.deepStrictEqual(str, 'hellothere');
|
assert.strictEqual(str, 'hellothere');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
passthrough.write('hello');
|
passthrough.write('hello');
|
||||||
|
@ -78,7 +78,7 @@ const kArrayBuffer =
|
||||||
|
|
||||||
json(passthrough).then(common.mustCall(async (str) => {
|
json(passthrough).then(common.mustCall(async (str) => {
|
||||||
assert.strictEqual(str.length, 10);
|
assert.strictEqual(str.length, 10);
|
||||||
assert.deepStrictEqual(str, 'hellothere');
|
assert.strictEqual(str, 'hellothere');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
passthrough.write('"hello');
|
passthrough.write('"hello');
|
||||||
|
@ -126,7 +126,7 @@ const kArrayBuffer =
|
||||||
|
|
||||||
text(readable).then(common.mustCall(async (str) => {
|
text(readable).then(common.mustCall(async (str) => {
|
||||||
assert.strictEqual(str.length, 10);
|
assert.strictEqual(str.length, 10);
|
||||||
assert.deepStrictEqual(str, 'hellothere');
|
assert.strictEqual(str, 'hellothere');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const writer = writable.getWriter();
|
const writer = writable.getWriter();
|
||||||
|
@ -144,7 +144,7 @@ const kArrayBuffer =
|
||||||
|
|
||||||
json(readable).then(common.mustCall(async (str) => {
|
json(readable).then(common.mustCall(async (str) => {
|
||||||
assert.strictEqual(str.length, 10);
|
assert.strictEqual(str.length, 10);
|
||||||
assert.deepStrictEqual(str, 'hellothere');
|
assert.strictEqual(str, 'hellothere');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const writer = writable.getWriter();
|
const writer = writable.getWriter();
|
||||||
|
|
|
@ -47,6 +47,6 @@ s.read(0);
|
||||||
// ACTUALLY [1, 3, 5, 6, 4, 2]
|
// ACTUALLY [1, 3, 5, 6, 4, 2]
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
assert.deepStrictEqual(s.readableBuffer.join(','), '1,2,3,4,5,6');
|
assert.strictEqual(s.readableBuffer.join(','), '1,2,3,4,5,6');
|
||||||
console.log('ok');
|
console.log('ok');
|
||||||
});
|
});
|
||||||
|
|
|
@ -60,7 +60,7 @@ function fromArray(list) {
|
||||||
|
|
||||||
assert.deepStrictEqual(v1, { one: '1' });
|
assert.deepStrictEqual(v1, { one: '1' });
|
||||||
assert.deepStrictEqual(v2, { two: '2' });
|
assert.deepStrictEqual(v2, { two: '2' });
|
||||||
assert.deepStrictEqual(v3, null);
|
assert.strictEqual(v3, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,7 +128,7 @@ connect({
|
||||||
assert.strictEqual(peerCert.nistCurve, 'P-256');
|
assert.strictEqual(peerCert.nistCurve, 'P-256');
|
||||||
assert.strictEqual(peerCert.bits, 256);
|
assert.strictEqual(peerCert.bits, 256);
|
||||||
|
|
||||||
assert.deepStrictEqual(peerCert.infoAccess, undefined);
|
assert.strictEqual(peerCert.infoAccess, undefined);
|
||||||
|
|
||||||
const issuer = peerCert.issuerCertificate;
|
const issuer = peerCert.issuerCertificate;
|
||||||
assert.strictEqual(issuer.issuerCertificate, issuer);
|
assert.strictEqual(issuer.issuerCertificate, issuer);
|
||||||
|
|
|
@ -83,7 +83,7 @@ const stat = promisify(fs.stat);
|
||||||
callback(null, 'foo', 'bar');
|
callback(null, 'foo', 'bar');
|
||||||
}
|
}
|
||||||
promisify(fn)().then(common.mustCall((value) => {
|
promisify(fn)().then(common.mustCall((value) => {
|
||||||
assert.deepStrictEqual(value, 'foo');
|
assert.strictEqual(value, 'foo');
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ class MySource {
|
||||||
});
|
});
|
||||||
|
|
||||||
readable.on('data', common.mustCall((chunk) => {
|
readable.on('data', common.mustCall((chunk) => {
|
||||||
assert.deepStrictEqual(chunk, 'hello');
|
assert.strictEqual(chunk, 'hello');
|
||||||
}));
|
}));
|
||||||
readable.on('end', common.mustCall());
|
readable.on('end', common.mustCall());
|
||||||
readable.on('close', common.mustCall());
|
readable.on('close', common.mustCall());
|
||||||
|
|
|
@ -170,7 +170,7 @@ class TestSource {
|
||||||
writable.on('finish', common.mustCall());
|
writable.on('finish', common.mustCall());
|
||||||
writable.on('close', common.mustCall(() => {
|
writable.on('close', common.mustCall(() => {
|
||||||
assert.strictEqual(source.chunks.length, 1);
|
assert.strictEqual(source.chunks.length, 1);
|
||||||
assert.deepStrictEqual(source.chunks[0], 'hello');
|
assert.strictEqual(source.chunks[0], 'hello');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
writable.write('hello', common.mustCall());
|
writable.write('hello', common.mustCall());
|
||||||
|
|
|
@ -10,13 +10,13 @@ const message2 = { foo: 'bar' };
|
||||||
|
|
||||||
// Make sure receiveMessageOnPort() works in a FIFO way, the same way it does
|
// Make sure receiveMessageOnPort() works in a FIFO way, the same way it does
|
||||||
// when we’re using events.
|
// when we’re using events.
|
||||||
assert.deepStrictEqual(receiveMessageOnPort(port2), undefined);
|
assert.strictEqual(receiveMessageOnPort(port2), undefined);
|
||||||
port1.postMessage(message1);
|
port1.postMessage(message1);
|
||||||
port1.postMessage(message2);
|
port1.postMessage(message2);
|
||||||
assert.deepStrictEqual(receiveMessageOnPort(port2), { message: message1 });
|
assert.deepStrictEqual(receiveMessageOnPort(port2), { message: message1 });
|
||||||
assert.deepStrictEqual(receiveMessageOnPort(port2), { message: message2 });
|
assert.deepStrictEqual(receiveMessageOnPort(port2), { message: message2 });
|
||||||
assert.deepStrictEqual(receiveMessageOnPort(port2), undefined);
|
assert.strictEqual(receiveMessageOnPort(port2), undefined);
|
||||||
assert.deepStrictEqual(receiveMessageOnPort(port2), undefined);
|
assert.strictEqual(receiveMessageOnPort(port2), undefined);
|
||||||
|
|
||||||
// Make sure message handlers aren’t called.
|
// Make sure message handlers aren’t called.
|
||||||
port2.on('message', common.mustNotCall());
|
port2.on('message', common.mustNotCall());
|
||||||
|
|
|
@ -28,7 +28,7 @@ const meowScript = () => 'meow';
|
||||||
|
|
||||||
{
|
{
|
||||||
const uint8Array = new Uint8Array([ 1, 2, 3, 4 ]);
|
const uint8Array = new Uint8Array([ 1, 2, 3, 4 ]);
|
||||||
assert.deepStrictEqual(uint8Array.length, 4);
|
assert.strictEqual(uint8Array.length, 4);
|
||||||
new Worker(`
|
new Worker(`
|
||||||
const { parentPort, workerData } = require('worker_threads');
|
const { parentPort, workerData } = require('worker_threads');
|
||||||
parentPort.postMessage(workerData);
|
parentPort.postMessage(workerData);
|
||||||
|
@ -41,7 +41,7 @@ const meowScript = () => 'meow';
|
||||||
(message) =>
|
(message) =>
|
||||||
assert.deepStrictEqual(message, Uint8Array.of(1, 2, 3, 4))
|
assert.deepStrictEqual(message, Uint8Array.of(1, 2, 3, 4))
|
||||||
);
|
);
|
||||||
assert.deepStrictEqual(uint8Array.length, 0);
|
assert.strictEqual(uint8Array.length, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@ for (const fn of [
|
||||||
})
|
})
|
||||||
.on('data', (chunk) => output.push(chunk))
|
.on('data', (chunk) => output.push(chunk))
|
||||||
.on('end', common.mustCall(
|
.on('end', common.mustCall(
|
||||||
() => assert.deepStrictEqual(Buffer.concat(output).toString(), 'abc')));
|
() => assert.strictEqual(Buffer.concat(output).toString(), 'abc')));
|
||||||
|
|
||||||
fn(deflate, () => {
|
fn(deflate, () => {
|
||||||
fn(inflate, () => {
|
fn(inflate, () => {
|
||||||
|
|
|
@ -16,10 +16,10 @@ const unzip = zlib.createUnzip()
|
||||||
})
|
})
|
||||||
.on('data', (data) => resultBuffers.push(data))
|
.on('data', (data) => resultBuffers.push(data))
|
||||||
.on('finish', common.mustCall(() => {
|
.on('finish', common.mustCall(() => {
|
||||||
assert.deepStrictEqual(Buffer.concat(resultBuffers).toString(), 'abcdef',
|
const unzipped = Buffer.concat(resultBuffers).toString();
|
||||||
`'${Buffer.concat(resultBuffers).toString()}' ` +
|
assert.strictEqual(unzipped, 'abcdef',
|
||||||
'should match \'abcdef\' after ' +
|
`'${unzipped}' should match 'abcdef' after zipping ` +
|
||||||
'zipping and unzipping');
|
'and unzipping');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
|
|
@ -7,12 +7,12 @@ process.stderr.columns = 20;
|
||||||
|
|
||||||
// Confirm that there is no position indicator.
|
// Confirm that there is no position indicator.
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => { assert.deepStrictEqual('a'.repeat(30), 'a'.repeat(31)); },
|
() => { assert.strictEqual('a'.repeat(30), 'a'.repeat(31)); },
|
||||||
(err) => !err.message.includes('^')
|
(err) => !err.message.includes('^')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Confirm that there is a position indicator.
|
// Confirm that there is a position indicator.
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => { assert.deepStrictEqual('aaaa', 'aaaaa'); },
|
() => { assert.strictEqual('aaaa', 'aaaaa'); },
|
||||||
(err) => err.message.includes('^')
|
(err) => err.message.includes('^')
|
||||||
);
|
);
|
||||||
|
|
|
@ -161,9 +161,9 @@ if (process.argv[2] === 'child') {
|
||||||
child.stdout.on('data', (chunk) => { stdout += chunk; });
|
child.stdout.on('data', (chunk) => { stdout += chunk; });
|
||||||
child.on('exit', common.mustCall((code, signal) => {
|
child.on('exit', common.mustCall((code, signal) => {
|
||||||
assert.strictEqual(stderr.trim(), '');
|
assert.strictEqual(stderr.trim(), '');
|
||||||
assert.deepStrictEqual(code, 0, 'Process exited unexpectedly with code: ' +
|
assert.strictEqual(code, 0, 'Process exited unexpectedly with code: ' +
|
||||||
`${code}`);
|
`${code}`);
|
||||||
assert.deepStrictEqual(signal, null, 'Process should have exited cleanly,' +
|
assert.strictEqual(signal, null, 'Process should have exited cleanly,' +
|
||||||
` but did not: ${signal}`);
|
` but did not: ${signal}`);
|
||||||
|
|
||||||
const reports = helper.findReports(child.pid, tmpdir.path);
|
const reports = helper.findReports(child.pid, tmpdir.path);
|
||||||
|
|
|
@ -44,7 +44,7 @@ function verifyFrames(output, file, func) {
|
||||||
console.log(output.stderr.toString());
|
console.log(output.stderr.toString());
|
||||||
console.log(roots);
|
console.log(roots);
|
||||||
}
|
}
|
||||||
assert.notDeepStrictEqual(frame, undefined);
|
assert.notStrictEqual(frame, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
const kHeapProfInterval = 128;
|
const kHeapProfInterval = 128;
|
||||||
|
|
|
@ -51,7 +51,7 @@ function verifyFrames(output, file, func) {
|
||||||
console.log(output.stderr.toString());
|
console.log(output.stderr.toString());
|
||||||
console.log(roots);
|
console.log(roots);
|
||||||
}
|
}
|
||||||
assert.notDeepStrictEqual(frame, undefined);
|
assert.notStrictEqual(frame, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to set --heap-prof-interval to a small enough value to make
|
// We need to set --heap-prof-interval to a small enough value to make
|
||||||
|
|
Loading…
Reference in New Issue