1'use strict'; 2 3// These testcases are specific to one uncommon behavior in path module. Few 4// of the functions in path module, treat '' strings as current working 5// directory. This test makes sure that the behavior is intact between commits. 6// See: https://github.com/nodejs/node/pull/2106 7 8require('../common'); 9const assert = require('assert'); 10const path = require('path'); 11const pwd = process.cwd(); 12 13// Join will internally ignore all the zero-length strings and it will return 14// '.' if the joined string is a zero-length string. 15assert.strictEqual(path.posix.join(''), '.'); 16assert.strictEqual(path.posix.join('', ''), '.'); 17assert.strictEqual(path.win32.join(''), '.'); 18assert.strictEqual(path.win32.join('', ''), '.'); 19assert.strictEqual(path.join(pwd), pwd); 20assert.strictEqual(path.join(pwd, ''), pwd); 21 22// Normalize will return '.' if the input is a zero-length string 23assert.strictEqual(path.posix.normalize(''), '.'); 24assert.strictEqual(path.win32.normalize(''), '.'); 25assert.strictEqual(path.normalize(pwd), pwd); 26 27// Since '' is not a valid path in any of the common environments, return false 28assert.strictEqual(path.posix.isAbsolute(''), false); 29assert.strictEqual(path.win32.isAbsolute(''), false); 30 31// Resolve, internally ignores all the zero-length strings and returns the 32// current working directory 33assert.strictEqual(path.resolve(''), pwd); 34assert.strictEqual(path.resolve('', ''), pwd); 35 36// Relative, internally calls resolve. So, '' is actually the current directory 37assert.strictEqual(path.relative('', pwd), ''); 38assert.strictEqual(path.relative(pwd, ''), ''); 39assert.strictEqual(path.relative(pwd, pwd), ''); 40