From f91dd7bfb4dd48eed8c0bab794d7083da692a29b Mon Sep 17 00:00:00 2001 From: Yitong Date: Fri, 12 Oct 2018 10:03:05 -0700 Subject: [PATCH] test: swap actual and expected in assertions 'test/parallel/test-fs-write.js' contains assertions where the first argument provided is the expected value and the second value is the actual value. This is backward from the documentation for assertions like 'assert.strictEqual()' where the first value should be the actual value being tested and the second value is the expected value. PR-URL: https://github.com/nodejs/node/pull/23474 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Shelley Vohr --- test/parallel/test-fs-write.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js index a3c8814bc392ce..d6022e81067f14 100644 --- a/test/parallel/test-fs-write.js +++ b/test/parallel/test-fs-write.js @@ -41,41 +41,41 @@ common.allowGlobals(externalizeString, isOneByteString, x); { const expected = 'ümlaut eins'; // Must be a unique string. externalizeString(expected); - assert.strictEqual(true, isOneByteString(expected)); + assert.strictEqual(isOneByteString(expected), true); const fd = fs.openSync(fn, 'w'); fs.writeSync(fd, expected, 0, 'latin1'); fs.closeSync(fd); - assert.strictEqual(expected, fs.readFileSync(fn, 'latin1')); + assert.strictEqual(fs.readFileSync(fn, 'latin1'), expected); } { const expected = 'ümlaut zwei'; // Must be a unique string. externalizeString(expected); - assert.strictEqual(true, isOneByteString(expected)); + assert.strictEqual(isOneByteString(expected), true); const fd = fs.openSync(fn, 'w'); fs.writeSync(fd, expected, 0, 'utf8'); fs.closeSync(fd); - assert.strictEqual(expected, fs.readFileSync(fn, 'utf8')); + assert.strictEqual(fs.readFileSync(fn, 'utf8'), expected); } { const expected = '中文 1'; // Must be a unique string. externalizeString(expected); - assert.strictEqual(false, isOneByteString(expected)); + assert.strictEqual(isOneByteString(expected), false); const fd = fs.openSync(fn, 'w'); fs.writeSync(fd, expected, 0, 'ucs2'); fs.closeSync(fd); - assert.strictEqual(expected, fs.readFileSync(fn, 'ucs2')); + assert.strictEqual(fs.readFileSync(fn, 'ucs2'), expected); } { const expected = '中文 2'; // Must be a unique string. externalizeString(expected); - assert.strictEqual(false, isOneByteString(expected)); + assert.strictEqual(isOneByteString(expected), false); const fd = fs.openSync(fn, 'w'); fs.writeSync(fd, expected, 0, 'utf8'); fs.closeSync(fd); - assert.strictEqual(expected, fs.readFileSync(fn, 'utf8')); + assert.strictEqual(fs.readFileSync(fn, 'utf8'), expected); } /* eslint-enable no-undef */ @@ -84,16 +84,16 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) { const done = common.mustCall(function(err, written) { assert.ifError(err); - assert.strictEqual(Buffer.byteLength(expected), written); + assert.strictEqual(written, Buffer.byteLength(expected)); fs.closeSync(fd); const found = fs.readFileSync(fn, 'utf8'); fs.unlinkSync(fn); - assert.strictEqual(expected, found); + assert.strictEqual(found, expected); }); const written = common.mustCall(function(err, written) { assert.ifError(err); - assert.strictEqual(0, written); + assert.strictEqual(written, 0); fs.write(fd, expected, 0, 'utf8', done); }); @@ -106,16 +106,16 @@ fs.open(fn2, args, 0o644, common.mustCall((err, fd) => { const done = common.mustCall((err, written) => { assert.ifError(err); - assert.strictEqual(Buffer.byteLength(expected), written); + assert.strictEqual(written, Buffer.byteLength(expected)); fs.closeSync(fd); const found = fs.readFileSync(fn2, 'utf8'); fs.unlinkSync(fn2); - assert.strictEqual(expected, found); + assert.strictEqual(found, expected); }); const written = common.mustCall(function(err, written) { assert.ifError(err); - assert.strictEqual(0, written); + assert.strictEqual(written, 0); fs.write(fd, expected, 0, 'utf8', done); }); @@ -127,7 +127,7 @@ fs.open(fn3, 'w', 0o644, common.mustCall(function(err, fd) { const done = common.mustCall(function(err, written) { assert.ifError(err); - assert.strictEqual(Buffer.byteLength(expected), written); + assert.strictEqual(written, Buffer.byteLength(expected)); fs.closeSync(fd); });