aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/path.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'integration/bunjs-only-snippets/path.test.js')
-rw-r--r--integration/bunjs-only-snippets/path.test.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/path.test.js b/integration/bunjs-only-snippets/path.test.js
index d6987bf80..997368150 100644
--- a/integration/bunjs-only-snippets/path.test.js
+++ b/integration/bunjs-only-snippets/path.test.js
@@ -390,3 +390,68 @@ it("path.normalize", () => {
);
strictEqual(path.posix.normalize("foo/bar\\baz"), "foo/bar\\baz");
});
+
+it("path.resolve", () => {
+ const failures = [];
+ const slashRE = /\//g;
+ const backslashRE = /\\/g;
+
+ const resolveTests = [
+ // [
+ // path.win32.resolve,
+ // // 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"],
+ // [["."], process.cwd()],
+ // [["//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",
+ // ],
+ // ],
+ // ],
+ [
+ path.posix.resolve,
+ // Arguments result
+ [
+ [["/var/lib", "../", "file/"], "/var/file"],
+ [["/var/lib", "/../", "file/"], "/file"],
+ [["a/b/c/", "../../.."], process.cwd()],
+ [["."], process.cwd()],
+ [["/some/dir", ".", "/absolute/"], "/absolute"],
+ [
+ ["/foo/tmp.3/", "../tmp.3/cycles/root.js"],
+ "/foo/tmp.3/cycles/root.js",
+ ],
+ ],
+ ],
+ ];
+ const isWindows = false;
+ resolveTests.forEach(([resolve, tests]) => {
+ tests.forEach(([test, expected]) => {
+ const actual = resolve.apply(null, test);
+ let actualAlt;
+ const os = resolve === path.win32.resolve ? "win32" : "posix";
+ if (resolve === path.win32.resolve && !isWindows)
+ actualAlt = actual.replace(backslashRE, "/");
+ else if (resolve !== path.win32.resolve && isWindows)
+ actualAlt = actual.replace(slashRE, "\\");
+
+ const message = `path.${os}.resolve(${test
+ .map(JSON.stringify)
+ .join(",")})\n expect=${JSON.stringify(
+ expected
+ )}\n actual=${JSON.stringify(actual)}`;
+ if (actual !== expected && actualAlt !== expected) failures.push(message);
+ });
+ });
+ strictEqual(failures.length, 0, failures.join("\n"));
+});