summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/glob_test.ts51
-rw-r--r--fs/globrex_test.ts5
-rw-r--r--fs/path/basename_test.ts112
-rw-r--r--fs/path/dirname_test.ts85
-rw-r--r--fs/path/extname_test.ts41
-rw-r--r--fs/path/isabsolute_test.ts47
-rw-r--r--fs/path/join_test.ts9
-rw-r--r--fs/path/parse_format_test.ts29
-rw-r--r--fs/path/relative_test.ts7
-rw-r--r--fs/path/resolve_test.ts7
-rw-r--r--fs/path/zero_length_strings_test.ts35
-rw-r--r--fs/walk_test.ts67
12 files changed, 252 insertions, 243 deletions
diff --git a/fs/glob_test.ts b/fs/glob_test.ts
index bd5e2543c..97f5d102e 100644
--- a/fs/glob_test.ts
+++ b/fs/glob_test.ts
@@ -1,6 +1,7 @@
const { mkdir, open } = Deno;
import { FileInfo } from "deno";
-import { test, assert } from "../testing/mod.ts";
+import { test } from "../testing/mod.ts";
+import { assertEq } from "../testing/asserts.ts";
import { glob } from "./glob.ts";
import { join } from "./path.ts";
import { testWalk } from "./walk_test.ts";
@@ -22,43 +23,43 @@ async function walkArray(
const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) =>
f.path.replace(/\\/g, "/")
).sort();
- assert.equal(arr, arr_sync);
+ assertEq(arr, arr_sync);
return arr;
}
test({
name: "glob: glob to regex",
fn() {
- assert.equal(glob("unicorn.*") instanceof RegExp, true);
- assert.equal(glob("unicorn.*").test("poney.ts"), false);
- assert.equal(glob("unicorn.*").test("unicorn.py"), true);
- assert.equal(glob("*.ts").test("poney.ts"), true);
- assert.equal(glob("*.ts").test("unicorn.js"), false);
- assert.equal(
+ 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(
glob(join("unicorn", "**", "cathedral.ts")).test(
join("unicorn", "in", "the", "cathedral.ts")
),
true
);
- assert.equal(
+ assertEq(
glob(join("unicorn", "**", "cathedral.ts")).test(
join("unicorn", "in", "the", "kitchen.ts")
),
false
);
- assert.equal(
+ assertEq(
glob(join("unicorn", "**", "bathroom.*")).test(
join("unicorn", "sleeping", "in", "bathroom.py")
),
true
);
- assert.equal(
+ assertEq(
glob(join("unicorn", "!(sleeping)", "bathroom.ts"), {
extended: true
}).test(join("unicorn", "flying", "bathroom.ts")),
true
);
- assert.equal(
+ assertEq(
glob(join("unicorn", "(!sleeping)", "bathroom.ts"), {
extended: true
}).test(join("unicorn", "sleeping", "bathroom.ts")),
@@ -74,8 +75,8 @@ testWalk(
},
async function globInWalk() {
const arr = await walkArray(".", { match: [glob("*.ts")] });
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "./a/x.ts");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "./a/x.ts");
}
);
@@ -89,9 +90,9 @@ testWalk(
},
async function globInWalkWildcardFiles() {
const arr = await walkArray(".", { match: [glob("*.ts")] });
- assert.equal(arr.length, 2);
- assert.equal(arr[0], "./a/x.ts");
- assert.equal(arr[1], "./b/z.ts");
+ assertEq(arr.length, 2);
+ assertEq(arr[0], "./a/x.ts");
+ assertEq(arr[1], "./b/z.ts");
}
);
@@ -110,8 +111,8 @@ testWalk(
})
]
});
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "./a/yo/x.ts");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "./a/yo/x.ts");
}
);
@@ -134,9 +135,9 @@ testWalk(
})
]
});
- assert.equal(arr.length, 2);
- assert.equal(arr[0], "./a/deno/x.ts");
- assert.equal(arr[1], "./a/raptor/x.ts");
+ assertEq(arr.length, 2);
+ assertEq(arr[0], "./a/deno/x.ts");
+ assertEq(arr[1], "./a/raptor/x.ts");
}
);
@@ -151,8 +152,8 @@ testWalk(
match: [glob("x.*", { flags: "g", globstar: true })]
});
console.log(arr);
- assert.equal(arr.length, 2);
- assert.equal(arr[0], "./x.js");
- assert.equal(arr[1], "./x.ts");
+ assertEq(arr.length, 2);
+ assertEq(arr[0], "./x.js");
+ assertEq(arr[1], "./x.ts");
}
);
diff --git a/fs/globrex_test.ts b/fs/globrex_test.ts
index 8f97f2897..f84f3ac8c 100644
--- a/fs/globrex_test.ts
+++ b/fs/globrex_test.ts
@@ -3,11 +3,12 @@
// Copyright (c) 2018 Terkel Gjervig Nielsen
import * as deno from "deno";
-import { test, assert } from "../testing/mod.ts";
+import { test } from "../testing/mod.ts";
+import { assertEq } from "../testing/asserts.ts";
import { globrex } from "./globrex.ts";
const isWin = deno.platform.os === "win";
-const t = { equal: assert.equal, is: assert.equal };
+const t = { equal: assertEq, is: assertEq };
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 ffe9e051c..b4b6f1303 100644
--- a/fs/path/basename_test.ts
+++ b/fs/path/basename_test.ts
@@ -1,75 +1,73 @@
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
test(function basename() {
- assertEqual(path.basename(".js", ".js"), "");
- assertEqual(path.basename(""), "");
- assertEqual(path.basename("/dir/basename.ext"), "basename.ext");
- assertEqual(path.basename("/basename.ext"), "basename.ext");
- assertEqual(path.basename("basename.ext"), "basename.ext");
- assertEqual(path.basename("basename.ext/"), "basename.ext");
- assertEqual(path.basename("basename.ext//"), "basename.ext");
- assertEqual(path.basename("aaa/bbb", "/bbb"), "bbb");
- assertEqual(path.basename("aaa/bbb", "a/bbb"), "bbb");
- assertEqual(path.basename("aaa/bbb", "bbb"), "bbb");
- assertEqual(path.basename("aaa/bbb//", "bbb"), "bbb");
- assertEqual(path.basename("aaa/bbb", "bb"), "b");
- assertEqual(path.basename("aaa/bbb", "b"), "bb");
- assertEqual(path.basename("/aaa/bbb", "/bbb"), "bbb");
- assertEqual(path.basename("/aaa/bbb", "a/bbb"), "bbb");
- assertEqual(path.basename("/aaa/bbb", "bbb"), "bbb");
- assertEqual(path.basename("/aaa/bbb//", "bbb"), "bbb");
- assertEqual(path.basename("/aaa/bbb", "bb"), "b");
- assertEqual(path.basename("/aaa/bbb", "b"), "bb");
- assertEqual(path.basename("/aaa/bbb"), "bbb");
- assertEqual(path.basename("/aaa/"), "aaa");
- assertEqual(path.basename("/aaa/b"), "b");
- assertEqual(path.basename("/a/b"), "b");
- assertEqual(path.basename("//a"), "a");
+ 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");
// On unix a backslash is just treated as any other character.
- assertEqual(
- path.posix.basename("\\dir\\basename.ext"),
- "\\dir\\basename.ext"
- );
- assertEqual(path.posix.basename("\\basename.ext"), "\\basename.ext");
- assertEqual(path.posix.basename("basename.ext"), "basename.ext");
- assertEqual(path.posix.basename("basename.ext\\"), "basename.ext\\");
- assertEqual(path.posix.basename("basename.ext\\\\"), "basename.ext\\\\");
- assertEqual(path.posix.basename("foo"), "foo");
+ 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");
// POSIX filenames may include control characters
const controlCharFilename = "Icon" + String.fromCharCode(13);
- assertEqual(
+ assertEq(
path.posix.basename("/a/b/" + controlCharFilename),
controlCharFilename
);
});
test(function basenameWin32() {
- assertEqual(path.win32.basename("\\dir\\basename.ext"), "basename.ext");
- assertEqual(path.win32.basename("\\basename.ext"), "basename.ext");
- assertEqual(path.win32.basename("basename.ext"), "basename.ext");
- assertEqual(path.win32.basename("basename.ext\\"), "basename.ext");
- assertEqual(path.win32.basename("basename.ext\\\\"), "basename.ext");
- assertEqual(path.win32.basename("foo"), "foo");
- assertEqual(path.win32.basename("aaa\\bbb", "\\bbb"), "bbb");
- assertEqual(path.win32.basename("aaa\\bbb", "a\\bbb"), "bbb");
- assertEqual(path.win32.basename("aaa\\bbb", "bbb"), "bbb");
- assertEqual(path.win32.basename("aaa\\bbb\\\\\\\\", "bbb"), "bbb");
- assertEqual(path.win32.basename("aaa\\bbb", "bb"), "b");
- assertEqual(path.win32.basename("aaa\\bbb", "b"), "bb");
- assertEqual(path.win32.basename("C:"), "");
- assertEqual(path.win32.basename("C:."), ".");
- assertEqual(path.win32.basename("C:\\"), "");
- assertEqual(path.win32.basename("C:\\dir\\base.ext"), "base.ext");
- assertEqual(path.win32.basename("C:\\basename.ext"), "basename.ext");
- assertEqual(path.win32.basename("C:basename.ext"), "basename.ext");
- assertEqual(path.win32.basename("C:basename.ext\\"), "basename.ext");
- assertEqual(path.win32.basename("C:basename.ext\\\\"), "basename.ext");
- assertEqual(path.win32.basename("C:foo"), "foo");
- assertEqual(path.win32.basename("file:stream"), "file:stream");
+ 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");
});
diff --git a/fs/path/dirname_test.ts b/fs/path/dirname_test.ts
index 5613d6d2c..cf52f067d 100644
--- a/fs/path/dirname_test.ts
+++ b/fs/path/dirname_test.ts
@@ -1,61 +1,62 @@
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
test(function dirname() {
- assertEqual(path.posix.dirname("/a/b/"), "/a");
- assertEqual(path.posix.dirname("/a/b"), "/a");
- assertEqual(path.posix.dirname("/a"), "/");
- assertEqual(path.posix.dirname(""), ".");
- assertEqual(path.posix.dirname("/"), "/");
- assertEqual(path.posix.dirname("////"), "/");
- assertEqual(path.posix.dirname("//a"), "//");
- assertEqual(path.posix.dirname("foo"), ".");
+ 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"), ".");
});
test(function dirnameWin32() {
- assertEqual(path.win32.dirname("c:\\"), "c:\\");
- assertEqual(path.win32.dirname("c:\\foo"), "c:\\");
- assertEqual(path.win32.dirname("c:\\foo\\"), "c:\\");
- assertEqual(path.win32.dirname("c:\\foo\\bar"), "c:\\foo");
- assertEqual(path.win32.dirname("c:\\foo\\bar\\"), "c:\\foo");
- assertEqual(path.win32.dirname("c:\\foo\\bar\\baz"), "c:\\foo\\bar");
- assertEqual(path.win32.dirname("\\"), "\\");
- assertEqual(path.win32.dirname("\\foo"), "\\");
- assertEqual(path.win32.dirname("\\foo\\"), "\\");
- assertEqual(path.win32.dirname("\\foo\\bar"), "\\foo");
- assertEqual(path.win32.dirname("\\foo\\bar\\"), "\\foo");
- assertEqual(path.win32.dirname("\\foo\\bar\\baz"), "\\foo\\bar");
- assertEqual(path.win32.dirname("c:"), "c:");
- assertEqual(path.win32.dirname("c:foo"), "c:");
- assertEqual(path.win32.dirname("c:foo\\"), "c:");
- assertEqual(path.win32.dirname("c:foo\\bar"), "c:foo");
- assertEqual(path.win32.dirname("c:foo\\bar\\"), "c:foo");
- assertEqual(path.win32.dirname("c:foo\\bar\\baz"), "c:foo\\bar");
- assertEqual(path.win32.dirname("file:stream"), ".");
- assertEqual(path.win32.dirname("dir\\file:stream"), "dir");
- assertEqual(path.win32.dirname("\\\\unc\\share"), "\\\\unc\\share");
- assertEqual(path.win32.dirname("\\\\unc\\share\\foo"), "\\\\unc\\share\\");
- assertEqual(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\");
- assertEqual(
+ 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(
path.win32.dirname("\\\\unc\\share\\foo\\bar"),
"\\\\unc\\share\\foo"
);
- assertEqual(
+ assertEq(
path.win32.dirname("\\\\unc\\share\\foo\\bar\\"),
"\\\\unc\\share\\foo"
);
- assertEqual(
+ assertEq(
path.win32.dirname("\\\\unc\\share\\foo\\bar\\baz"),
"\\\\unc\\share\\foo\\bar"
);
- assertEqual(path.win32.dirname("/a/b/"), "/a");
- assertEqual(path.win32.dirname("/a/b"), "/a");
- assertEqual(path.win32.dirname("/a"), "/");
- assertEqual(path.win32.dirname(""), ".");
- assertEqual(path.win32.dirname("/"), "/");
- assertEqual(path.win32.dirname("////"), "/");
- assertEqual(path.win32.dirname("foo"), ".");
+ 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"), ".");
});
diff --git a/fs/path/extname_test.ts b/fs/path/extname_test.ts
index 63d473d34..08f780e7d 100644
--- a/fs/path/extname_test.ts
+++ b/fs/path/extname_test.ts
@@ -1,7 +1,8 @@
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
const slashRE = /\//g;
@@ -55,35 +56,35 @@ test(function extname() {
pairs.forEach(function(p) {
const input = p[0];
const expected = p[1];
- assertEqual(expected, path.posix.extname(input));
+ assertEq(expected, path.posix.extname(input));
});
// On *nix, backslash is a valid name component like any other character.
- assertEqual(path.posix.extname(".\\"), "");
- assertEqual(path.posix.extname("..\\"), ".\\");
- assertEqual(path.posix.extname("file.ext\\"), ".ext\\");
- assertEqual(path.posix.extname("file.ext\\\\"), ".ext\\\\");
- assertEqual(path.posix.extname("file\\"), "");
- assertEqual(path.posix.extname("file\\\\"), "");
- assertEqual(path.posix.extname("file.\\"), ".\\");
- assertEqual(path.posix.extname("file.\\\\"), ".\\\\");
+ 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.\\\\"), ".\\\\");
});
test(function extnameWin32() {
pairs.forEach(function(p) {
const input = p[0].replace(slashRE, "\\");
const expected = p[1];
- assertEqual(expected, path.win32.extname(input));
- assertEqual(expected, path.win32.extname("C:" + input));
+ assertEq(expected, path.win32.extname(input));
+ assertEq(expected, path.win32.extname("C:" + input));
});
// On Windows, backslash is a path separator.
- assertEqual(path.win32.extname(".\\"), "");
- assertEqual(path.win32.extname("..\\"), "");
- assertEqual(path.win32.extname("file.ext\\"), ".ext");
- assertEqual(path.win32.extname("file.ext\\\\"), ".ext");
- assertEqual(path.win32.extname("file\\"), "");
- assertEqual(path.win32.extname("file\\\\"), "");
- assertEqual(path.win32.extname("file.\\"), ".");
- assertEqual(path.win32.extname("file.\\\\"), ".");
+ 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.\\\\"), ".");
});
diff --git a/fs/path/isabsolute_test.ts b/fs/path/isabsolute_test.ts
index 9591b8045..7b262e354 100644
--- a/fs/path/isabsolute_test.ts
+++ b/fs/path/isabsolute_test.ts
@@ -1,33 +1,34 @@
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
test(function isAbsolute() {
- assertEqual(path.posix.isAbsolute("/home/foo"), true);
- assertEqual(path.posix.isAbsolute("/home/foo/.."), true);
- assertEqual(path.posix.isAbsolute("bar/"), false);
- assertEqual(path.posix.isAbsolute("./baz"), false);
+ 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);
});
test(function isAbsoluteWin32() {
- assertEqual(path.win32.isAbsolute("/"), true);
- assertEqual(path.win32.isAbsolute("//"), true);
- assertEqual(path.win32.isAbsolute("//server"), true);
- assertEqual(path.win32.isAbsolute("//server/file"), true);
- assertEqual(path.win32.isAbsolute("\\\\server\\file"), true);
- assertEqual(path.win32.isAbsolute("\\\\server"), true);
- assertEqual(path.win32.isAbsolute("\\\\"), true);
- assertEqual(path.win32.isAbsolute("c"), false);
- assertEqual(path.win32.isAbsolute("c:"), false);
- assertEqual(path.win32.isAbsolute("c:\\"), true);
- assertEqual(path.win32.isAbsolute("c:/"), true);
- assertEqual(path.win32.isAbsolute("c://"), true);
- assertEqual(path.win32.isAbsolute("C:/Users/"), true);
- assertEqual(path.win32.isAbsolute("C:\\Users\\"), true);
- assertEqual(path.win32.isAbsolute("C:cwd/another"), false);
- assertEqual(path.win32.isAbsolute("C:cwd\\another"), false);
- assertEqual(path.win32.isAbsolute("directory/directory"), false);
- assertEqual(path.win32.isAbsolute("directory\\directory"), false);
+ 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);
});
diff --git a/fs/path/join_test.ts b/fs/path/join_test.ts
index 2051dbdaa..acf5a8096 100644
--- a/fs/path/join_test.ts
+++ b/fs/path/join_test.ts
@@ -1,4 +1,5 @@
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
const backslashRE = /\\/g;
@@ -108,17 +109,17 @@ const windowsJoinTests = [
test(function join() {
joinTests.forEach(function(p) {
const actual = path.posix.join.apply(null, p[0]);
- assertEqual(actual, p[1]);
+ assertEq(actual, p[1]);
});
});
test(function joinWin32() {
joinTests.forEach(function(p) {
const actual = path.win32.join.apply(null, p[0]).replace(backslashRE, "/");
- assertEqual(actual, p[1]);
+ assertEq(actual, p[1]);
});
windowsJoinTests.forEach(function(p) {
const actual = path.win32.join.apply(null, p[0]);
- assertEqual(actual, p[1]);
+ assertEq(actual, p[1]);
});
});
diff --git a/fs/path/parse_format_test.ts b/fs/path/parse_format_test.ts
index 8b429ce24..3bf3c462b 100644
--- a/fs/path/parse_format_test.ts
+++ b/fs/path/parse_format_test.ts
@@ -1,7 +1,8 @@
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
const winPaths = [
@@ -130,15 +131,15 @@ function checkParseFormat(path, paths) {
paths.forEach(function(p) {
const element = p[0];
const output = path.parse(element);
- assertEqual(typeof output.root, "string");
- assertEqual(typeof output.dir, "string");
- assertEqual(typeof output.base, "string");
- assertEqual(typeof output.ext, "string");
- assertEqual(typeof output.name, "string");
- assertEqual(path.format(output), element);
- assertEqual(output.rooroot, undefined);
- assertEqual(output.dir, output.dir ? path.dirname(element) : "");
- assertEqual(output.base, path.basename(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));
});
}
@@ -148,14 +149,14 @@ function checkSpecialCaseParseFormat(path, testCases) {
const expect = testCase[1];
const output = path.parse(element);
Object.keys(expect).forEach(function(key) {
- assertEqual(output[key], expect[key]);
+ assertEq(output[key], expect[key]);
});
});
}
function checkFormat(path, testCases) {
testCases.forEach(function(testCase) {
- assertEqual(path.format(testCase[0]), testCase[1]);
+ assertEq(path.format(testCase[0]), testCase[1]);
});
}
@@ -163,7 +164,7 @@ test(function parseTrailingWin32() {
windowsTrailingTests.forEach(function(p) {
const actual = path.win32.parse(p[0] as string);
const expected = p[1];
- assertEqual(actual, expected);
+ assertEq(actual, expected);
});
});
@@ -171,6 +172,6 @@ test(function parseTrailing() {
posixTrailingTests.forEach(function(p) {
const actual = path.posix.parse(p[0] as string);
const expected = p[1];
- assertEqual(actual, expected);
+ assertEq(actual, expected);
});
});
diff --git a/fs/path/relative_test.ts b/fs/path/relative_test.ts
index 87e308b43..7a76c4578 100644
--- a/fs/path/relative_test.ts
+++ b/fs/path/relative_test.ts
@@ -1,7 +1,8 @@
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
const relativeTests = {
@@ -59,7 +60,7 @@ test(function relative() {
relativeTests.posix.forEach(function(p) {
const expected = p[2];
const actual = path.posix.relative(p[0], p[1]);
- assertEqual(actual, expected);
+ assertEq(actual, expected);
});
});
@@ -67,6 +68,6 @@ test(function relativeWin32() {
relativeTests.win32.forEach(function(p) {
const expected = p[2];
const actual = path.win32.relative(p[0], p[1]);
- assertEqual(actual, expected);
+ assertEq(actual, expected);
});
});
diff --git a/fs/path/resolve_test.ts b/fs/path/resolve_test.ts
index 2259dd025..7243dc030 100644
--- a/fs/path/resolve_test.ts
+++ b/fs/path/resolve_test.ts
@@ -2,7 +2,8 @@
// Ported from https://github.com/browserify/path-browserify/
const { cwd } = Deno;
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
const windowsTests =
@@ -37,13 +38,13 @@ const posixTests =
test(function resolve() {
posixTests.forEach(function(p) {
const actual = path.posix.resolve.apply(null, p[0]);
- assertEqual(actual, p[1]);
+ assertEq(actual, p[1]);
});
});
test(function resolveWin32() {
windowsTests.forEach(function(p) {
const actual = path.win32.resolve.apply(null, p[0]);
- assertEqual(actual, p[1]);
+ assertEq(actual, p[1]);
});
});
diff --git a/fs/path/zero_length_strings_test.ts b/fs/path/zero_length_strings_test.ts
index c769c9a79..469a0a7c0 100644
--- a/fs/path/zero_length_strings_test.ts
+++ b/fs/path/zero_length_strings_test.ts
@@ -2,7 +2,8 @@
// Ported from https://github.com/browserify/path-browserify/
const { cwd } = Deno;
-import { test, assertEqual } from "../../testing/mod.ts";
+import { test } from "../../testing/mod.ts";
+import { assertEq } from "../../testing/asserts.ts";
import * as path from "./mod.ts";
const pwd = cwd();
@@ -10,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.
- assertEqual(path.posix.join(""), ".");
- assertEqual(path.posix.join("", ""), ".");
- if (path.win32) assertEqual(path.win32.join(""), ".");
- if (path.win32) assertEqual(path.win32.join("", ""), ".");
- assertEqual(path.join(pwd), pwd);
- assertEqual(path.join(pwd, ""), pwd);
+ 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);
});
test(function normalizeZeroLength() {
// normalize will return '.' if the input is a zero-length string
- assertEqual(path.posix.normalize(""), ".");
- if (path.win32) assertEqual(path.win32.normalize(""), ".");
- assertEqual(path.normalize(pwd), pwd);
+ assertEq(path.posix.normalize(""), ".");
+ if (path.win32) assertEq(path.win32.normalize(""), ".");
+ assertEq(path.normalize(pwd), pwd);
});
test(function isAbsoluteZeroLength() {
// Since '' is not a valid path in any of the common environments, return false
- assertEqual(path.posix.isAbsolute(""), false);
- if (path.win32) assertEqual(path.win32.isAbsolute(""), false);
+ assertEq(path.posix.isAbsolute(""), false);
+ if (path.win32) assertEq(path.win32.isAbsolute(""), false);
});
test(function resolveZeroLength() {
// resolve, internally ignores all the zero-length strings and returns the
// current working directory
- assertEqual(path.resolve(""), pwd);
- assertEqual(path.resolve("", ""), pwd);
+ assertEq(path.resolve(""), pwd);
+ assertEq(path.resolve("", ""), pwd);
});
test(function relativeZeroLength() {
// relative, internally calls resolve. So, '' is actually the current directory
- assertEqual(path.relative("", pwd), "");
- assertEqual(path.relative(pwd, ""), "");
- assertEqual(path.relative(pwd, pwd), "");
+ assertEq(path.relative("", pwd), "");
+ assertEq(path.relative(pwd, ""), "");
+ assertEq(path.relative(pwd, pwd), "");
});
diff --git a/fs/walk_test.ts b/fs/walk_test.ts
index f78765b1d..00a0c567e 100644
--- a/fs/walk_test.ts
+++ b/fs/walk_test.ts
@@ -10,7 +10,8 @@ const {
} = Deno;
import { FileInfo } from "deno";
import { walk, walkSync, WalkOptions } from "./walk.ts";
-import { test, assert, TestFunction } from "../testing/mod.ts";
+import { test, TestFunction } from "../testing/mod.ts";
+import { assert, assertEq } from "../testing/asserts.ts";
const isWindows = platform.os === "win";
@@ -46,7 +47,7 @@ async function walkArray(
const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) =>
f.path.replace(/\\/g, "/")
).sort();
- assert.equal(arr, arr_sync);
+ assertEq(arr, arr_sync);
return arr;
}
@@ -55,7 +56,7 @@ async function touch(path: string): Promise<void> {
}
function assertReady(expectedLength: number) {
const arr = Array.from(walkSync(), (f: FileInfo) => f.path);
- assert.equal(arr.length, expectedLength);
+ assertEq(arr.length, expectedLength);
}
testWalk(
@@ -64,7 +65,7 @@ testWalk(
},
async function emptyDir() {
const arr = await walkArray();
- assert.equal(arr.length, 0);
+ assertEq(arr.length, 0);
}
);
@@ -74,8 +75,8 @@ testWalk(
},
async function singleFile() {
const arr = await walkArray();
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "./x");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "./x");
}
);
@@ -88,11 +89,11 @@ testWalk(
for (const f of walkSync()) {
count += 1;
}
- assert.equal(count, 1);
+ assertEq(count, 1);
for await (const f of walk()) {
count += 1;
}
- assert.equal(count, 2);
+ assertEq(count, 2);
}
);
@@ -103,8 +104,8 @@ testWalk(
},
async function nestedSingleFile() {
const arr = await walkArray();
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "./a/x");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "./a/x");
}
);
@@ -116,10 +117,10 @@ testWalk(
async function depth() {
assertReady(1);
const arr_3 = await walkArray(".", { maxDepth: 3 });
- assert.equal(arr_3.length, 0);
+ assertEq(arr_3.length, 0);
const arr_5 = await walkArray(".", { maxDepth: 5 });
- assert.equal(arr_5.length, 1);
- assert.equal(arr_5[0], "./a/b/c/d/x");
+ assertEq(arr_5.length, 1);
+ assertEq(arr_5[0], "./a/b/c/d/x");
}
);
@@ -131,8 +132,8 @@ testWalk(
async function ext() {
assertReady(2);
const arr = await walkArray(".", { exts: [".ts"] });
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "./x.ts");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "./x.ts");
}
);
@@ -145,9 +146,9 @@ testWalk(
async function extAny() {
assertReady(3);
const arr = await walkArray(".", { exts: [".rs", ".ts"] });
- assert.equal(arr.length, 2);
- assert.equal(arr[0], "./x.ts");
- assert.equal(arr[1], "./y.rs");
+ assertEq(arr.length, 2);
+ assertEq(arr[0], "./x.ts");
+ assertEq(arr[1], "./y.rs");
}
);
@@ -159,8 +160,8 @@ testWalk(
async function match() {
assertReady(2);
const arr = await walkArray(".", { match: [/x/] });
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "./x");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "./x");
}
);
@@ -173,9 +174,9 @@ testWalk(
async function matchAny() {
assertReady(3);
const arr = await walkArray(".", { match: [/x/, /y/] });
- assert.equal(arr.length, 2);
- assert.equal(arr[0], "./x");
- assert.equal(arr[1], "./y");
+ assertEq(arr.length, 2);
+ assertEq(arr[0], "./x");
+ assertEq(arr[1], "./y");
}
);
@@ -187,8 +188,8 @@ testWalk(
async function skip() {
assertReady(2);
const arr = await walkArray(".", { skip: [/x/] });
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "./y");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "./y");
}
);
@@ -201,8 +202,8 @@ testWalk(
async function skipAny() {
assertReady(3);
const arr = await walkArray(".", { skip: [/x/, /y/] });
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "./z");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "./z");
}
);
@@ -217,19 +218,19 @@ testWalk(
async function subDir() {
assertReady(3);
const arr = await walkArray("b");
- assert.equal(arr.length, 1);
- assert.equal(arr[0], "b/z");
+ assertEq(arr.length, 1);
+ assertEq(arr[0], "b/z");
}
);
testWalk(async (d: string) => {}, async function onError() {
assertReady(0);
const ignored = await walkArray("missing");
- assert.equal(ignored.length, 0);
+ assertEq(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.
- assert.equal(errors, 2);
+ assertEq(errors, 2);
});
testWalk(
@@ -254,11 +255,11 @@ testWalk(
assertReady(3);
const files = await walkArray("a");
- assert.equal(files.length, 2);
+ assertEq(files.length, 2);
assert(!files.includes("a/bb/z"));
const arr = await walkArray("a", { followSymlinks: true });
- assert.equal(arr.length, 3);
+ assertEq(arr.length, 3);
assert(arr.some(f => f.endsWith("/b/z")));
}
);