From 627f05b7730c2bee7106db939daa9c02fb063e4d Mon Sep 17 00:00:00 2001 From: Kyriakos Markakis <> Date: Sat, 11 Nov 2023 14:23:58 +0200 Subject: [PATCH 1/2] test: change forEach to for...of in path extname --- test/parallel/test-path-extname.js | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/test/parallel/test-path-extname.js b/test/parallel/test-path-extname.js index 47b327d370d78e..cbd828d66035b7 100644 --- a/test/parallel/test-path-extname.js +++ b/test/parallel/test-path-extname.js @@ -6,7 +6,7 @@ const path = require('path'); const failures = []; const slashRE = /\//g; -[ +const testPaths = [ [__filename, '.js'], ['', ''], ['/path/to/file', ''], @@ -50,10 +50,13 @@ const slashRE = /\//g; ['file//', ''], ['file./', '.'], ['file.//', '.'], -].forEach((test) => { - const expected = test[1]; - [path.posix.extname, path.win32.extname].forEach((extname) => { - let input = test[0]; +]; + +for (const testPath of testPaths) { + const expected = testPath[1]; + const extNames = [path.posix.extname, path.win32.extname]; + for (const extname of extNames) { + let input = testPath[0]; let os; if (extname === path.win32.extname) { input = input.replace(slashRE, '\\'); @@ -66,16 +69,14 @@ const slashRE = /\//g; JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`; if (actual !== expected) failures.push(`\n${message}`); - }); - { - const input = `C:${test[0].replace(slashRE, '\\')}`; - const actual = path.win32.extname(input); - const message = `path.win32.extname(${JSON.stringify(input)})\n expect=${ - JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`; - if (actual !== expected) - failures.push(`\n${message}`); - } -}); + }; + const input = `C:${testPath[0].replace(slashRE, '\\')}`; + const actual = path.win32.extname(input); + const message = `path.win32.extname(${JSON.stringify(input)})\n expect=${ + JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`; + if (actual !== expected) + failures.push(`\n${message}`); +} assert.strictEqual(failures.length, 0, failures.join('')); // On Windows, backslash is a path separator. From 7ff2d60fbcc7598d2797fdebf0f22b8c16273428 Mon Sep 17 00:00:00 2001 From: Kyriakos Markakis <> Date: Sat, 11 Nov 2023 14:56:08 +0200 Subject: [PATCH 2/2] test: remove unnecessary semicolon --- test/parallel/test-path-extname.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-path-extname.js b/test/parallel/test-path-extname.js index cbd828d66035b7..be5a6316b0c7c3 100644 --- a/test/parallel/test-path-extname.js +++ b/test/parallel/test-path-extname.js @@ -69,7 +69,7 @@ for (const testPath of testPaths) { JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`; if (actual !== expected) failures.push(`\n${message}`); - }; + } const input = `C:${testPath[0].replace(slashRE, '\\')}`; const actual = path.win32.extname(input); const message = `path.win32.extname(${JSON.stringify(input)})\n expect=${