Skip to content

Commit 01f00fa

Browse files
himself65richardlau
authored andcommitted
test: simplify test-path-resolve.js
PR-URL: #38671 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8699e62 commit 01f00fa

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,24 @@ const resolveTests = [
3838
]
3939
]
4040
];
41-
resolveTests.forEach((test)=>{
42-
constresolve=test[0];
43-
test[1].forEach((test)=>{
44-
constactual=resolve.apply(null,test[0]);
41+
resolveTests.forEach(([resolve,tests])=>{
42+
tests.forEach(([test,expected])=>{
43+
constactual=resolve.apply(null,test);
4544
letactualAlt;
4645
constos=resolve===path.win32.resolve ? 'win32' : 'posix';
4746
if(resolve===path.win32.resolve&&!common.isWindows)
4847
actualAlt=actual.replace(backslashRE,'/');
4948
elseif(resolve!==path.win32.resolve&&common.isWindows)
5049
actualAlt=actual.replace(slashRE,'\\');
5150

52-
constexpected=test[1];
5351
constmessage=
54-
`path.${os}.resolve(${test[0].map(JSON.stringify).join(',')})\n expect=${
52+
`path.${os}.resolve(${test.map(JSON.stringify).join(',')})\n expect=${
5553
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
5654
if(actual!==expected&&actualAlt!==expected)
57-
failures.push(`\n${message}`);
55+
failures.push(message);
5856
});
5957
});
60-
assert.strictEqual(failures.length,0,failures.join(''));
58+
assert.strictEqual(failures.length,0,failures.join('\n'));
6159

6260
if(common.isWindows){
6361
// Test resolving the current Windows drive letter from a spawned process.

0 commit comments

Comments
(0)