diff options
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 | ||