Skip to content

Commit 342a83e

Browse files
marquicodestargos
authored andcommitted
test: change forEach to for...of in path extname
PR-URL: #50667 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent c494838 commit 342a83e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

‎test/parallel/test-path-extname.js‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path');
66
constfailures=[];
77
constslashRE=/\//g;
88

9-
[
9+
consttestPaths=[
1010
[__filename,'.js'],
1111
['',''],
1212
['/path/to/file',''],
@@ -50,10 +50,13 @@ const slashRE = /\//g;
5050
['file//',''],
5151
['file./','.'],
5252
['file.//','.'],
53-
].forEach((test)=>{
54-
constexpected=test[1];
55-
[path.posix.extname,path.win32.extname].forEach((extname)=>{
56-
letinput=test[0];
53+
];
54+
55+
for(consttestPathoftestPaths){
56+
constexpected=testPath[1];
57+
constextNames=[path.posix.extname,path.win32.extname];
58+
for(constextnameofextNames){
59+
letinput=testPath[0];
5760
letos;
5861
if(extname===path.win32.extname){
5962
input=input.replace(slashRE,'\\');
@@ -66,16 +69,14 @@ const slashRE = /\//g;
6669
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
6770
if(actual!==expected)
6871
failures.push(`\n${message}`);
69-
});
70-
{
71-
constinput=`C:${test[0].replace(slashRE,'\\')}`;
72-
constactual=path.win32.extname(input);
73-
constmessage=`path.win32.extname(${JSON.stringify(input)})\n expect=${
74-
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
75-
if(actual!==expected)
76-
failures.push(`\n${message}`);
7772
}
78-
});
73+
constinput=`C:${testPath[0].replace(slashRE,'\\')}`;
74+
constactual=path.win32.extname(input);
75+
constmessage=`path.win32.extname(${JSON.stringify(input)})\n expect=${
76+
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
77+
if(actual!==expected)
78+
failures.push(`\n${message}`);
79+
}
7980
assert.strictEqual(failures.length,0,failures.join(''));
8081

8182
// On Windows, backslash is a path separator.

0 commit comments

Comments
(0)