From: Dmitry Volyntsev Date: Wed, 26 Feb 2025 07:05:31 +0000 (-0800) Subject: Test262: improved compatibility with node.js for fs/methods.t.mjs. X-Git-Tag: 0.8.10~9 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=4ee93af07245da8750feeaf6a1a1b965f40c63c4;p=njs.git Test262: improved compatibility with node.js for fs/methods.t.mjs. --- diff --git a/test/fs/methods.t.mjs b/test/fs/methods.t.mjs index 705c1b5a..72e42cb9 100644 --- a/test/fs/methods.t.mjs +++ b/test/fs/methods.t.mjs @@ -21,6 +21,10 @@ function p(args, default_opts) { return params; } +function has_quickjs() { + return (typeof njs != 'undefined' && njs.engine == 'QuickJS'); +} + function promisify(f) { return function (...args) { return new Promise((resolve, reject) => { @@ -116,7 +120,7 @@ let readfile_tests = () => [ return true; } }, - { args: ["test/fs/non_utf8", "utf8"], expected: "��", skip() { return njs && njs.engine == 'QuickJS'; } }, + { args: ["test/fs/non_utf8", "utf8"], expected: "��", skip: () => has_quickjs() }, { args: ["test/fs/non_utf8", {encoding: "hex"}], expected: "8080" }, { args: ["test/fs/non_utf8", "base64"], expected: "gIA=" }, { args: ["test/fs/ascii", "utf8"], expected: "x".repeat(600) }, @@ -219,7 +223,7 @@ let writefile_tests = () => [ { args: ["@", Buffer.from("XYZ"), {encoding: "utf8", mode: 0o666}], expected: Buffer.from("XYZ") }, { args: ["@", new DataView(Buffer.alloc(3).fill(66).buffer)], - expected: Buffer.from("BBB"), skip() { return njs && njs.engine == 'QuickJS'; } }, + expected: Buffer.from("BBB"), skip: () => has_quickjs() }, { args: ["@", new Uint8Array(Buffer.from("ABCD"))], expected: Buffer.from("ABCD")}, { args: ["@", "XYZ"], expected: Buffer.from("XYZ")}, @@ -309,7 +313,7 @@ let append_tests = () => [ { args: ["@", Buffer.from("XYZ"), {encoding: "utf8", mode: 0o666}], expected: Buffer.from("XYZXYZ") }, { args: ["@", new DataView(Buffer.alloc(3).fill(66).buffer)], - expected: Buffer.from("BBBBBB"), skip() { return njs && njs.engine == 'QuickJS'; } }, + expected: Buffer.from("BBBBBB"), skip: () => has_quickjs() }, { args: ["@", new Uint8Array(Buffer.from("ABCD"))], expected: Buffer.from("ABCDABCD")}, { args: ["@", "XYZ"], expected: Buffer.from("XYZXYZ")},