mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
2ef0f007a4
Create one file for testing each function of the path module. Keep general error tests and tests for constant properties in test-path.js. PR-URL: https://github.com/nodejs/node/pull/15093 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
57 lines
2.9 KiB
JavaScript
57 lines
2.9 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
|
|
assert.strictEqual(path.dirname(__filename).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('//a'), '//');
|
|
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('file:stream'), '.');
|
|
assert.strictEqual(path.win32.dirname('dir\\file:stream'), 'dir');
|
|
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'), '.');
|