@ -7,107 +7,111 @@ const f = __filename;
const failures = [ ] ;
// path.basename tests
assert . e qual( path . basename ( f ) , 'test-path.js' ) ;
assert . e qual( path . basename ( f , '.js' ) , 'test-path' ) ;
assert . e qual( path . basename ( '' ) , '' ) ;
assert . e qual( path . basename ( '/dir/basename.ext' ) , 'basename.ext' ) ;
assert . e qual( path . basename ( '/basename.ext' ) , 'basename.ext' ) ;
assert . e qual( path . basename ( 'basename.ext' ) , 'basename.ext' ) ;
assert . e qual( path . basename ( 'basename.ext/' ) , 'basename.ext' ) ;
assert . e qual( path . basename ( 'basename.ext//' ) , 'basename.ext' ) ;
assert . e qual( path . basename ( 'aaa/bbb' , '/bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( 'aaa/bbb' , 'a/bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( 'aaa/bbb' , 'bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( 'aaa/bbb//' , 'bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( 'aaa/bbb' , 'bb' ) , 'b' ) ;
assert . e qual( path . basename ( 'aaa/bbb' , 'b' ) , 'bb' ) ;
assert . e qual( path . basename ( '/aaa/bbb' , '/bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( '/aaa/bbb' , 'a/bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( '/aaa/bbb' , 'bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( '/aaa/bbb//' , 'bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( '/aaa/bbb' , 'bb' ) , 'b' ) ;
assert . e qual( path . basename ( '/aaa/bbb' , 'b' ) , 'bb' ) ;
assert . e qual( path . basename ( '/aaa/bbb' ) , 'bbb' ) ;
assert . e qual( path . basename ( '/aaa/' ) , 'aaa' ) ;
assert . e qual( path . basename ( '/aaa/b' ) , 'b' ) ;
assert . e qual( path . basename ( '/a/b' ) , 'b' ) ;
assert . e qual( path . basename ( '//a' ) , 'a' ) ;
assert . strictE qual( path . basename ( f ) , 'test-path.js' ) ;
assert . strictE qual( path . basename ( f , '.js' ) , 'test-path' ) ;
assert . strictE qual( path . basename ( '' ) , '' ) ;
assert . strictE qual( path . basename ( '/dir/basename.ext' ) , 'basename.ext' ) ;
assert . strictE qual( path . basename ( '/basename.ext' ) , 'basename.ext' ) ;
assert . strictE qual( path . basename ( 'basename.ext' ) , 'basename.ext' ) ;
assert . strictE qual( path . basename ( 'basename.ext/' ) , 'basename.ext' ) ;
assert . strictE qual( path . basename ( 'basename.ext//' ) , 'basename.ext' ) ;
assert . strictE qual( path . basename ( 'aaa/bbb' , '/bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( 'aaa/bbb' , 'a/bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( 'aaa/bbb' , 'bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( 'aaa/bbb//' , 'bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( 'aaa/bbb' , 'bb' ) , 'b' ) ;
assert . strictE qual( path . basename ( 'aaa/bbb' , 'b' ) , 'bb' ) ;
assert . strictE qual( path . basename ( '/aaa/bbb' , '/bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( '/aaa/bbb' , 'a/bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( '/aaa/bbb' , 'bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( '/aaa/bbb//' , 'bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( '/aaa/bbb' , 'bb' ) , 'b' ) ;
assert . strictE qual( path . basename ( '/aaa/bbb' , 'b' ) , 'bb' ) ;
assert . strictE qual( path . basename ( '/aaa/bbb' ) , 'bbb' ) ;
assert . strictE qual( path . basename ( '/aaa/' ) , 'aaa' ) ;
assert . strictE qual( path . basename ( '/aaa/b' ) , 'b' ) ;
assert . strictE qual( path . basename ( '/a/b' ) , 'b' ) ;
assert . strictE qual( path . basename ( '//a' ) , 'a' ) ;
// On Windows a backslash acts as a path separator.
assert . e qual( path . win32 . basename ( '\\dir\\basename.ext' ) , 'basename.ext' ) ;
assert . e qual( path . win32 . basename ( '\\basename.ext' ) , 'basename.ext' ) ;
assert . e qual( path . win32 . basename ( 'basename.ext' ) , 'basename.ext' ) ;
assert . e qual( path . win32 . basename ( 'basename.ext\\' ) , 'basename.ext' ) ;
assert . e qual( path . win32 . basename ( 'basename.ext\\\\' ) , 'basename.ext' ) ;
assert . e qual( path . win32 . basename ( 'foo' ) , 'foo' ) ;
assert . e qual( path . win32 . basename ( 'aaa\\bbb' , '\\bbb' ) , 'bbb' ) ;
assert . e qual( path . win32 . basename ( 'aaa\\bbb' , 'a\\bbb' ) , 'bbb' ) ;
assert . e qual( path . win32 . basename ( 'aaa\\bbb' , 'bbb' ) , 'bbb' ) ;
assert . e qual( path . win32 . basename ( 'aaa\\bbb\\\\\\\\' , 'bbb' ) , 'bbb' ) ;
assert . e qual( path . win32 . basename ( 'aaa\\bbb' , 'bb' ) , 'b' ) ;
assert . e qual( path . win32 . basename ( 'aaa\\bbb' , 'b' ) , 'bb' ) ;
assert . strictE qual( path . win32 . basename ( '\\dir\\basename.ext' ) , 'basename.ext' ) ;
assert . strictE qual( path . win32 . basename ( '\\basename.ext' ) , 'basename.ext' ) ;
assert . strictE qual( path . win32 . basename ( 'basename.ext' ) , 'basename.ext' ) ;
assert . strictE qual( path . win32 . basename ( 'basename.ext\\' ) , 'basename.ext' ) ;
assert . strictE qual( path . win32 . basename ( 'basename.ext\\\\' ) , 'basename.ext' ) ;
assert . strictE qual( path . win32 . basename ( 'foo' ) , 'foo' ) ;
assert . strictE qual( path . win32 . basename ( 'aaa\\bbb' , '\\bbb' ) , 'bbb' ) ;
assert . strictE qual( path . win32 . basename ( 'aaa\\bbb' , 'a\\bbb' ) , 'bbb' ) ;
assert . strictE qual( path . win32 . basename ( 'aaa\\bbb' , 'bbb' ) , 'bbb' ) ;
assert . strictE qual( path . win32 . basename ( 'aaa\\bbb\\\\\\\\' , 'bbb' ) , 'bbb' ) ;
assert . strictE qual( path . win32 . basename ( 'aaa\\bbb' , 'bb' ) , 'b' ) ;
assert . strictE qual( path . win32 . basename ( 'aaa\\bbb' , 'b' ) , 'bb' ) ;
// On unix a backslash is just treated as any other character.
assert . equal ( path . posix . basename ( '\\dir\\basename.ext' ) , '\\dir\\basename.ext' ) ;
assert . equal ( path . posix . basename ( '\\basename.ext' ) , '\\basename.ext' ) ;
assert . equal ( path . posix . basename ( 'basename.ext' ) , 'basename.ext' ) ;
assert . equal ( path . posix . basename ( 'basename.ext\\' ) , 'basename.ext\\' ) ;
assert . equal ( path . posix . basename ( 'basename.ext\\\\' ) , 'basename.ext\\\\' ) ;
assert . equal ( path . posix . basename ( 'foo' ) , 'foo' ) ;
assert . strictEqual ( path . posix . basename ( '\\dir\\basename.ext' ) ,
'\\dir\\basename.ext' ) ;
assert . strictEqual ( path . posix . basename ( '\\basename.ext' ) , '\\basename.ext' ) ;
assert . strictEqual ( path . posix . basename ( 'basename.ext' ) , 'basename.ext' ) ;
assert . strictEqual ( path . posix . basename ( 'basename.ext\\' ) , 'basename.ext\\' ) ;
assert . strictEqual ( path . posix . basename ( 'basename.ext\\\\' ) , 'basename.ext\\\\' ) ;
assert . strictEqual ( path . posix . basename ( 'foo' ) , 'foo' ) ;
// POSIX filenames may include control characters
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
const controlCharFilename = 'Icon' + String . fromCharCode ( 13 ) ;
assert . e qual( path . posix . basename ( '/a/b/' + controlCharFilename ) ,
controlCharFilename ) ;
assert . strictE qual( path . posix . basename ( '/a/b/' + controlCharFilename ) ,
controlCharFilename ) ;
// path.dirname tests
assert . equal ( path . dirname ( f ) . substr ( - 13 ) ,
common . isWindows ? 'test\\parallel' : 'test/parallel' ) ;
assert . equal ( path . posix . dirname ( '/a/b/' ) , '/a' ) ;
assert . equal ( path . posix . dirname ( '/a/b' ) , '/a' ) ;
assert . equal ( path . posix . dirname ( '/a' ) , '/' ) ;
assert . equal ( path . posix . dirname ( '' ) , '.' ) ;
assert . equal ( path . posix . dirname ( '/' ) , '/' ) ;
assert . equal ( path . posix . dirname ( '////' ) , '/' ) ;
assert . equal ( path . posix . dirname ( 'foo' ) , '.' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\' ) , 'c:\\' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\foo' ) , 'c:\\' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\foo\\' ) , 'c:\\' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\foo\\bar' ) , 'c:\\foo' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\foo\\bar\\' ) , 'c:\\foo' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\foo\\bar\\baz' ) , 'c:\\foo\\bar' ) ;
assert . equal ( path . win32 . dirname ( '\\' ) , '\\' ) ;
assert . equal ( path . win32 . dirname ( '\\foo' ) , '\\' ) ;
assert . equal ( path . win32 . dirname ( '\\foo\\' ) , '\\' ) ;
assert . equal ( path . win32 . dirname ( '\\foo\\bar' ) , '\\foo' ) ;
assert . equal ( path . win32 . dirname ( '\\foo\\bar\\' ) , '\\foo' ) ;
assert . equal ( path . win32 . dirname ( '\\foo\\bar\\baz' ) , '\\foo\\bar' ) ;
assert . equal ( path . win32 . dirname ( 'c:' ) , 'c:' ) ;
assert . equal ( path . win32 . dirname ( 'c:foo' ) , 'c:' ) ;
assert . equal ( path . win32 . dirname ( 'c:foo\\' ) , 'c:' ) ;
assert . equal ( path . win32 . dirname ( 'c:foo\\bar' ) , 'c:foo' ) ;
assert . equal ( path . win32 . dirname ( 'c:foo\\bar\\' ) , 'c:foo' ) ;
assert . equal ( path . win32 . dirname ( 'c:foo\\bar\\baz' ) , 'c:foo\\bar' ) ;
assert . equal ( path . win32 . dirname ( '\\\\unc\\share' ) , '\\\\unc\\share' ) ;
assert . equal ( path . win32 . dirname ( '\\\\unc\\share\\foo' ) , '\\\\unc\\share\\' ) ;
assert . equal ( path . win32 . dirname ( '\\\\unc\\share\\foo\\' ) , '\\\\unc\\share\\' ) ;
assert . equal ( path . win32 . dirname ( '\\\\unc\\share\\foo\\bar' ) ,
'\\\\unc\\share\\foo' ) ;
assert . equal ( path . win32 . dirname ( '\\\\unc\\share\\foo\\bar\\' ) ,
'\\\\unc\\share\\foo' ) ;
assert . equal ( path . win32 . dirname ( '\\\\unc\\share\\foo\\bar\\baz' ) ,
'\\\\unc\\share\\foo\\bar' ) ;
assert . equal ( path . win32 . dirname ( '/a/b/' ) , '/a' ) ;
assert . equal ( path . win32 . dirname ( '/a/b' ) , '/a' ) ;
assert . equal ( path . win32 . dirname ( '/a' ) , '/' ) ;
assert . equal ( path . win32 . dirname ( '' ) , '.' ) ;
assert . equal ( path . win32 . dirname ( '/' ) , '/' ) ;
assert . equal ( path . win32 . dirname ( '////' ) , '/' ) ;
assert . equal ( path . win32 . dirname ( 'foo' ) , '.' ) ;
assert . strictEqual ( path . dirname ( f ) . substr ( - 13 ) ,
common . isWindows ? 'test\\parallel' : 'test/parallel' ) ;
assert . strictEqual ( path . posix . dirname ( '/a/b/' ) , '/a' ) ;
assert . strictEqual ( path . posix . dirname ( '/a/b' ) , '/a' ) ;
assert . strictEqual ( path . posix . dirname ( '/a' ) , '/' ) ;
assert . strictEqual ( path . posix . dirname ( '' ) , '.' ) ;
assert . strictEqual ( path . posix . dirname ( '/' ) , '/' ) ;
assert . strictEqual ( path . posix . dirname ( '////' ) , '/' ) ;
assert . strictEqual ( path . posix . dirname ( 'foo' ) , '.' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:\\' ) , 'c:\\' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:\\foo' ) , 'c:\\' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:\\foo\\' ) , 'c:\\' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:\\foo\\bar' ) , 'c:\\foo' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:\\foo\\bar\\' ) , 'c:\\foo' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:\\foo\\bar\\baz' ) , 'c:\\foo\\bar' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\' ) , '\\' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\foo' ) , '\\' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\foo\\' ) , '\\' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\foo\\bar' ) , '\\foo' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\foo\\bar\\' ) , '\\foo' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\foo\\bar\\baz' ) , '\\foo\\bar' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:' ) , 'c:' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:foo' ) , 'c:' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:foo\\' ) , 'c:' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:foo\\bar' ) , 'c:foo' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:foo\\bar\\' ) , 'c:foo' ) ;
assert . strictEqual ( path . win32 . dirname ( 'c:foo\\bar\\baz' ) , 'c:foo\\bar' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\\\unc\\share' ) ,
'\\\\unc\\share' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\\\unc\\share\\foo' ) ,
'\\\\unc\\share\\' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\\\unc\\share\\foo\\' ) ,
'\\\\unc\\share\\' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\\\unc\\share\\foo\\bar' ) ,
'\\\\unc\\share\\foo' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\\\unc\\share\\foo\\bar\\' ) ,
'\\\\unc\\share\\foo' ) ;
assert . strictEqual ( path . win32 . dirname ( '\\\\unc\\share\\foo\\bar\\baz' ) ,
'\\\\unc\\share\\foo\\bar' ) ;
assert . strictEqual ( path . win32 . dirname ( '/a/b/' ) , '/a' ) ;
assert . strictEqual ( path . win32 . dirname ( '/a/b' ) , '/a' ) ;
assert . strictEqual ( path . win32 . dirname ( '/a' ) , '/' ) ;
assert . strictEqual ( path . win32 . dirname ( '' ) , '.' ) ;
assert . strictEqual ( path . win32 . dirname ( '/' ) , '/' ) ;
assert . strictEqual ( path . win32 . dirname ( '////' ) , '/' ) ;
assert . strictEqual ( path . win32 . dirname ( 'foo' ) , '.' ) ;
// path.extname tests
@ -175,27 +179,27 @@ assert.equal(path.win32.dirname('foo'), '.');
failures . push ( '\n' + message ) ;
} ) ;
} ) ;
assert . e qual( failures . length , 0 , failures . join ( '' ) ) ;
assert . strictE qual( failures . length , 0 , failures . join ( '' ) ) ;
// On Windows, backslash is a path separator.
assert . e qual( path . win32 . extname ( '.\\' ) , '' ) ;
assert . e qual( path . win32 . extname ( '..\\' ) , '' ) ;
assert . e qual( path . win32 . extname ( 'file.ext\\' ) , '.ext' ) ;
assert . e qual( path . win32 . extname ( 'file.ext\\\\' ) , '.ext' ) ;
assert . e qual( path . win32 . extname ( 'file\\' ) , '' ) ;
assert . e qual( path . win32 . extname ( 'file\\\\' ) , '' ) ;
assert . e qual( path . win32 . extname ( 'file.\\' ) , '.' ) ;
assert . e qual( path . win32 . extname ( 'file.\\\\' ) , '.' ) ;
assert . strictE qual( path . win32 . extname ( '.\\' ) , '' ) ;
assert . strictE qual( path . win32 . extname ( '..\\' ) , '' ) ;
assert . strictE qual( path . win32 . extname ( 'file.ext\\' ) , '.ext' ) ;
assert . strictE qual( path . win32 . extname ( 'file.ext\\\\' ) , '.ext' ) ;
assert . strictE qual( path . win32 . extname ( 'file\\' ) , '' ) ;
assert . strictE qual( path . win32 . extname ( 'file\\\\' ) , '' ) ;
assert . strictE qual( path . win32 . extname ( 'file.\\' ) , '.' ) ;
assert . strictE qual( path . win32 . extname ( 'file.\\\\' ) , '.' ) ;
// On *nix, backslash is a valid name component like any other character.
assert . e qual( path . posix . extname ( '.\\' ) , '' ) ;
assert . e qual( path . posix . extname ( '..\\' ) , '.\\' ) ;
assert . e qual( path . posix . extname ( 'file.ext\\' ) , '.ext\\' ) ;
assert . e qual( path . posix . extname ( 'file.ext\\\\' ) , '.ext\\\\' ) ;
assert . e qual( path . posix . extname ( 'file\\' ) , '' ) ;
assert . e qual( path . posix . extname ( 'file\\\\' ) , '' ) ;
assert . e qual( path . posix . extname ( 'file.\\' ) , '.\\' ) ;
assert . e qual( path . posix . extname ( 'file.\\\\' ) , '.\\\\' ) ;
assert . strictE qual( path . posix . extname ( '.\\' ) , '' ) ;
assert . strictE qual( path . posix . extname ( '..\\' ) , '.\\' ) ;
assert . strictE qual( path . posix . extname ( 'file.ext\\' ) , '.ext\\' ) ;
assert . strictE qual( path . posix . extname ( 'file.ext\\\\' ) , '.ext\\\\' ) ;
assert . strictE qual( path . posix . extname ( 'file\\' ) , '' ) ;
assert . strictE qual( path . posix . extname ( 'file\\\\' ) , '' ) ;
assert . strictE qual( path . posix . extname ( 'file.\\' ) , '.\\' ) ;
assert . strictE qual( path . posix . extname ( 'file.\\\\' ) , '.\\\\' ) ;
// path.join tests
@ -332,7 +336,7 @@ joinTests.forEach(function(test) {
} ) ;
} ) ;
} ) ;
assert . e qual( failures . length , 0 , failures . join ( '' ) ) ;
assert . strictE qual( failures . length , 0 , failures . join ( '' ) ) ;
// Test thrown TypeErrors
@ -368,24 +372,24 @@ typeErrorTests.forEach(function(test) {
// path.normalize tests
assert . e qual( path . win32 . normalize ( './fixtures///b/../b/c.js' ) ,
'fixtures\\b\\c.js' ) ;
assert . e qual( path . win32 . normalize ( '/foo/../../../bar' ) , '\\bar' ) ;
assert . e qual( path . win32 . normalize ( 'a//b//../b' ) , 'a\\b' ) ;
assert . e qual( path . win32 . normalize ( 'a//b//./c' ) , 'a\\b\\c' ) ;
assert . e qual( path . win32 . normalize ( 'a//b//.' ) , 'a\\b' ) ;
assert . e qual( path . win32 . normalize ( '//server/share/dir/file.ext' ) ,
'\\\\server\\share\\dir\\file.ext' ) ;
assert . e qual( path . win32 . normalize ( '/a/b/c/../../../x/y/z' ) , '\\x\\y\\z' ) ;
assert . e qual( path . posix . normalize ( './fixtures///b/../b/c.js' ) ,
'fixtures/b/c.js' ) ;
assert . e qual( path . posix . normalize ( '/foo/../../../bar' ) , '/bar' ) ;
assert . e qual( path . posix . normalize ( 'a//b//../b' ) , 'a/b' ) ;
assert . e qual( path . posix . normalize ( 'a//b//./c' ) , 'a/b/c' ) ;
assert . e qual( path . posix . normalize ( 'a//b//.' ) , 'a/b' ) ;
assert . e qual( path . posix . normalize ( '/a/b/c/../../../x/y/z' ) , '/x/y/z' ) ;
assert . e qual( path . posix . normalize ( '///..//./foo/.//bar' ) , '/foo/bar' ) ;
assert . strictE qual( path . win32 . normalize ( './fixtures///b/../b/c.js' ) ,
'fixtures\\b\\c.js' ) ;
assert . strictE qual( path . win32 . normalize ( '/foo/../../../bar' ) , '\\bar' ) ;
assert . strictE qual( path . win32 . normalize ( 'a//b//../b' ) , 'a\\b' ) ;
assert . strictE qual( path . win32 . normalize ( 'a//b//./c' ) , 'a\\b\\c' ) ;
assert . strictE qual( path . win32 . normalize ( 'a//b//.' ) , 'a\\b' ) ;
assert . strictE qual( path . win32 . normalize ( '//server/share/dir/file.ext' ) ,
'\\\\server\\share\\dir\\file.ext' ) ;
assert . strictE qual( path . win32 . normalize ( '/a/b/c/../../../x/y/z' ) , '\\x\\y\\z' ) ;
assert . strictE qual( path . posix . normalize ( './fixtures///b/../b/c.js' ) ,
'fixtures/b/c.js' ) ;
assert . strictE qual( path . posix . normalize ( '/foo/../../../bar' ) , '/bar' ) ;
assert . strictE qual( path . posix . normalize ( 'a//b//../b' ) , 'a/b' ) ;
assert . strictE qual( path . posix . normalize ( 'a//b//./c' ) , 'a/b/c' ) ;
assert . strictE qual( path . posix . normalize ( 'a//b//.' ) , 'a/b' ) ;
assert . strictE qual( path . posix . normalize ( '/a/b/c/../../../x/y/z' ) , '/x/y/z' ) ;
assert . strictE qual( path . posix . normalize ( '///..//./foo/.//bar' ) , '/foo/bar' ) ;
// path.resolve tests
@ -438,33 +442,33 @@ resolveTests.forEach(function(test) {
failures . push ( '\n' + message ) ;
} ) ;
} ) ;
assert . e qual( failures . length , 0 , failures . join ( '' ) ) ;
assert . strictE qual( failures . length , 0 , failures . join ( '' ) ) ;
// path.isAbsolute tests
assert . e qual( path . win32 . isAbsolute ( '/' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( '//' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( '//server' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( '//server/file' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( '\\\\server\\file' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( '\\\\server' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( '\\\\' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( 'c' ) , false ) ;
assert . e qual( path . win32 . isAbsolute ( 'c:' ) , false ) ;
assert . e qual( path . win32 . isAbsolute ( 'c:\\' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( 'c:/' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( 'c://' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( 'C:/Users/' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( 'C:\\Users\\' ) , true ) ;
assert . e qual( path . win32 . isAbsolute ( 'C:cwd/another' ) , false ) ;
assert . e qual( path . win32 . isAbsolute ( 'C:cwd\\another' ) , false ) ;
assert . e qual( path . win32 . isAbsolute ( 'directory/directory' ) , false ) ;
assert . e qual( path . win32 . isAbsolute ( 'directory\\directory' ) , false ) ;
assert . e qual( path . posix . isAbsolute ( '/home/foo' ) , true ) ;
assert . e qual( path . posix . isAbsolute ( '/home/foo/..' ) , true ) ;
assert . e qual( path . posix . isAbsolute ( 'bar/' ) , false ) ;
assert . e qual( path . posix . isAbsolute ( './baz' ) , false ) ;
assert . strictE qual( path . win32 . isAbsolute ( '/' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( '//' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( '//server' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( '//server/file' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( '\\\\server\\file' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( '\\\\server' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( '\\\\' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'c' ) , false ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'c:' ) , false ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'c:\\' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'c:/' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'c://' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'C:/Users/' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'C:\\Users\\' ) , true ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'C:cwd/another' ) , false ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'C:cwd\\another' ) , false ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'directory/directory' ) , false ) ;
assert . strictE qual( path . win32 . isAbsolute ( 'directory\\directory' ) , false ) ;
assert . strictE qual( path . posix . isAbsolute ( '/home/foo' ) , true ) ;
assert . strictE qual( path . posix . isAbsolute ( '/home/foo/..' ) , true ) ;
assert . strictE qual( path . posix . isAbsolute ( 'bar/' ) , false ) ;
assert . strictE qual( path . posix . isAbsolute ( './baz' ) , false ) ;
// path.relative tests
@ -530,54 +534,56 @@ relativeTests.forEach(function(test) {
failures . push ( '\n' + message ) ;
} ) ;
} ) ;
assert . e qual( failures . length , 0 , failures . join ( '' ) ) ;
assert . strictE qual( failures . length , 0 , failures . join ( '' ) ) ;
// path.sep tests
// windows
assert . e qual( path . win32 . sep , '\\' ) ;
assert . strictE qual( path . win32 . sep , '\\' ) ;
// posix
assert . e qual( path . posix . sep , '/' ) ;
assert . strictE qual( path . posix . sep , '/' ) ;
// path.delimiter tests
// windows
assert . e qual( path . win32 . delimiter , ';' ) ;
assert . strictE qual( path . win32 . delimiter , ';' ) ;
// posix
assert . e qual( path . posix . delimiter , ':' ) ;
assert . strictE qual( path . posix . delimiter , ':' ) ;
// path._makeLong tests
const emptyObj = { } ;
assert . e qual( path . posix . _ makeLong ( '/foo/bar' ) , '/foo/bar' ) ;
assert . e qual( path . posix . _ makeLong ( 'foo/bar' ) , 'foo/bar' ) ;
assert . e qual( path . posix . _ makeLong ( null ) , null ) ;
assert . e qual( path . posix . _ makeLong ( true ) , true ) ;
assert . e qual( path . posix . _ makeLong ( 1 ) , 1 ) ;
assert . e qual( path . posix . _ makeLong ( ) , undefined ) ;
assert . e qual( path . posix . _ makeLong ( emptyObj ) , emptyObj ) ;
assert . strictE qual( path . posix . _ makeLong ( '/foo/bar' ) , '/foo/bar' ) ;
assert . strictE qual( path . posix . _ makeLong ( 'foo/bar' ) , 'foo/bar' ) ;
assert . strictE qual( path . posix . _ makeLong ( null ) , null ) ;
assert . strictE qual( path . posix . _ makeLong ( true ) , true ) ;
assert . strictE qual( path . posix . _ makeLong ( 1 ) , 1 ) ;
assert . strictE qual( path . posix . _ makeLong ( ) , undefined ) ;
assert . strictE qual( path . posix . _ makeLong ( emptyObj ) , emptyObj ) ;
if ( common . isWindows ) {
// These tests cause resolve() to insert the cwd, so we cannot test them from
// non-Windows platforms (easily)
assert . e qual( path . win32 . _ makeLong ( 'foo\\bar' ) . toLowerCase ( ) ,
'\\\\?\\' + process . cwd ( ) . toLowerCase ( ) + '\\foo\\bar' ) ;
assert . e qual( path . win32 . _ makeLong ( 'foo/bar' ) . toLowerCase ( ) ,
'\\\\?\\' + process . cwd ( ) . toLowerCase ( ) + '\\foo\\bar' ) ;
assert . strictE qual( path . win32 . _ makeLong ( 'foo\\bar' ) . toLowerCase ( ) ,
'\\\\?\\' + process . cwd ( ) . toLowerCase ( ) + '\\foo\\bar' ) ;
assert . strictE qual( path . win32 . _ makeLong ( 'foo/bar' ) . toLowerCase ( ) ,
'\\\\?\\' + process . cwd ( ) . toLowerCase ( ) + '\\foo\\bar' ) ;
const currentDeviceLetter = path . parse ( process . cwd ( ) ) . root . substring ( 0 , 2 ) ;
assert . e qual( path . win32 . _ makeLong ( currentDeviceLetter ) . toLowerCase ( ) ,
'\\\\?\\' + process . cwd ( ) . toLowerCase ( ) ) ;
assert . e qual( path . win32 . _ makeLong ( 'C' ) . toLowerCase ( ) ,
'\\\\?\\' + process . cwd ( ) . toLowerCase ( ) + '\\c' ) ;
assert . strictE qual( path . win32 . _ makeLong ( currentDeviceLetter ) . toLowerCase ( ) ,
'\\\\?\\' + process . cwd ( ) . toLowerCase ( ) ) ;
assert . strictE qual( path . win32 . _ makeLong ( 'C' ) . toLowerCase ( ) ,
'\\\\?\\' + process . cwd ( ) . toLowerCase ( ) + '\\c' ) ;
}
assert . equal ( path . win32 . _ makeLong ( 'C:\\foo' ) , '\\\\?\\C:\\foo' ) ;
assert . equal ( path . win32 . _ makeLong ( 'C:/foo' ) , '\\\\?\\C:\\foo' ) ;
assert . equal ( path . win32 . _ makeLong ( '\\\\foo\\bar' ) , '\\\\?\\UNC\\foo\\bar\\' ) ;
assert . equal ( path . win32 . _ makeLong ( '//foo//bar' ) , '\\\\?\\UNC\\foo\\bar\\' ) ;
assert . equal ( path . win32 . _ makeLong ( '\\\\?\\foo' ) , '\\\\?\\foo' ) ;
assert . equal ( path . win32 . _ makeLong ( null ) , null ) ;
assert . equal ( path . win32 . _ makeLong ( true ) , true ) ;
assert . equal ( path . win32 . _ makeLong ( 1 ) , 1 ) ;
assert . equal ( path . win32 . _ makeLong ( ) , undefined ) ;
assert . equal ( path . win32 . _ makeLong ( emptyObj ) , emptyObj ) ;
assert . strictEqual ( path . win32 . _ makeLong ( 'C:\\foo' ) , '\\\\?\\C:\\foo' ) ;
assert . strictEqual ( path . win32 . _ makeLong ( 'C:/foo' ) , '\\\\?\\C:\\foo' ) ;
assert . strictEqual ( path . win32 . _ makeLong ( '\\\\foo\\bar' ) ,
'\\\\?\\UNC\\foo\\bar\\' ) ;
assert . strictEqual ( path . win32 . _ makeLong ( '//foo//bar' ) ,
'\\\\?\\UNC\\foo\\bar\\' ) ;
assert . strictEqual ( path . win32 . _ makeLong ( '\\\\?\\foo' ) , '\\\\?\\foo' ) ;
assert . strictEqual ( path . win32 . _ makeLong ( null ) , null ) ;
assert . strictEqual ( path . win32 . _ makeLong ( true ) , true ) ;
assert . strictEqual ( path . win32 . _ makeLong ( 1 ) , 1 ) ;
assert . strictEqual ( path . win32 . _ makeLong ( ) , undefined ) ;
assert . strictEqual ( path . win32 . _ makeLong ( emptyObj ) , emptyObj ) ;
if ( common . isWindows )