@ -23,11 +23,11 @@ assert.equal(path.win32.basename('basename.ext'), 'basename.ext');
assert . equal ( path . win32 . basename ( 'basename.ext\\' ) , 'basename.ext' ) ;
assert . equal ( path . win32 . basename ( 'basename.ext\\' ) , 'basename.ext' ) ;
assert . equal ( path . win32 . basename ( 'basename.ext\\\\' ) , 'basename.ext' ) ;
assert . equal ( path . win32 . basename ( 'basename.ext\\\\' ) , 'basename.ext' ) ;
assert . equal ( path . win32 . basename ( 'foo' ) , 'foo' ) ;
assert . equal ( path . win32 . basename ( 'foo' ) , 'foo' ) ;
assert . equal ( path . win32 . basename ( null ) , 'null' ) ;
assert . throws ( path . win32 . basename . bind ( null , null ) , TypeError ) ;
assert . equal ( path . win32 . basename ( true ) , 'true' ) ;
assert . throws ( path . win32 . basename . bind ( null , true ) , TypeError ) ;
assert . equal ( path . win32 . basename ( 1 ) , '1' ) ;
assert . throws ( path . win32 . basename . bind ( null , 1 ) , TypeError ) ;
assert . equal ( path . win32 . basename ( ) , 'undefined' ) ;
assert . throws ( path . win32 . basename . bind ( null ) , TypeError ) ;
assert . equal ( path . win32 . basename ( { } ) , '[object Object]' ) ;
assert . throws ( path . win32 . basename . bind ( null , { } ) , TypeError ) ;
// On unix a backslash is just treated as any other character.
// 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 ( '\\dir\\basename.ext' ) , '\\dir\\basename.ext' ) ;
@ -36,11 +36,11 @@ 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 ( 'basename.ext\\\\' ) , 'basename.ext\\\\' ) ;
assert . equal ( path . posix . basename ( 'foo' ) , 'foo' ) ;
assert . equal ( path . posix . basename ( 'foo' ) , 'foo' ) ;
assert . equal ( path . posix . basename ( null ) , 'null' ) ;
assert . throws ( path . posix . basename . bind ( null , null ) , TypeError ) ;
assert . equal ( path . posix . basename ( true ) , 'true' ) ;
assert . throws ( path . posix . basename . bind ( null , true ) , TypeError ) ;
assert . equal ( path . posix . basename ( 1 ) , '1' ) ;
assert . throws ( path . posix . basename . bind ( null , 1 ) , TypeError ) ;
assert . equal ( path . posix . basename ( ) , 'undefined' ) ;
assert . throws ( path . posix . basename . bind ( null ) , TypeError ) ;
assert . equal ( path . posix . basename ( { } ) , '[object Object]' ) ;
assert . throws ( path . posix . basename . bind ( null , { } ) , TypeError ) ;
// POSIX filenames may include control characters
// POSIX filenames may include control characters
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
@ -60,11 +60,11 @@ assert.equal(path.posix.dirname(''), '.');
assert . equal ( path . posix . dirname ( '/' ) , '/' ) ;
assert . equal ( path . posix . dirname ( '/' ) , '/' ) ;
assert . equal ( path . posix . dirname ( '////' ) , '/' ) ;
assert . equal ( path . posix . dirname ( '////' ) , '/' ) ;
assert . equal ( path . posix . dirname ( 'foo' ) , '.' ) ;
assert . equal ( path . posix . dirname ( 'foo' ) , '.' ) ;
assert . equal ( path . posix . dirname ( null ) , '.' ) ;
assert . throws ( path . posix . dirname . bind ( null , null ) , TypeError ) ;
assert . equal ( path . posix . dirname ( true ) , '.' ) ;
assert . throws ( path . posix . dirname . bind ( null , true ) , TypeError ) ;
assert . equal ( path . posix . dirname ( 1 ) , '.' ) ;
assert . throws ( path . posix . dirname . bind ( null , 1 ) , TypeError ) ;
assert . equal ( path . posix . dirname ( ) , '.' ) ;
assert . throws ( path . posix . dirname . bind ( null ) , TypeError ) ;
assert . equal ( path . posix . dirname ( { } ) , '.' ) ;
assert . throws ( path . posix . dirname . bind ( null , { } ) , TypeError ) ;
assert . equal ( path . win32 . dirname ( 'c:\\' ) , 'c:\\' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\' ) , 'c:\\' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\foo' ) , 'c:\\' ) ;
assert . equal ( path . win32 . dirname ( 'c:\\foo' ) , 'c:\\' ) ;
@ -100,11 +100,11 @@ assert.equal(path.win32.dirname(''), '.');
assert . equal ( path . win32 . dirname ( '/' ) , '/' ) ;
assert . equal ( path . win32 . dirname ( '/' ) , '/' ) ;
assert . equal ( path . win32 . dirname ( '////' ) , '/' ) ;
assert . equal ( path . win32 . dirname ( '////' ) , '/' ) ;
assert . equal ( path . win32 . dirname ( 'foo' ) , '.' ) ;
assert . equal ( path . win32 . dirname ( 'foo' ) , '.' ) ;
assert . equal ( path . win32 . dirname ( null ) , '.' ) ;
assert . throws ( path . win32 . dirname . bind ( null , null ) , TypeError ) ;
assert . equal ( path . win32 . dirname ( true ) , '.' ) ;
assert . throws ( path . win32 . dirname . bind ( null , true ) , TypeError ) ;
assert . equal ( path . win32 . dirname ( 1 ) , '.' ) ;
assert . throws ( path . win32 . dirname . bind ( null , 1 ) , TypeError ) ;
assert . equal ( path . win32 . dirname ( ) , '.' ) ;
assert . throws ( path . win32 . dirname . bind ( null ) , TypeError ) ;
assert . equal ( path . win32 . dirname ( { } ) , '.' ) ;
assert . throws ( path . win32 . dirname . bind ( null , { } ) , TypeError ) ;
// path.extname tests
// path.extname tests
@ -180,11 +180,11 @@ assert.equal(path.win32.extname('file\\'), '');
assert . equal ( path . win32 . extname ( 'file\\\\' ) , '' ) ;
assert . equal ( path . win32 . extname ( 'file\\\\' ) , '' ) ;
assert . equal ( path . win32 . extname ( 'file.\\' ) , '.' ) ;
assert . equal ( path . win32 . extname ( 'file.\\' ) , '.' ) ;
assert . equal ( path . win32 . extname ( 'file.\\\\' ) , '.' ) ;
assert . equal ( path . win32 . extname ( 'file.\\\\' ) , '.' ) ;
assert . equal ( path . win32 . extname ( null ) , '' ) ;
assert . throws ( path . win32 . extname . bind ( null , null ) , TypeError ) ;
assert . equal ( path . win32 . extname ( true ) , '' ) ;
assert . throws ( path . win32 . extname . bind ( null , true ) , TypeError ) ;
assert . equal ( path . win32 . extname ( 1 ) , '' ) ;
assert . throws ( path . win32 . extname . bind ( null , 1 ) , TypeError ) ;
assert . equal ( path . win32 . extname ( ) , '' ) ;
assert . throws ( path . win32 . extname . bind ( null ) , TypeError ) ;
assert . equal ( path . win32 . extname ( { } ) , '' ) ;
assert . throws ( path . win32 . extname . bind ( null , { } ) , TypeError ) ;
// On *nix, backslash is a valid name component like any other character.
// On *nix, backslash is a valid name component like any other character.
assert . equal ( path . posix . extname ( '.\\' ) , '' ) ;
assert . equal ( path . posix . extname ( '.\\' ) , '' ) ;
@ -195,11 +195,11 @@ assert.equal(path.posix.extname('file\\'), '');
assert . equal ( path . posix . extname ( 'file\\\\' ) , '' ) ;
assert . equal ( path . posix . extname ( 'file\\\\' ) , '' ) ;
assert . equal ( path . posix . extname ( 'file.\\' ) , '.\\' ) ;
assert . equal ( path . posix . extname ( 'file.\\' ) , '.\\' ) ;
assert . equal ( path . posix . extname ( 'file.\\\\' ) , '.\\\\' ) ;
assert . equal ( path . posix . extname ( 'file.\\\\' ) , '.\\\\' ) ;
assert . equal ( path . posix . extname ( null ) , '' ) ;
assert . throws ( path . posix . extname . bind ( null , null ) , TypeError ) ;
assert . equal ( path . posix . extname ( true ) , '' ) ;
assert . throws ( path . posix . extname . bind ( null , true ) , TypeError ) ;
assert . equal ( path . posix . extname ( 1 ) , '' ) ;
assert . throws ( path . posix . extname . bind ( null , 1 ) , TypeError ) ;
assert . equal ( path . posix . extname ( ) , '' ) ;
assert . throws ( path . posix . extname . bind ( null ) , TypeError ) ;
assert . equal ( path . posix . extname ( { } ) , '' ) ;
assert . throws ( path . posix . extname . bind ( null , { } ) , TypeError ) ;
// path.join tests
// path.join tests
@ -336,10 +336,10 @@ assert.equal(failures.length, 0, failures.join(''));
// Test thrown TypeErrors
// Test thrown TypeErrors
var typeErrorTests = [ true , false , 7 , null , { } , undefined , [ ] , NaN ] ;
const typeErrorTests = [ true , false , 7 , null , { } , undefined , [ ] , NaN ] ;
function fail ( fn ) {
function fail ( fn ) {
var args = Array . prototype . slice . call ( arguments , 1 ) ;
const args = Array . prototype . slice . call ( arguments , 1 ) ;
assert . throws ( function ( ) {
assert . throws ( function ( ) {
fn . apply ( null , args ) ;
fn . apply ( null , args ) ;
@ -347,24 +347,23 @@ function fail(fn) {
}
}
typeErrorTests . forEach ( function ( test ) {
typeErrorTests . forEach ( function ( test ) {
fail ( path . join , test ) ;
[ path . posix , path . win32 ] . forEach ( function ( namespace ) {
fail ( path . resolve , test ) ;
fail ( namespace . join , test ) ;
fail ( path . normalize , test ) ;
fail ( namespace . resolve , test ) ;
fail ( path . isAbsolute , test ) ;
fail ( namespace . normalize , test ) ;
fail ( path . relative , test , 'foo' ) ;
fail ( namespace . isAbsolute , test ) ;
fail ( path . relative , 'foo' , test ) ;
fail ( namespace . relative , test , 'foo' ) ;
fail ( path . parse , test ) ;
fail ( namespace . relative , 'foo' , test ) ;
fail ( namespace . parse , test ) ;
// These methods should throw a TypeError, but do not for backwards
fail ( namespace . dirname , test ) ;
// compatibility. Uncommenting these lines in the future should be a goal.
fail ( namespace . basename , test ) ;
// fail(path.dirname, test);
fail ( namespace . extname , test ) ;
// fail(path.basename, test);
// fail(path.extname, test);
// undefined is a valid value as the second argument to basename
if ( test !== undefined ) {
// undefined is a valid value as the second argument to basename
fail ( namespace . basename , 'foo' , test ) ;
if ( test !== undefined ) {
}
fail ( path . basename , 'foo' , test ) ;
} ) ;
}
} ) ;
} ) ;