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 <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
This commit is contained in:
parent
cf7b5a8dc2
commit
a9e6e68c0b
@ -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);
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user