nix-super/tests/functional/lang/eval-okay-baseNameOf.nix
2024-03-24 01:26:17 +01:00

32 lines
1,023 B
Nix

assert baseNameOf "" == "";
assert baseNameOf "." == ".";
assert baseNameOf ".." == "..";
assert baseNameOf "a" == "a";
assert baseNameOf "a." == "a.";
assert baseNameOf "a.." == "a..";
assert baseNameOf "a.b" == "a.b";
assert baseNameOf "a.b." == "a.b.";
assert baseNameOf "a.b.." == "a.b..";
assert baseNameOf "a/" == "a";
assert baseNameOf "a/." == ".";
assert baseNameOf "a/.." == "..";
assert baseNameOf "a/b" == "b";
assert baseNameOf "a/b." == "b.";
assert baseNameOf "a/b.." == "b..";
assert baseNameOf "a/b/c" == "c";
assert baseNameOf "a/b/c." == "c.";
assert baseNameOf "a/b/c.." == "c..";
assert baseNameOf "a/b/c/d" == "d";
assert baseNameOf "a/b/c/d." == "d.";
assert baseNameOf "a\\b" == "a\\b";
assert baseNameOf "C:a" == "C:a";
assert baseNameOf "a//b" == "b";
# It's been like this for close to a decade. We ought to commit to it.
# https://github.com/NixOS/nix/pull/582#issuecomment-121014450
assert baseNameOf "a//" == "";
assert baseNameOf ./foo == "foo";
assert baseNameOf ./foo/bar == "bar";
"ok"