diff options
author | Rutger Broekhoff | 2025-07-07 21:52:08 +0200 |
---|---|---|
committer | Rutger Broekhoff | 2025-07-07 21:52:08 +0200 |
commit | ba61dfd69504ec6263a9dee9931d93adeb6f3142 (patch) | |
tree | d6c9b78e50eeab24e0c1c09ab45909a6ae3fd5db /test/testdata/eval-okay-listtoattrs.nix | |
download | verified-dyn-lang-interp-ba61dfd69504ec6263a9dee9931d93adeb6f3142.tar.gz verified-dyn-lang-interp-ba61dfd69504ec6263a9dee9931d93adeb6f3142.zip |
Initialize repository
Diffstat (limited to 'test/testdata/eval-okay-listtoattrs.nix')
-rw-r--r-- | test/testdata/eval-okay-listtoattrs.nix | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/testdata/eval-okay-listtoattrs.nix b/test/testdata/eval-okay-listtoattrs.nix new file mode 100644 index 0000000..4186e02 --- /dev/null +++ b/test/testdata/eval-okay-listtoattrs.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | # this test shows how to use listToAttrs and that evaluation is still lazy (throw isn't called) | ||
2 | with import ./lib.nix; | ||
3 | |||
4 | let | ||
5 | asi = name: value : { inherit name value; }; | ||
6 | list = [ ( asi "a" "A" ) ( asi "b" "B" ) ]; | ||
7 | a = builtins.listToAttrs list; | ||
8 | b = builtins.listToAttrs ( list ++ list ); | ||
9 | r = builtins.listToAttrs [ (asi "result" [ a b ]) ( asi "throw" (throw "this should not be thrown")) ]; | ||
10 | x = builtins.listToAttrs [ (asi "foo" "bar") (asi "foo" "bla") ]; | ||
11 | in concat (map (x: x.a) r.result) + x.foo | ||