// Auto-generated by scripts/gen_parity_tests.py from docs/runtime-parity.md.
// Module: node:path
// This file is a byte-for-byte parity test against `node --experimental-strip-types`.

import * as path from "node:path";

// ── Functions ──

console.log("basename plain:", path.basename("/foo/bar/baz.txt"));
console.log("basename suffix:", path.basename("/foo/bar/baz.txt", ".txt"));
console.log("basename trailing:", path.basename("/foo/bar/"));
console.log("basename empty:", path.basename(""));

console.log("dirname plain:", path.dirname("/foo/bar/baz.txt"));
console.log("dirname root:", path.dirname("/"));
console.log("dirname relative:", path.dirname("a/b/c"));

console.log("extname txt:", path.extname("/foo/bar/baz.txt"));
console.log("extname none:", path.extname("/foo/bar/baz"));
console.log("extname hidden:", path.extname("/foo/.hidden"));
console.log("extname multi:", path.extname("foo.tar.gz"));

console.log("format full:", path.format({ root: "/", dir: "/home/user", base: "file.txt" }));
console.log("format ext+name:", path.format({ name: "file", ext: ".txt" }));

console.log("isAbsolute /a:", path.isAbsolute("/a"));
console.log("isAbsolute a/b:", path.isAbsolute("a/b"));
console.log("isAbsolute empty:", path.isAbsolute(""));

console.log("join basic:", path.join("/foo", "bar", "baz"));
console.log("join trailing:", path.join("/foo/", "/bar/", "baz"));
console.log("join dotdot:", path.join("/foo", "..", "bar"));
console.log("join empty:", path.join());

try {
  console.log("matchesGlob *:", path.matchesGlob("foo.txt", "*.txt"));
} catch (e) {
  console.log("matchesGlob ERROR:", (e as Error).message);
}

console.log("normalize basic:", path.normalize("/foo/bar//baz/qux/.."));
console.log("normalize dotdot:", path.normalize("foo/bar/../baz"));
console.log("normalize trailing:", path.normalize("foo/bar/"));

const parsed = path.parse("/home/user/file.txt");
console.log("parse root:", parsed.root);
console.log("parse dir:", parsed.dir);
console.log("parse base:", parsed.base);
console.log("parse name:", parsed.name);
console.log("parse ext:", parsed.ext);

console.log("relative same:", path.relative("/foo", "/foo"));
console.log("relative sibling:", path.relative("/foo/a", "/foo/b"));
console.log("relative deeper:", path.relative("/foo", "/foo/bar/baz"));

console.log("resolve abs:", path.resolve("/foo", "bar"));
console.log("resolve override:", path.resolve("/foo", "/bar", "baz"));
console.log("resolve dotdot:", path.resolve("/foo/bar", "..", "baz"));

console.log("toNamespacedPath:", path.toNamespacedPath("/foo/bar"));

// ── Properties ──
console.log("path.delimiter:", path.delimiter);
console.log("path.sep:", path.sep);

// path.posix / path.win32 — exercise a sample method from each instead
// of dumping the whole namespace object (object printing differs).
if (path.posix) {
  console.log("posix.join:", path.posix.join("/foo", "bar"));
  console.log("posix.sep:", path.posix.sep);
} else {
  console.log("posix.join:", "<unimplemented>");
  console.log("posix.sep:", "<unimplemented>");
}
if (path.win32) {
  console.log("win32.join:", path.win32.join("C:\\foo", "bar"));
  console.log("win32.sep:", path.win32.sep);
} else {
  console.log("win32.join:", "<unimplemented>");
  console.log("win32.sep:", "<unimplemented>");
}
