diff options
author | Nayeem Rahman <muhammed.9939@gmail.com> | 2019-10-16 19:39:33 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-10-16 14:39:33 -0400 |
commit | f51dcc12d7a75a677529d63eb53d7a577d5b9289 (patch) | |
tree | 67c5ee1026a6da84e68b249a77067bfd0b313532 /std/path/resolve_test.ts | |
parent | 99d8ac70dbf412ee5de9ad2370c75dcd51cc5def (diff) |
std: Move fs/path to the top-level (#3100)
Diffstat (limited to 'std/path/resolve_test.ts')
-rw-r--r-- | std/path/resolve_test.ts | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/std/path/resolve_test.ts b/std/path/resolve_test.ts new file mode 100644 index 000000000..65a8a2d05 --- /dev/null +++ b/std/path/resolve_test.ts @@ -0,0 +1,52 @@ +// Copyright the Browserify authors. MIT License. +// Ported from https://github.com/browserify/path-browserify/ + +const { cwd } = Deno; +import { test } from "../testing/mod.ts"; +import { assertEquals } from "../testing/asserts.ts"; +import * as path from "./mod.ts"; + +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 _p = p[0] as string[]; + const actual = path.posix.resolve.apply(null, _p); + assertEquals(actual, p[1]); + }); +}); + +test(function resolveWin32() { + windowsTests.forEach(function(p) { + const _p = p[0] as string[]; + const actual = path.win32.resolve.apply(null, _p); + assertEquals(actual, p[1]); + }); +}); |