summaryrefslogtreecommitdiff
path: root/tests/node_compat/test/parallel/test-fs-write.js
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2024-06-11 12:41:44 +0100
committerGitHub <noreply@github.com>2024-06-11 11:41:44 +0000
commit6a356aff1380e79d67738c5b43aa2b5fee76600d (patch)
treebe4aadc62a523ff280820958a1a3829f1a18ca7d /tests/node_compat/test/parallel/test-fs-write.js
parent3d41b486da7dcba49c8a18b45425e356c329d986 (diff)
chore: sync up Node.js test files for v20.11.1 (#24066)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Diffstat (limited to 'tests/node_compat/test/parallel/test-fs-write.js')
-rw-r--r--tests/node_compat/test/parallel/test-fs-write.js40
1 files changed, 15 insertions, 25 deletions
diff --git a/tests/node_compat/test/parallel/test-fs-write.js b/tests/node_compat/test/parallel/test-fs-write.js
index 33fcb84cf..e10db287f 100644
--- a/tests/node_compat/test/parallel/test-fs-write.js
+++ b/tests/node_compat/test/parallel/test-fs-write.js
@@ -2,8 +2,8 @@
// deno-lint-ignore-file
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// Taken from Node 16.13.0
-// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
+// Taken from Node 18.12.1
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
// Copyright Joyent, Inc. and other Node contributors.
//
@@ -30,17 +30,15 @@
'use strict';
const common = require('../common');
const assert = require('assert');
-const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-const fn = path.join(tmpdir.path, 'write.txt');
-const fn2 = path.join(tmpdir.path, 'write2.txt');
-const fn3 = path.join(tmpdir.path, 'write3.txt');
-const fn4 = path.join(tmpdir.path, 'write4.txt');
-const fn5 = path.join(tmpdir.path, 'write5.txt');
+const fn = tmpdir.resolve('write.txt');
+const fn2 = tmpdir.resolve('write2.txt');
+const fn3 = tmpdir.resolve('write3.txt');
+const fn4 = tmpdir.resolve('write4.txt');
const expected = 'ümlaut.';
const constants = fs.constants;
@@ -106,9 +104,6 @@ fs.open(fn, 'w', 0o644, common.mustSucceed((fd) => {
fs.write(fd, '', 0, 'utf8', written);
}));
-// TODO(kt3k): Enable this test when fs.open supports number for `flags`
-// paramter.
-/*
const args = constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC;
fs.open(fn2, args, 0o644, common.mustSucceed((fd) => {
const done = common.mustSucceed((written) => {
@@ -126,7 +121,6 @@ fs.open(fn2, args, 0o644, common.mustSucceed((fd) => {
fs.write(fd, '', 0, 'utf8', written);
}));
-*/
fs.open(fn3, 'w', 0o644, common.mustSucceed((fd) => {
const done = common.mustSucceed((written) => {
@@ -137,17 +131,6 @@ fs.open(fn3, 'w', 0o644, common.mustSucceed((fd) => {
fs.write(fd, expected, done);
}));
-fs.open(fn4, 'w', 0o644, common.mustSucceed((fd) => {
- const done = common.mustSucceed((written) => {
- assert.strictEqual(written, Buffer.byteLength(expected));
- fs.closeSync(fd);
- });
-
- const data = {
- toString() { return expected; }
- };
- fs.write(fd, data, done);
-}));
[false, 'test', {}, [], null, undefined].forEach((i) => {
assert.throws(
@@ -166,7 +149,14 @@ fs.open(fn4, 'w', 0o644, common.mustSucceed((fd) => {
);
});
-[false, 5, {}, [], null, undefined].forEach((data) => {
+[
+ false, 5, {}, [], null, undefined, true, 5n, () => {}, Symbol(), new Map(),
+ new String('notPrimitive'),
+ { [Symbol.toPrimitive]: (hint) => 'amObject' },
+ { toString() { return 'amObject'; } },
+ Promise.resolve('amPromise'),
+ common.mustNotCall(),
+].forEach((data) => {
assert.throws(
() => fs.write(1, data, common.mustNotCall()),
{
@@ -185,7 +175,7 @@ fs.open(fn4, 'w', 0o644, common.mustSucceed((fd) => {
{
// Regression test for https://github.com/nodejs/node/issues/38168
- const fd = fs.openSync(fn5, 'w');
+ const fd = fs.openSync(fn4, 'w');
assert.throws(
() => fs.writeSync(fd, 'abc', 0, 'hex'),