summaryrefslogtreecommitdiff
path: root/tests/node_compat/test/parallel/test-path-extname.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/node_compat/test/parallel/test-path-extname.js')
-rw-r--r--tests/node_compat/test/parallel/test-path-extname.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/node_compat/test/parallel/test-path-extname.js b/tests/node_compat/test/parallel/test-path-extname.js
index f5894058b..8cba90b07 100644
--- a/tests/node_compat/test/parallel/test-path-extname.js
+++ b/tests/node_compat/test/parallel/test-path-extname.js
@@ -13,7 +13,7 @@ const path = require('path');
const failures = [];
const slashRE = /\//g;
-[
+const testPaths = [
[__filename, '.js'],
['', ''],
['/path/to/file', ''],
@@ -57,10 +57,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, '\\');
@@ -73,16 +76,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.