summaryrefslogtreecommitdiff
path: root/lib/path/tests/unit.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/path/tests/unit.nix')
-rw-r--r--lib/path/tests/unit.nix36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/path/tests/unit.nix b/lib/path/tests/unit.nix
index da2c950de914..a1a45173a909 100644
--- a/lib/path/tests/unit.nix
+++ b/lib/path/tests/unit.nix
@@ -3,9 +3,43 @@
{ libpath }:
let
lib = import libpath;
- inherit (lib.path) subpath;
+ inherit (lib.path) append subpath;
cases = lib.runTests {
+ # Test examples from the lib.path.append documentation
+ testAppendExample1 = {
+ expr = append /foo "bar/baz";
+ expected = /foo/bar/baz;
+ };
+ testAppendExample2 = {
+ expr = append /foo "./bar//baz/./";
+ expected = /foo/bar/baz;
+ };
+ testAppendExample3 = {
+ expr = append /. "foo/bar";
+ expected = /foo/bar;
+ };
+ testAppendExample4 = {
+ expr = (builtins.tryEval (append "/foo" "bar")).success;
+ expected = false;
+ };
+ testAppendExample5 = {
+ expr = (builtins.tryEval (append /foo /bar)).success;
+ expected = false;
+ };
+ testAppendExample6 = {
+ expr = (builtins.tryEval (append /foo "")).success;
+ expected = false;
+ };
+ testAppendExample7 = {
+ expr = (builtins.tryEval (append /foo "/bar")).success;
+ expected = false;
+ };
+ testAppendExample8 = {
+ expr = (builtins.tryEval (append /foo "../bar")).success;
+ expected = false;
+ };
+
# Test examples from the lib.path.subpath.isValid documentation
testSubpathIsValidExample1 = {
expr = subpath.isValid null;