From 80206a3858958e3f569eca6801c233af71e5d5b8 Mon Sep 17 00:00:00 2001 From: Gibby Free Date: Fri, 22 Sep 2023 15:03:14 -0700 Subject: [PATCH 1/2] test: use destructuring in test-path-parse-format --- test/parallel/test-path-parse-format.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-path-parse-format.js b/test/parallel/test-path-parse-format.js index 52acd836cce87b..fe2eb92ef67c19 100644 --- a/test/parallel/test-path-parse-format.js +++ b/test/parallel/test-path-parse-format.js @@ -148,13 +148,11 @@ const trailingTests = [ ], ]; const failures = []; -trailingTests.forEach((test) => { - const parse = test[0]; +trailingTests.forEach(([parse, testList]) => { const os = parse === path.win32.parse ? 'win32' : 'posix'; - test[1].forEach((test) => { - const actual = parse(test[0]); - const expected = test[1]; - const message = `path.${os}.parse(${JSON.stringify(test[0])})\n expect=${ + testList.forEach(([input, expected]) => { + const actual = parse(input); + const message = `path.${os}.parse(${JSON.stringify(input)})\n expect=${ JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`; const actualKeys = Object.keys(actual); const expectedKeys = Object.keys(expected); From eec759f9680fcf23f740b96cacb0ea4e9b21a279 Mon Sep 17 00:00:00 2001 From: Gibby Free Date: Fri, 22 Sep 2023 15:38:08 -0700 Subject: [PATCH 2/2] test: use for ... of instead of forEach --- test/parallel/test-path-parse-format.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-path-parse-format.js b/test/parallel/test-path-parse-format.js index fe2eb92ef67c19..e834031403034c 100644 --- a/test/parallel/test-path-parse-format.js +++ b/test/parallel/test-path-parse-format.js @@ -148,9 +148,9 @@ const trailingTests = [ ], ]; const failures = []; -trailingTests.forEach(([parse, testList]) => { +for (const [parse, testList] of trailingTests) { const os = parse === path.win32.parse ? 'win32' : 'posix'; - testList.forEach(([input, expected]) => { + for (const [input, expected] of testList) { const actual = parse(input); const message = `path.${os}.parse(${JSON.stringify(input)})\n expect=${ JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`; @@ -168,8 +168,8 @@ trailingTests.forEach(([parse, testList]) => { } if (failed) failures.push(`\n${message}`); - }); -}); + } +} assert.strictEqual(failures.length, 0, failures.join('')); function checkErrors(path) {