11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// These testcases are specific to one uncommon behavior in path module. Few 41cb0ef41Sopenharmony_ci// of the functions in path module, treat '' strings as current working 51cb0ef41Sopenharmony_ci// directory. This test makes sure that the behavior is intact between commits. 61cb0ef41Sopenharmony_ci// See: https://github.com/nodejs/node/pull/2106 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cirequire('../common'); 91cb0ef41Sopenharmony_ciconst assert = require('assert'); 101cb0ef41Sopenharmony_ciconst path = require('path'); 111cb0ef41Sopenharmony_ciconst pwd = process.cwd(); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci// Join will internally ignore all the zero-length strings and it will return 141cb0ef41Sopenharmony_ci// '.' if the joined string is a zero-length string. 151cb0ef41Sopenharmony_ciassert.strictEqual(path.posix.join(''), '.'); 161cb0ef41Sopenharmony_ciassert.strictEqual(path.posix.join('', ''), '.'); 171cb0ef41Sopenharmony_ciassert.strictEqual(path.win32.join(''), '.'); 181cb0ef41Sopenharmony_ciassert.strictEqual(path.win32.join('', ''), '.'); 191cb0ef41Sopenharmony_ciassert.strictEqual(path.join(pwd), pwd); 201cb0ef41Sopenharmony_ciassert.strictEqual(path.join(pwd, ''), pwd); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci// Normalize will return '.' if the input is a zero-length string 231cb0ef41Sopenharmony_ciassert.strictEqual(path.posix.normalize(''), '.'); 241cb0ef41Sopenharmony_ciassert.strictEqual(path.win32.normalize(''), '.'); 251cb0ef41Sopenharmony_ciassert.strictEqual(path.normalize(pwd), pwd); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci// Since '' is not a valid path in any of the common environments, return false 281cb0ef41Sopenharmony_ciassert.strictEqual(path.posix.isAbsolute(''), false); 291cb0ef41Sopenharmony_ciassert.strictEqual(path.win32.isAbsolute(''), false); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci// Resolve, internally ignores all the zero-length strings and returns the 321cb0ef41Sopenharmony_ci// current working directory 331cb0ef41Sopenharmony_ciassert.strictEqual(path.resolve(''), pwd); 341cb0ef41Sopenharmony_ciassert.strictEqual(path.resolve('', ''), pwd); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci// Relative, internally calls resolve. So, '' is actually the current directory 371cb0ef41Sopenharmony_ciassert.strictEqual(path.relative('', pwd), ''); 381cb0ef41Sopenharmony_ciassert.strictEqual(path.relative(pwd, ''), ''); 391cb0ef41Sopenharmony_ciassert.strictEqual(path.relative(pwd, pwd), ''); 40