diff options
| author | 木杉 <zhmushan@qq.com> | 2019-01-11 06:11:44 +0800 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-01-10 17:11:44 -0500 |
| commit | 57c877c443765d7aa1f1f2d3cba801f280f19bfa (patch) | |
| tree | 8a6d28410631497413fb32d9ff54b312f7e3d825 /fs/path/resolve_test.ts | |
| parent | 6f8dc44a2b218bac3fb3ebb1035cbbd10160b48b (diff) | |
refactor(path): reorg (denoland/deno_std#101)
Original: https://github.com/denoland/deno_std/commit/5be16ba5992b34a64d307779350b88b5cacbfa23
Diffstat (limited to 'fs/path/resolve_test.ts')
| -rw-r--r-- | fs/path/resolve_test.ts | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/fs/path/resolve_test.ts b/fs/path/resolve_test.ts new file mode 100644 index 000000000..7c2b55249 --- /dev/null +++ b/fs/path/resolve_test.ts @@ -0,0 +1,49 @@ +// Copyright the Browserify authors. MIT License. +// Ported from https://github.com/browserify/path-browserify/ + +import { test, assertEqual } from "../../testing/mod.ts"; +import * as path from "./mod.ts"; +import { cwd } from "deno"; + +const windowsTests = + // arguments result + [ + [["c:/blah\\blah", "d:/games", "c:../a"], "c:\\blah\\a"], + [["c:/ignore", "d:\\a/b\\c/d", "\\e.exe"], "d:\\e.exe"], + [["c:/ignore", "c:/some/file"], "c:\\some\\file"], + [["d:/ignore", "d:some/dir//"], "d:\\ignore\\some\\dir"], + [["//server/share", "..", "relative\\"], "\\\\server\\share\\relative"], + [["c:/", "//"], "c:\\"], + [["c:/", "//dir"], "c:\\dir"], + [["c:/", "//server/share"], "\\\\server\\share\\"], + [["c:/", "//server//share"], "\\\\server\\share\\"], + [["c:/", "///some//dir"], "c:\\some\\dir"], + [ + ["C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js"], + "C:\\foo\\tmp.3\\cycles\\root.js" + ] + ]; +const posixTests = + // arguments result + [ + [["/var/lib", "../", "file/"], "/var/file"], + [["/var/lib", "/../", "file/"], "/file"], + [["a/b/c/", "../../.."], cwd()], + [["."], cwd()], + [["/some/dir", ".", "/absolute/"], "/absolute"], + [["/foo/tmp.3/", "../tmp.3/cycles/root.js"], "/foo/tmp.3/cycles/root.js"] + ]; + +test(function resolve() { + posixTests.forEach(function(p) { + const actual = path.posix.resolve.apply(null, p[0]); + assertEqual(actual, p[1]); + }); +}); + +test(function resolveWin32() { + windowsTests.forEach(function(p) { + const actual = path.win32.resolve.apply(null, p[0]); + assertEqual(actual, p[1]); + }); +}); |
