diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-10-09 17:18:08 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-10-09 17:18:08 -0400 |
commit | 28293acd9c12a94f5d769706291032e844c7b92b (patch) | |
tree | 1fec6a3cd8d7c9e8bc9b1486f5c8438eb906a595 /std/fs/path/dirname_test.ts | |
parent | 5c6835efd82c298df99ce71c4a36ca23515333a3 (diff) | |
parent | 151ce0266eb4de2c8fc600c81c192a5f791b6169 (diff) |
Merge branch 'std_modified' into merge_std3
Diffstat (limited to 'std/fs/path/dirname_test.ts')
-rw-r--r-- | std/fs/path/dirname_test.ts | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/std/fs/path/dirname_test.ts b/std/fs/path/dirname_test.ts new file mode 100644 index 000000000..047d4859b --- /dev/null +++ b/std/fs/path/dirname_test.ts @@ -0,0 +1,62 @@ +// Copyright the Browserify authors. MIT License. +// Ported from https://github.com/browserify/path-browserify/ + +import { test } from "../../testing/mod.ts"; +import { assertEquals } from "../../testing/asserts.ts"; +import * as path from "./mod.ts"; + +test(function dirname() { + assertEquals(path.posix.dirname("/a/b/"), "/a"); + assertEquals(path.posix.dirname("/a/b"), "/a"); + assertEquals(path.posix.dirname("/a"), "/"); + assertEquals(path.posix.dirname(""), "."); + assertEquals(path.posix.dirname("/"), "/"); + assertEquals(path.posix.dirname("////"), "/"); + assertEquals(path.posix.dirname("//a"), "//"); + assertEquals(path.posix.dirname("foo"), "."); +}); + +test(function dirnameWin32() { + assertEquals(path.win32.dirname("c:\\"), "c:\\"); + assertEquals(path.win32.dirname("c:\\foo"), "c:\\"); + assertEquals(path.win32.dirname("c:\\foo\\"), "c:\\"); + assertEquals(path.win32.dirname("c:\\foo\\bar"), "c:\\foo"); + assertEquals(path.win32.dirname("c:\\foo\\bar\\"), "c:\\foo"); + assertEquals(path.win32.dirname("c:\\foo\\bar\\baz"), "c:\\foo\\bar"); + assertEquals(path.win32.dirname("\\"), "\\"); + assertEquals(path.win32.dirname("\\foo"), "\\"); + assertEquals(path.win32.dirname("\\foo\\"), "\\"); + assertEquals(path.win32.dirname("\\foo\\bar"), "\\foo"); + assertEquals(path.win32.dirname("\\foo\\bar\\"), "\\foo"); + assertEquals(path.win32.dirname("\\foo\\bar\\baz"), "\\foo\\bar"); + assertEquals(path.win32.dirname("c:"), "c:"); + assertEquals(path.win32.dirname("c:foo"), "c:"); + assertEquals(path.win32.dirname("c:foo\\"), "c:"); + assertEquals(path.win32.dirname("c:foo\\bar"), "c:foo"); + assertEquals(path.win32.dirname("c:foo\\bar\\"), "c:foo"); + assertEquals(path.win32.dirname("c:foo\\bar\\baz"), "c:foo\\bar"); + assertEquals(path.win32.dirname("file:stream"), "."); + assertEquals(path.win32.dirname("dir\\file:stream"), "dir"); + assertEquals(path.win32.dirname("\\\\unc\\share"), "\\\\unc\\share"); + assertEquals(path.win32.dirname("\\\\unc\\share\\foo"), "\\\\unc\\share\\"); + assertEquals(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\"); + assertEquals( + path.win32.dirname("\\\\unc\\share\\foo\\bar"), + "\\\\unc\\share\\foo" + ); + assertEquals( + path.win32.dirname("\\\\unc\\share\\foo\\bar\\"), + "\\\\unc\\share\\foo" + ); + assertEquals( + path.win32.dirname("\\\\unc\\share\\foo\\bar\\baz"), + "\\\\unc\\share\\foo\\bar" + ); + assertEquals(path.win32.dirname("/a/b/"), "/a"); + assertEquals(path.win32.dirname("/a/b"), "/a"); + assertEquals(path.win32.dirname("/a"), "/"); + assertEquals(path.win32.dirname(""), "."); + assertEquals(path.win32.dirname("/"), "/"); + assertEquals(path.win32.dirname("////"), "/"); + assertEquals(path.win32.dirname("foo"), "."); +}); |