From 71b130c581c81bf3bd2a3c777f7cc11d746327ae Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 2 Dec 2021 18:12:51 +0100 Subject: lib.attrsets: Introduce showAttrPath --- lib/tests/misc.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib/tests') diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 5fa95828df691..c4a34369f50fb 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 = ""; + }; + + testShowAttrPathVarious = { + expr = showAttrPath [ + "." + "foo" + "2" + "a2-b" + "_bc'de" + ]; + expected = "\".\".foo.\"2\".a2-b._bc'de"; + }; } -- cgit 1.4.1