common.js needs to be loaded in all tests so that there is checking for variable leaks and possibly other things. However, it does not need to be assigned to a variable if nothing in common.js is referred to elsewhere in the test. The main tradeoff for this bit of code churn is that it gets the code base most of the way to being able to enable the no-unused-vars rule in eslint. (The non-tooling benefit is that it lessens cognitive load when reading tests as it is an immediate indication that none of the functions or properties in common.js will be used by the test.) PR-URL: https://github.com/nodejs/node/pull/4563 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
// These testcases are specific to one uncommon behaviour in path module. Few
|
|
// of the functions in path module, treat '' strings as current working
|
|
// directory. This test makes sure that the behaviour is intact between commits.
|
|
// See: https://github.com/nodejs/node/pull/2106
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const pwd = process.cwd();
|
|
|
|
// join will internally ignore all the zero-length strings and it will return
|
|
// '.' if the joined string is a zero-length string.
|
|
assert.equal(path.join(''), '.');
|
|
assert.equal(path.join('', ''), '.');
|
|
assert.equal(path.join(pwd), pwd);
|
|
assert.equal(path.join(pwd, ''), pwd);
|
|
|
|
// normalize will return '.' if the input is a zero-length string
|
|
assert.equal(path.normalize(''), '.');
|
|
assert.equal(path.normalize(pwd), pwd);
|
|
|
|
// Since '' is not a valid path in any of the common environments, return false
|
|
assert.equal(path.isAbsolute(''), false);
|
|
|
|
// resolve, internally ignores all the zero-length strings and returns the
|
|
// current working directory
|
|
assert.equal(path.resolve(''), pwd);
|
|
assert.equal(path.resolve('', ''), pwd);
|
|
|
|
// relative, internally calls resolve. So, '' is actually the current directory
|
|
assert.equal(path.relative('', pwd), '');
|
|
assert.equal(path.relative(pwd, ''), '');
|
|
assert.equal(path.relative(pwd, pwd), '');
|