@@ -6,7 +6,7 @@ const path = require('path');
66const failures = [ ] ;
77const slashRE = / \/ / g;
88
9- [
9+ const testPaths = [
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- 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 ] ;
5760 let os ;
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- 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 } ` ) ;
7772 }
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+ }
7980assert . strictEqual ( failures . length , 0 , failures . join ( '' ) ) ;
8081
8182// On Windows, backslash is a path separator.
0 commit comments