summary refs log tree commit diff
path: root/lib/tests
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2021-12-02 18:12:51 +0100
committerSilvan Mosberger <contact@infinisil.com>2022-03-18 00:05:08 +0100
commit71b130c581c81bf3bd2a3c777f7cc11d746327ae (patch)
tree9e30497b8edff6f64fe682150a1c5b57c7639831 /lib/tests
parent671a068a0166a5474e51b4d151b64250f8feaec8 (diff)
downloadnixpkgs-71b130c581c81bf3bd2a3c777f7cc11d746327ae.tar
nixpkgs-71b130c581c81bf3bd2a3c777f7cc11d746327ae.tar.gz
nixpkgs-71b130c581c81bf3bd2a3c777f7cc11d746327ae.tar.bz2
nixpkgs-71b130c581c81bf3bd2a3c777f7cc11d746327ae.tar.lz
nixpkgs-71b130c581c81bf3bd2a3c777f7cc11d746327ae.tar.xz
nixpkgs-71b130c581c81bf3bd2a3c777f7cc11d746327ae.tar.zst
nixpkgs-71b130c581c81bf3bd2a3c777f7cc11d746327ae.zip
lib.attrsets: Introduce showAttrPath
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/misc.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 5fa95828df6..c4a34369f50 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -761,4 +761,26 @@ runTests {
       { a = 3; b = 30; c = 300; }
     ];
   };
+
+  # The example from the showAttrPath documentation
+  testShowAttrPathExample = {
+    expr = showAttrPath [ "foo" "10" "bar" ];
+    expected = "foo.\"10\".bar";
+  };
+
+  testShowAttrPathEmpty = {
+    expr = showAttrPath [];
+    expected = "<root attribute path>";
+  };
+
+  testShowAttrPathVarious = {
+    expr = showAttrPath [
+      "."
+      "foo"
+      "2"
+      "a2-b"
+      "_bc'de"
+    ];
+    expected = "\".\".foo.\"2\".a2-b._bc'de";
+  };
 }