diff options
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/glob_test.ts | 50 | ||||
| -rw-r--r-- | fs/globrex_test.ts | 4 | ||||
| -rw-r--r-- | fs/path/basename_test.ts | 111 | ||||
| -rw-r--r-- | fs/path/dirname_test.ts | 84 | ||||
| -rw-r--r-- | fs/path/extname_test.ts | 40 | ||||
| -rw-r--r-- | fs/path/isabsolute_test.ts | 46 | ||||
| -rw-r--r-- | fs/path/join_test.ts | 8 | ||||
| -rw-r--r-- | fs/path/parse_format_test.ts | 28 | ||||
| -rw-r--r-- | fs/path/relative_test.ts | 6 | ||||
| -rw-r--r-- | fs/path/resolve_test.ts | 6 | ||||
| -rw-r--r-- | fs/path/zero_length_strings_test.ts | 34 | ||||
| -rw-r--r-- | fs/walk_test.ts | 66 |
12 files changed, 243 insertions, 240 deletions
diff --git a/fs/glob_test.ts b/fs/glob_test.ts index 97f5d102e..8691d2c33 100644 --- a/fs/glob_test.ts +++ b/fs/glob_test.ts @@ -1,7 +1,7 @@ const { mkdir, open } = Deno; import { FileInfo } from "deno"; import { test } from "../testing/mod.ts"; -import { assertEq } from "../testing/asserts.ts"; +import { assertEquals } from "../testing/asserts.ts"; import { glob } from "./glob.ts"; import { join } from "./path.ts"; import { testWalk } from "./walk_test.ts"; @@ -23,43 +23,43 @@ async function walkArray( const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) => f.path.replace(/\\/g, "/") ).sort(); - assertEq(arr, arr_sync); + assertEquals(arr, arr_sync); return arr; } test({ name: "glob: glob to regex", fn() { - assertEq(glob("unicorn.*") instanceof RegExp, true); - assertEq(glob("unicorn.*").test("poney.ts"), false); - assertEq(glob("unicorn.*").test("unicorn.py"), true); - assertEq(glob("*.ts").test("poney.ts"), true); - assertEq(glob("*.ts").test("unicorn.js"), false); - assertEq( + assertEquals(glob("unicorn.*") instanceof RegExp, true); + assertEquals(glob("unicorn.*").test("poney.ts"), false); + assertEquals(glob("unicorn.*").test("unicorn.py"), true); + assertEquals(glob("*.ts").test("poney.ts"), true); + assertEquals(glob("*.ts").test("unicorn.js"), false); + assertEquals( glob(join("unicorn", "**", "cathedral.ts")).test( join("unicorn", "in", "the", "cathedral.ts") ), true ); - assertEq( + assertEquals( glob(join("unicorn", "**", "cathedral.ts")).test( join("unicorn", "in", "the", "kitchen.ts") ), false ); - assertEq( + assertEquals( glob(join("unicorn", "**", "bathroom.*")).test( join("unicorn", "sleeping", "in", "bathroom.py") ), true ); - assertEq( + assertEquals( glob(join("unicorn", "!(sleeping)", "bathroom.ts"), { extended: true }).test(join("unicorn", "flying", "bathroom.ts")), true ); - assertEq( + assertEquals( glob(join("unicorn", "(!sleeping)", "bathroom.ts"), { extended: true }).test(join("unicorn", "sleeping", "bathroom.ts")), @@ -75,8 +75,8 @@ testWalk( }, async function globInWalk() { const arr = await walkArray(".", { match: [glob("*.ts")] }); - assertEq(arr.length, 1); - assertEq(arr[0], "./a/x.ts"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "./a/x.ts"); } ); @@ -90,9 +90,9 @@ testWalk( }, async function globInWalkWildcardFiles() { const arr = await walkArray(".", { match: [glob("*.ts")] }); - assertEq(arr.length, 2); - assertEq(arr[0], "./a/x.ts"); - assertEq(arr[1], "./b/z.ts"); + assertEquals(arr.length, 2); + assertEquals(arr[0], "./a/x.ts"); + assertEquals(arr[1], "./b/z.ts"); } ); @@ -111,8 +111,8 @@ testWalk( }) ] }); - assertEq(arr.length, 1); - assertEq(arr[0], "./a/yo/x.ts"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "./a/yo/x.ts"); } ); @@ -135,9 +135,9 @@ testWalk( }) ] }); - assertEq(arr.length, 2); - assertEq(arr[0], "./a/deno/x.ts"); - assertEq(arr[1], "./a/raptor/x.ts"); + assertEquals(arr.length, 2); + assertEquals(arr[0], "./a/deno/x.ts"); + assertEquals(arr[1], "./a/raptor/x.ts"); } ); @@ -152,8 +152,8 @@ testWalk( match: [glob("x.*", { flags: "g", globstar: true })] }); console.log(arr); - assertEq(arr.length, 2); - assertEq(arr[0], "./x.js"); - assertEq(arr[1], "./x.ts"); + assertEquals(arr.length, 2); + assertEquals(arr[0], "./x.js"); + assertEquals(arr[1], "./x.ts"); } ); diff --git a/fs/globrex_test.ts b/fs/globrex_test.ts index f84f3ac8c..3f645ce9b 100644 --- a/fs/globrex_test.ts +++ b/fs/globrex_test.ts @@ -4,11 +4,11 @@ import * as deno from "deno"; import { test } from "../testing/mod.ts"; -import { assertEq } from "../testing/asserts.ts"; +import { assertEquals } from "../testing/asserts.ts"; import { globrex } from "./globrex.ts"; const isWin = deno.platform.os === "win"; -const t = { equal: assertEq, is: assertEq }; +const t = { equal: assertEquals, is: assertEquals }; function match(glob, strUnix, strWin?, opts = {}) { if (typeof strWin === "object") { diff --git a/fs/path/basename_test.ts b/fs/path/basename_test.ts index b4b6f1303..f7770d1ca 100644 --- a/fs/path/basename_test.ts +++ b/fs/path/basename_test.ts @@ -2,72 +2,75 @@ // Ported from https://github.com/browserify/path-browserify/ import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; test(function basename() { - assertEq(path.basename(".js", ".js"), ""); - assertEq(path.basename(""), ""); - assertEq(path.basename("/dir/basename.ext"), "basename.ext"); - assertEq(path.basename("/basename.ext"), "basename.ext"); - assertEq(path.basename("basename.ext"), "basename.ext"); - assertEq(path.basename("basename.ext/"), "basename.ext"); - assertEq(path.basename("basename.ext//"), "basename.ext"); - assertEq(path.basename("aaa/bbb", "/bbb"), "bbb"); - assertEq(path.basename("aaa/bbb", "a/bbb"), "bbb"); - assertEq(path.basename("aaa/bbb", "bbb"), "bbb"); - assertEq(path.basename("aaa/bbb//", "bbb"), "bbb"); - assertEq(path.basename("aaa/bbb", "bb"), "b"); - assertEq(path.basename("aaa/bbb", "b"), "bb"); - assertEq(path.basename("/aaa/bbb", "/bbb"), "bbb"); - assertEq(path.basename("/aaa/bbb", "a/bbb"), "bbb"); - assertEq(path.basename("/aaa/bbb", "bbb"), "bbb"); - assertEq(path.basename("/aaa/bbb//", "bbb"), "bbb"); - assertEq(path.basename("/aaa/bbb", "bb"), "b"); - assertEq(path.basename("/aaa/bbb", "b"), "bb"); - assertEq(path.basename("/aaa/bbb"), "bbb"); - assertEq(path.basename("/aaa/"), "aaa"); - assertEq(path.basename("/aaa/b"), "b"); - assertEq(path.basename("/a/b"), "b"); - assertEq(path.basename("//a"), "a"); + assertEquals(path.basename(".js", ".js"), ""); + assertEquals(path.basename(""), ""); + assertEquals(path.basename("/dir/basename.ext"), "basename.ext"); + assertEquals(path.basename("/basename.ext"), "basename.ext"); + assertEquals(path.basename("basename.ext"), "basename.ext"); + assertEquals(path.basename("basename.ext/"), "basename.ext"); + assertEquals(path.basename("basename.ext//"), "basename.ext"); + assertEquals(path.basename("aaa/bbb", "/bbb"), "bbb"); + assertEquals(path.basename("aaa/bbb", "a/bbb"), "bbb"); + assertEquals(path.basename("aaa/bbb", "bbb"), "bbb"); + assertEquals(path.basename("aaa/bbb//", "bbb"), "bbb"); + assertEquals(path.basename("aaa/bbb", "bb"), "b"); + assertEquals(path.basename("aaa/bbb", "b"), "bb"); + assertEquals(path.basename("/aaa/bbb", "/bbb"), "bbb"); + assertEquals(path.basename("/aaa/bbb", "a/bbb"), "bbb"); + assertEquals(path.basename("/aaa/bbb", "bbb"), "bbb"); + assertEquals(path.basename("/aaa/bbb//", "bbb"), "bbb"); + assertEquals(path.basename("/aaa/bbb", "bb"), "b"); + assertEquals(path.basename("/aaa/bbb", "b"), "bb"); + assertEquals(path.basename("/aaa/bbb"), "bbb"); + assertEquals(path.basename("/aaa/"), "aaa"); + assertEquals(path.basename("/aaa/b"), "b"); + assertEquals(path.basename("/a/b"), "b"); + assertEquals(path.basename("//a"), "a"); // On unix a backslash is just treated as any other character. - assertEq(path.posix.basename("\\dir\\basename.ext"), "\\dir\\basename.ext"); - assertEq(path.posix.basename("\\basename.ext"), "\\basename.ext"); - assertEq(path.posix.basename("basename.ext"), "basename.ext"); - assertEq(path.posix.basename("basename.ext\\"), "basename.ext\\"); - assertEq(path.posix.basename("basename.ext\\\\"), "basename.ext\\\\"); - assertEq(path.posix.basename("foo"), "foo"); + assertEquals( + path.posix.basename("\\dir\\basename.ext"), + "\\dir\\basename.ext" + ); + assertEquals(path.posix.basename("\\basename.ext"), "\\basename.ext"); + assertEquals(path.posix.basename("basename.ext"), "basename.ext"); + assertEquals(path.posix.basename("basename.ext\\"), "basename.ext\\"); + assertEquals(path.posix.basename("basename.ext\\\\"), "basename.ext\\\\"); + assertEquals(path.posix.basename("foo"), "foo"); // POSIX filenames may include control characters const controlCharFilename = "Icon" + String.fromCharCode(13); - assertEq( + assertEquals( path.posix.basename("/a/b/" + controlCharFilename), controlCharFilename ); }); test(function basenameWin32() { - assertEq(path.win32.basename("\\dir\\basename.ext"), "basename.ext"); - assertEq(path.win32.basename("\\basename.ext"), "basename.ext"); - assertEq(path.win32.basename("basename.ext"), "basename.ext"); - assertEq(path.win32.basename("basename.ext\\"), "basename.ext"); - assertEq(path.win32.basename("basename.ext\\\\"), "basename.ext"); - assertEq(path.win32.basename("foo"), "foo"); - assertEq(path.win32.basename("aaa\\bbb", "\\bbb"), "bbb"); - assertEq(path.win32.basename("aaa\\bbb", "a\\bbb"), "bbb"); - assertEq(path.win32.basename("aaa\\bbb", "bbb"), "bbb"); - assertEq(path.win32.basename("aaa\\bbb\\\\\\\\", "bbb"), "bbb"); - assertEq(path.win32.basename("aaa\\bbb", "bb"), "b"); - assertEq(path.win32.basename("aaa\\bbb", "b"), "bb"); - assertEq(path.win32.basename("C:"), ""); - assertEq(path.win32.basename("C:."), "."); - assertEq(path.win32.basename("C:\\"), ""); - assertEq(path.win32.basename("C:\\dir\\base.ext"), "base.ext"); - assertEq(path.win32.basename("C:\\basename.ext"), "basename.ext"); - assertEq(path.win32.basename("C:basename.ext"), "basename.ext"); - assertEq(path.win32.basename("C:basename.ext\\"), "basename.ext"); - assertEq(path.win32.basename("C:basename.ext\\\\"), "basename.ext"); - assertEq(path.win32.basename("C:foo"), "foo"); - assertEq(path.win32.basename("file:stream"), "file:stream"); + assertEquals(path.win32.basename("\\dir\\basename.ext"), "basename.ext"); + assertEquals(path.win32.basename("\\basename.ext"), "basename.ext"); + assertEquals(path.win32.basename("basename.ext"), "basename.ext"); + assertEquals(path.win32.basename("basename.ext\\"), "basename.ext"); + assertEquals(path.win32.basename("basename.ext\\\\"), "basename.ext"); + assertEquals(path.win32.basename("foo"), "foo"); + assertEquals(path.win32.basename("aaa\\bbb", "\\bbb"), "bbb"); + assertEquals(path.win32.basename("aaa\\bbb", "a\\bbb"), "bbb"); + assertEquals(path.win32.basename("aaa\\bbb", "bbb"), "bbb"); + assertEquals(path.win32.basename("aaa\\bbb\\\\\\\\", "bbb"), "bbb"); + assertEquals(path.win32.basename("aaa\\bbb", "bb"), "b"); + assertEquals(path.win32.basename("aaa\\bbb", "b"), "bb"); + assertEquals(path.win32.basename("C:"), ""); + assertEquals(path.win32.basename("C:."), "."); + assertEquals(path.win32.basename("C:\\"), ""); + assertEquals(path.win32.basename("C:\\dir\\base.ext"), "base.ext"); + assertEquals(path.win32.basename("C:\\basename.ext"), "basename.ext"); + assertEquals(path.win32.basename("C:basename.ext"), "basename.ext"); + assertEquals(path.win32.basename("C:basename.ext\\"), "basename.ext"); + assertEquals(path.win32.basename("C:basename.ext\\\\"), "basename.ext"); + assertEquals(path.win32.basename("C:foo"), "foo"); + assertEquals(path.win32.basename("file:stream"), "file:stream"); }); diff --git a/fs/path/dirname_test.ts b/fs/path/dirname_test.ts index cf52f067d..047d4859b 100644 --- a/fs/path/dirname_test.ts +++ b/fs/path/dirname_test.ts @@ -2,61 +2,61 @@ // Ported from https://github.com/browserify/path-browserify/ import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; test(function dirname() { - assertEq(path.posix.dirname("/a/b/"), "/a"); - assertEq(path.posix.dirname("/a/b"), "/a"); - assertEq(path.posix.dirname("/a"), "/"); - assertEq(path.posix.dirname(""), "."); - assertEq(path.posix.dirname("/"), "/"); - assertEq(path.posix.dirname("////"), "/"); - assertEq(path.posix.dirname("//a"), "//"); - assertEq(path.posix.dirname("foo"), "."); + 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() { - assertEq(path.win32.dirname("c:\\"), "c:\\"); - assertEq(path.win32.dirname("c:\\foo"), "c:\\"); - assertEq(path.win32.dirname("c:\\foo\\"), "c:\\"); - assertEq(path.win32.dirname("c:\\foo\\bar"), "c:\\foo"); - assertEq(path.win32.dirname("c:\\foo\\bar\\"), "c:\\foo"); - assertEq(path.win32.dirname("c:\\foo\\bar\\baz"), "c:\\foo\\bar"); - assertEq(path.win32.dirname("\\"), "\\"); - assertEq(path.win32.dirname("\\foo"), "\\"); - assertEq(path.win32.dirname("\\foo\\"), "\\"); - assertEq(path.win32.dirname("\\foo\\bar"), "\\foo"); - assertEq(path.win32.dirname("\\foo\\bar\\"), "\\foo"); - assertEq(path.win32.dirname("\\foo\\bar\\baz"), "\\foo\\bar"); - assertEq(path.win32.dirname("c:"), "c:"); - assertEq(path.win32.dirname("c:foo"), "c:"); - assertEq(path.win32.dirname("c:foo\\"), "c:"); - assertEq(path.win32.dirname("c:foo\\bar"), "c:foo"); - assertEq(path.win32.dirname("c:foo\\bar\\"), "c:foo"); - assertEq(path.win32.dirname("c:foo\\bar\\baz"), "c:foo\\bar"); - assertEq(path.win32.dirname("file:stream"), "."); - assertEq(path.win32.dirname("dir\\file:stream"), "dir"); - assertEq(path.win32.dirname("\\\\unc\\share"), "\\\\unc\\share"); - assertEq(path.win32.dirname("\\\\unc\\share\\foo"), "\\\\unc\\share\\"); - assertEq(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\"); - assertEq( + 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" ); - assertEq( + assertEquals( path.win32.dirname("\\\\unc\\share\\foo\\bar\\"), "\\\\unc\\share\\foo" ); - assertEq( + assertEquals( path.win32.dirname("\\\\unc\\share\\foo\\bar\\baz"), "\\\\unc\\share\\foo\\bar" ); - assertEq(path.win32.dirname("/a/b/"), "/a"); - assertEq(path.win32.dirname("/a/b"), "/a"); - assertEq(path.win32.dirname("/a"), "/"); - assertEq(path.win32.dirname(""), "."); - assertEq(path.win32.dirname("/"), "/"); - assertEq(path.win32.dirname("////"), "/"); - assertEq(path.win32.dirname("foo"), "."); + 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"), "."); }); diff --git a/fs/path/extname_test.ts b/fs/path/extname_test.ts index 08f780e7d..336d6b0b2 100644 --- a/fs/path/extname_test.ts +++ b/fs/path/extname_test.ts @@ -2,7 +2,7 @@ // Ported from https://github.com/browserify/path-browserify/ import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; const slashRE = /\//g; @@ -56,35 +56,35 @@ test(function extname() { pairs.forEach(function(p) { const input = p[0]; const expected = p[1]; - assertEq(expected, path.posix.extname(input)); + assertEquals(expected, path.posix.extname(input)); }); // On *nix, backslash is a valid name component like any other character. - assertEq(path.posix.extname(".\\"), ""); - assertEq(path.posix.extname("..\\"), ".\\"); - assertEq(path.posix.extname("file.ext\\"), ".ext\\"); - assertEq(path.posix.extname("file.ext\\\\"), ".ext\\\\"); - assertEq(path.posix.extname("file\\"), ""); - assertEq(path.posix.extname("file\\\\"), ""); - assertEq(path.posix.extname("file.\\"), ".\\"); - assertEq(path.posix.extname("file.\\\\"), ".\\\\"); + assertEquals(path.posix.extname(".\\"), ""); + assertEquals(path.posix.extname("..\\"), ".\\"); + assertEquals(path.posix.extname("file.ext\\"), ".ext\\"); + assertEquals(path.posix.extname("file.ext\\\\"), ".ext\\\\"); + assertEquals(path.posix.extname("file\\"), ""); + assertEquals(path.posix.extname("file\\\\"), ""); + assertEquals(path.posix.extname("file.\\"), ".\\"); + assertEquals(path.posix.extname("file.\\\\"), ".\\\\"); }); test(function extnameWin32() { pairs.forEach(function(p) { const input = p[0].replace(slashRE, "\\"); const expected = p[1]; - assertEq(expected, path.win32.extname(input)); - assertEq(expected, path.win32.extname("C:" + input)); + assertEquals(expected, path.win32.extname(input)); + assertEquals(expected, path.win32.extname("C:" + input)); }); // On Windows, backslash is a path separator. - assertEq(path.win32.extname(".\\"), ""); - assertEq(path.win32.extname("..\\"), ""); - assertEq(path.win32.extname("file.ext\\"), ".ext"); - assertEq(path.win32.extname("file.ext\\\\"), ".ext"); - assertEq(path.win32.extname("file\\"), ""); - assertEq(path.win32.extname("file\\\\"), ""); - assertEq(path.win32.extname("file.\\"), "."); - assertEq(path.win32.extname("file.\\\\"), "."); + assertEquals(path.win32.extname(".\\"), ""); + assertEquals(path.win32.extname("..\\"), ""); + assertEquals(path.win32.extname("file.ext\\"), ".ext"); + assertEquals(path.win32.extname("file.ext\\\\"), ".ext"); + assertEquals(path.win32.extname("file\\"), ""); + assertEquals(path.win32.extname("file\\\\"), ""); + assertEquals(path.win32.extname("file.\\"), "."); + assertEquals(path.win32.extname("file.\\\\"), "."); }); diff --git a/fs/path/isabsolute_test.ts b/fs/path/isabsolute_test.ts index 7b262e354..87218a185 100644 --- a/fs/path/isabsolute_test.ts +++ b/fs/path/isabsolute_test.ts @@ -2,33 +2,33 @@ // Ported from https://github.com/browserify/path-browserify/ import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; test(function isAbsolute() { - assertEq(path.posix.isAbsolute("/home/foo"), true); - assertEq(path.posix.isAbsolute("/home/foo/.."), true); - assertEq(path.posix.isAbsolute("bar/"), false); - assertEq(path.posix.isAbsolute("./baz"), false); + 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); }); test(function isAbsoluteWin32() { - assertEq(path.win32.isAbsolute("/"), true); - assertEq(path.win32.isAbsolute("//"), true); - assertEq(path.win32.isAbsolute("//server"), true); - assertEq(path.win32.isAbsolute("//server/file"), true); - assertEq(path.win32.isAbsolute("\\\\server\\file"), true); - assertEq(path.win32.isAbsolute("\\\\server"), true); - assertEq(path.win32.isAbsolute("\\\\"), true); - assertEq(path.win32.isAbsolute("c"), false); - assertEq(path.win32.isAbsolute("c:"), false); - assertEq(path.win32.isAbsolute("c:\\"), true); - assertEq(path.win32.isAbsolute("c:/"), true); - assertEq(path.win32.isAbsolute("c://"), true); - assertEq(path.win32.isAbsolute("C:/Users/"), true); - assertEq(path.win32.isAbsolute("C:\\Users\\"), true); - assertEq(path.win32.isAbsolute("C:cwd/another"), false); - assertEq(path.win32.isAbsolute("C:cwd\\another"), false); - assertEq(path.win32.isAbsolute("directory/directory"), false); - assertEq(path.win32.isAbsolute("directory\\directory"), false); + 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); }); diff --git a/fs/path/join_test.ts b/fs/path/join_test.ts index acf5a8096..d82a1b471 100644 --- a/fs/path/join_test.ts +++ b/fs/path/join_test.ts @@ -1,5 +1,5 @@ import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; const backslashRE = /\\/g; @@ -109,17 +109,17 @@ const windowsJoinTests = [ test(function join() { joinTests.forEach(function(p) { const actual = path.posix.join.apply(null, p[0]); - assertEq(actual, p[1]); + assertEquals(actual, p[1]); }); }); test(function joinWin32() { joinTests.forEach(function(p) { const actual = path.win32.join.apply(null, p[0]).replace(backslashRE, "/"); - assertEq(actual, p[1]); + assertEquals(actual, p[1]); }); windowsJoinTests.forEach(function(p) { const actual = path.win32.join.apply(null, p[0]); - assertEq(actual, p[1]); + assertEquals(actual, p[1]); }); }); diff --git a/fs/path/parse_format_test.ts b/fs/path/parse_format_test.ts index 3bf3c462b..29d840453 100644 --- a/fs/path/parse_format_test.ts +++ b/fs/path/parse_format_test.ts @@ -2,7 +2,7 @@ // Ported from https://github.com/browserify/path-browserify/ import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; const winPaths = [ @@ -131,15 +131,15 @@ function checkParseFormat(path, paths) { paths.forEach(function(p) { const element = p[0]; const output = path.parse(element); - assertEq(typeof output.root, "string"); - assertEq(typeof output.dir, "string"); - assertEq(typeof output.base, "string"); - assertEq(typeof output.ext, "string"); - assertEq(typeof output.name, "string"); - assertEq(path.format(output), element); - assertEq(output.rooroot, undefined); - assertEq(output.dir, output.dir ? path.dirname(element) : ""); - assertEq(output.base, path.basename(element)); + assertEquals(typeof output.root, "string"); + assertEquals(typeof output.dir, "string"); + assertEquals(typeof output.base, "string"); + assertEquals(typeof output.ext, "string"); + assertEquals(typeof output.name, "string"); + assertEquals(path.format(output), element); + assertEquals(output.rooroot, undefined); + assertEquals(output.dir, output.dir ? path.dirname(element) : ""); + assertEquals(output.base, path.basename(element)); }); } @@ -149,14 +149,14 @@ function checkSpecialCaseParseFormat(path, testCases) { const expect = testCase[1]; const output = path.parse(element); Object.keys(expect).forEach(function(key) { - assertEq(output[key], expect[key]); + assertEquals(output[key], expect[key]); }); }); } function checkFormat(path, testCases) { testCases.forEach(function(testCase) { - assertEq(path.format(testCase[0]), testCase[1]); + assertEquals(path.format(testCase[0]), testCase[1]); }); } @@ -164,7 +164,7 @@ test(function parseTrailingWin32() { windowsTrailingTests.forEach(function(p) { const actual = path.win32.parse(p[0] as string); const expected = p[1]; - assertEq(actual, expected); + assertEquals(actual, expected); }); }); @@ -172,6 +172,6 @@ test(function parseTrailing() { posixTrailingTests.forEach(function(p) { const actual = path.posix.parse(p[0] as string); const expected = p[1]; - assertEq(actual, expected); + assertEquals(actual, expected); }); }); diff --git a/fs/path/relative_test.ts b/fs/path/relative_test.ts index 7a76c4578..0188b5368 100644 --- a/fs/path/relative_test.ts +++ b/fs/path/relative_test.ts @@ -2,7 +2,7 @@ // Ported from https://github.com/browserify/path-browserify/ import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; const relativeTests = { @@ -60,7 +60,7 @@ test(function relative() { relativeTests.posix.forEach(function(p) { const expected = p[2]; const actual = path.posix.relative(p[0], p[1]); - assertEq(actual, expected); + assertEquals(actual, expected); }); }); @@ -68,6 +68,6 @@ test(function relativeWin32() { relativeTests.win32.forEach(function(p) { const expected = p[2]; const actual = path.win32.relative(p[0], p[1]); - assertEq(actual, expected); + assertEquals(actual, expected); }); }); diff --git a/fs/path/resolve_test.ts b/fs/path/resolve_test.ts index 7243dc030..7ee9513c1 100644 --- a/fs/path/resolve_test.ts +++ b/fs/path/resolve_test.ts @@ -3,7 +3,7 @@ const { cwd } = Deno; import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; const windowsTests = @@ -38,13 +38,13 @@ const posixTests = test(function resolve() { posixTests.forEach(function(p) { const actual = path.posix.resolve.apply(null, p[0]); - assertEq(actual, p[1]); + assertEquals(actual, p[1]); }); }); test(function resolveWin32() { windowsTests.forEach(function(p) { const actual = path.win32.resolve.apply(null, p[0]); - assertEq(actual, p[1]); + assertEquals(actual, p[1]); }); }); diff --git a/fs/path/zero_length_strings_test.ts b/fs/path/zero_length_strings_test.ts index 469a0a7c0..20405563c 100644 --- a/fs/path/zero_length_strings_test.ts +++ b/fs/path/zero_length_strings_test.ts @@ -3,7 +3,7 @@ const { cwd } = Deno; import { test } from "../../testing/mod.ts"; -import { assertEq } from "../../testing/asserts.ts"; +import { assertEquals } from "../../testing/asserts.ts"; import * as path from "./mod.ts"; const pwd = cwd(); @@ -11,37 +11,37 @@ const pwd = cwd(); test(function joinZeroLength() { // join will internally ignore all the zero-length strings and it will return // '.' if the joined string is a zero-length string. - assertEq(path.posix.join(""), "."); - assertEq(path.posix.join("", ""), "."); - if (path.win32) assertEq(path.win32.join(""), "."); - if (path.win32) assertEq(path.win32.join("", ""), "."); - assertEq(path.join(pwd), pwd); - assertEq(path.join(pwd, ""), pwd); + assertEquals(path.posix.join(""), "."); + assertEquals(path.posix.join("", ""), "."); + if (path.win32) assertEquals(path.win32.join(""), "."); + if (path.win32) assertEquals(path.win32.join("", ""), "."); + assertEquals(path.join(pwd), pwd); + assertEquals(path.join(pwd, ""), pwd); }); test(function normalizeZeroLength() { // normalize will return '.' if the input is a zero-length string - assertEq(path.posix.normalize(""), "."); - if (path.win32) assertEq(path.win32.normalize(""), "."); - assertEq(path.normalize(pwd), pwd); + assertEquals(path.posix.normalize(""), "."); + if (path.win32) assertEquals(path.win32.normalize(""), "."); + assertEquals(path.normalize(pwd), pwd); }); test(function isAbsoluteZeroLength() { // Since '' is not a valid path in any of the common environments, return false - assertEq(path.posix.isAbsolute(""), false); - if (path.win32) assertEq(path.win32.isAbsolute(""), false); + assertEquals(path.posix.isAbsolute(""), false); + if (path.win32) assertEquals(path.win32.isAbsolute(""), false); }); test(function resolveZeroLength() { // resolve, internally ignores all the zero-length strings and returns the // current working directory - assertEq(path.resolve(""), pwd); - assertEq(path.resolve("", ""), pwd); + assertEquals(path.resolve(""), pwd); + assertEquals(path.resolve("", ""), pwd); }); test(function relativeZeroLength() { // relative, internally calls resolve. So, '' is actually the current directory - assertEq(path.relative("", pwd), ""); - assertEq(path.relative(pwd, ""), ""); - assertEq(path.relative(pwd, pwd), ""); + assertEquals(path.relative("", pwd), ""); + assertEquals(path.relative(pwd, ""), ""); + assertEquals(path.relative(pwd, pwd), ""); }); diff --git a/fs/walk_test.ts b/fs/walk_test.ts index 00a0c567e..8391f51d7 100644 --- a/fs/walk_test.ts +++ b/fs/walk_test.ts @@ -11,7 +11,7 @@ const { import { FileInfo } from "deno"; import { walk, walkSync, WalkOptions } from "./walk.ts"; import { test, TestFunction } from "../testing/mod.ts"; -import { assert, assertEq } from "../testing/asserts.ts"; +import { assert, assertEquals } from "../testing/asserts.ts"; const isWindows = platform.os === "win"; @@ -47,7 +47,7 @@ async function walkArray( const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) => f.path.replace(/\\/g, "/") ).sort(); - assertEq(arr, arr_sync); + assertEquals(arr, arr_sync); return arr; } @@ -56,7 +56,7 @@ async function touch(path: string): Promise<void> { } function assertReady(expectedLength: number) { const arr = Array.from(walkSync(), (f: FileInfo) => f.path); - assertEq(arr.length, expectedLength); + assertEquals(arr.length, expectedLength); } testWalk( @@ -65,7 +65,7 @@ testWalk( }, async function emptyDir() { const arr = await walkArray(); - assertEq(arr.length, 0); + assertEquals(arr.length, 0); } ); @@ -75,8 +75,8 @@ testWalk( }, async function singleFile() { const arr = await walkArray(); - assertEq(arr.length, 1); - assertEq(arr[0], "./x"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "./x"); } ); @@ -89,11 +89,11 @@ testWalk( for (const f of walkSync()) { count += 1; } - assertEq(count, 1); + assertEquals(count, 1); for await (const f of walk()) { count += 1; } - assertEq(count, 2); + assertEquals(count, 2); } ); @@ -104,8 +104,8 @@ testWalk( }, async function nestedSingleFile() { const arr = await walkArray(); - assertEq(arr.length, 1); - assertEq(arr[0], "./a/x"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "./a/x"); } ); @@ -117,10 +117,10 @@ testWalk( async function depth() { assertReady(1); const arr_3 = await walkArray(".", { maxDepth: 3 }); - assertEq(arr_3.length, 0); + assertEquals(arr_3.length, 0); const arr_5 = await walkArray(".", { maxDepth: 5 }); - assertEq(arr_5.length, 1); - assertEq(arr_5[0], "./a/b/c/d/x"); + assertEquals(arr_5.length, 1); + assertEquals(arr_5[0], "./a/b/c/d/x"); } ); @@ -132,8 +132,8 @@ testWalk( async function ext() { assertReady(2); const arr = await walkArray(".", { exts: [".ts"] }); - assertEq(arr.length, 1); - assertEq(arr[0], "./x.ts"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "./x.ts"); } ); @@ -146,9 +146,9 @@ testWalk( async function extAny() { assertReady(3); const arr = await walkArray(".", { exts: [".rs", ".ts"] }); - assertEq(arr.length, 2); - assertEq(arr[0], "./x.ts"); - assertEq(arr[1], "./y.rs"); + assertEquals(arr.length, 2); + assertEquals(arr[0], "./x.ts"); + assertEquals(arr[1], "./y.rs"); } ); @@ -160,8 +160,8 @@ testWalk( async function match() { assertReady(2); const arr = await walkArray(".", { match: [/x/] }); - assertEq(arr.length, 1); - assertEq(arr[0], "./x"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "./x"); } ); @@ -174,9 +174,9 @@ testWalk( async function matchAny() { assertReady(3); const arr = await walkArray(".", { match: [/x/, /y/] }); - assertEq(arr.length, 2); - assertEq(arr[0], "./x"); - assertEq(arr[1], "./y"); + assertEquals(arr.length, 2); + assertEquals(arr[0], "./x"); + assertEquals(arr[1], "./y"); } ); @@ -188,8 +188,8 @@ testWalk( async function skip() { assertReady(2); const arr = await walkArray(".", { skip: [/x/] }); - assertEq(arr.length, 1); - assertEq(arr[0], "./y"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "./y"); } ); @@ -202,8 +202,8 @@ testWalk( async function skipAny() { assertReady(3); const arr = await walkArray(".", { skip: [/x/, /y/] }); - assertEq(arr.length, 1); - assertEq(arr[0], "./z"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "./z"); } ); @@ -218,19 +218,19 @@ testWalk( async function subDir() { assertReady(3); const arr = await walkArray("b"); - assertEq(arr.length, 1); - assertEq(arr[0], "b/z"); + assertEquals(arr.length, 1); + assertEquals(arr[0], "b/z"); } ); testWalk(async (d: string) => {}, async function onError() { assertReady(0); const ignored = await walkArray("missing"); - assertEq(ignored.length, 0); + assertEquals(ignored.length, 0); let errors = 0; const arr = await walkArray("missing", { onError: e => (errors += 1) }); // It's 2 since walkArray iterates over both sync and async. - assertEq(errors, 2); + assertEquals(errors, 2); }); testWalk( @@ -255,11 +255,11 @@ testWalk( assertReady(3); const files = await walkArray("a"); - assertEq(files.length, 2); + assertEquals(files.length, 2); assert(!files.includes("a/bb/z")); const arr = await walkArray("a", { followSymlinks: true }); - assertEq(arr.length, 3); + assertEquals(arr.length, 3); assert(arr.some(f => f.endsWith("/b/z"))); } ); |
