@@ -6,7 +6,7 @@ const path = require('path');
6
6
const failures = [ ] ;
7
7
const slashRE = / \/ / g;
8
8
9
- [
9
+ const testPaths = [
10
10
[ __filename , '.js' ] ,
11
11
[ '' , '' ] ,
12
12
[ '/path/to/file' , '' ] ,
@@ -50,10 +50,13 @@ const slashRE = /\//g;
50
50
[ 'file//' , '' ] ,
51
51
[ 'file./' , '.' ] ,
52
52
[ 'file.//' , '.' ] ,
53
- ] . forEach ( ( test ) => {
54
- const expected = test [ 1 ] ;
55
- [ path . posix . extname , path . win32 . extname ] . forEach ( ( extname ) => {
56
- let input = test [ 0 ] ;
53
+ ] ;
54
+
55
+ for ( const testPath of testPaths ) {
56
+ const expected = testPath [ 1 ] ;
57
+ const extNames = [ path . posix . extname , path . win32 . extname ] ;
58
+ for ( const extname of extNames ) {
59
+ let input = testPath [ 0 ] ;
57
60
let os ;
58
61
if ( extname === path . win32 . extname ) {
59
62
input = input . replace ( slashRE , '\\' ) ;
@@ -66,16 +69,14 @@ const slashRE = /\//g;
66
69
JSON . stringify ( expected ) } \n actual=${ JSON . stringify ( actual ) } `;
67
70
if ( actual !== expected )
68
71
failures . push ( `\n${ message } ` ) ;
69
- } ) ;
70
- {
71
- const input = `C:${ test [ 0 ] . replace ( slashRE , '\\' ) } ` ;
72
- const actual = path . win32 . extname ( input ) ;
73
- const message = `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 } ` ) ;
77
72
}
78
- } ) ;
73
+ const input = `C:${ testPath [ 0 ] . replace ( slashRE , '\\' ) } ` ;
74
+ const actual = path . win32 . extname ( input ) ;
75
+ const message = `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
+ }
79
80
assert . strictEqual ( failures . length , 0 , failures . join ( '' ) ) ;
80
81
81
82
// On Windows, backslash is a path separator.
0 commit comments