2018-12-18 21:29:39 -05:00
|
|
|
// Copyright the Browserify authors. MIT License.
|
|
|
|
// Ported from https://github.com/browserify/path-browserify/
|
2019-10-16 14:39:33 -04:00
|
|
|
import { assertEquals } from "../testing/asserts.ts";
|
2019-01-10 17:11:44 -05:00
|
|
|
import * as path from "./mod.ts";
|
2018-12-18 21:29:39 -05:00
|
|
|
|
2020-06-12 15:23:38 -04:00
|
|
|
Deno.test("isAbsolute", function () {
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals(path.posix.isAbsolute("/home/foo"), true);
|
|
|
|
assertEquals(path.posix.isAbsolute("/home/foo/.."), true);
|
|
|
|
assertEquals(path.posix.isAbsolute("bar/"), false);
|
|
|
|
assertEquals(path.posix.isAbsolute("./baz"), false);
|
2018-12-18 21:29:39 -05:00
|
|
|
});
|
|
|
|
|
2020-06-12 15:23:38 -04:00
|
|
|
Deno.test("isAbsoluteWin32", function () {
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals(path.win32.isAbsolute("/"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("//"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("//server"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("//server/file"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("\\\\server\\file"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("\\\\server"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("\\\\"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("c"), false);
|
|
|
|
assertEquals(path.win32.isAbsolute("c:"), false);
|
|
|
|
assertEquals(path.win32.isAbsolute("c:\\"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("c:/"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("c://"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("C:/Users/"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("C:\\Users\\"), true);
|
|
|
|
assertEquals(path.win32.isAbsolute("C:cwd/another"), false);
|
|
|
|
assertEquals(path.win32.isAbsolute("C:cwd\\another"), false);
|
|
|
|
assertEquals(path.win32.isAbsolute("directory/directory"), false);
|
|
|
|
assertEquals(path.win32.isAbsolute("directory\\directory"), false);
|
2018-12-18 21:29:39 -05:00
|
|
|
});
|