Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap actual and expected in assertions #23474

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions test/parallel/test-fs-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,59 +41,59 @@ 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 */

fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
fs.open(fn, 'w', 0o644, common.mustCall((err, fd) => {
assert.ifError(err);

const done = common.mustCall(function(err, written) {
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(fn, 'utf8');
fs.unlinkSync(fn);
assert.strictEqual(expected, found);
assert.strictEqual(found, expected);
});

const written = common.mustCall(function(err, written) {
const written = common.mustCall((err, written) => {
assert.ifError(err);
assert.strictEqual(0, written);
assert.strictEqual(written, 0);
fs.write(fd, expected, 0, 'utf8', done);
});

Expand All @@ -106,28 +106,28 @@ 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) {
const written = common.mustCall((err, written) => {
assert.ifError(err);
assert.strictEqual(0, written);
assert.strictEqual(written, 0);
fs.write(fd, expected, 0, 'utf8', done);
});

fs.write(fd, '', 0, 'utf8', written);
}));

fs.open(fn3, 'w', 0o644, common.mustCall(function(err, fd) {
fs.open(fn3, 'w', 0o644, common.mustCall((err, fd) => {
assert.ifError(err);

const done = common.mustCall(function(err, written) {
const done = common.mustCall((err, written) => {
assert.ifError(err);
assert.strictEqual(Buffer.byteLength(expected), written);
assert.strictEqual(written, Buffer.byteLength(expected));
fs.closeSync(fd);
});

Expand Down