about summary refs log tree commit diff
path: root/tvix/eval/src/tests/nix_tests/eval-okay-closure.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-11-20T22·12+0100
committertazjin <tazjin@tvl.su>2022-11-21T14·14+0000
commite1e8285ecfe94fc9afd33110ff63ce707fa4369a (patch)
treed6eb37322519b42def54664212d477fdc5f6fec9 /tvix/eval/src/tests/nix_tests/eval-okay-closure.nix
parentae30def0552e033a8f92e7094789cec1d0e940fe (diff)
test(tvix/eval): enable eval-okay-closure test from nix_tests r/5296
This function covers builtins.genericClosure, seemingly including
weird behaviour around the order in which the work set is processed.

For some reason, in C++ Nix the test expectation is written in XML
which we do not yet support, so I have created a new expectation file
using `nix-instantiate --eval --strict` on the file (yes, using C++
Nix).

Change-Id: Id90e7117d120dc66d963a51083c4d8e8f2d9f181
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7311
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/tests/nix_tests/eval-okay-closure.nix')
-rw-r--r--tvix/eval/src/tests/nix_tests/eval-okay-closure.nix13
1 files changed, 13 insertions, 0 deletions
diff --git a/tvix/eval/src/tests/nix_tests/eval-okay-closure.nix b/tvix/eval/src/tests/nix_tests/eval-okay-closure.nix
new file mode 100644
index 000000000000..cccd4dc35730
--- /dev/null
+++ b/tvix/eval/src/tests/nix_tests/eval-okay-closure.nix
@@ -0,0 +1,13 @@
+let
+
+  closure = builtins.genericClosure {
+    startSet = [{key = 80;}];
+    operator = {key, foo ? false}:
+      if builtins.lessThan key 0
+      then []
+      else [{key = builtins.sub key 9;} {key = builtins.sub key 13; foo = true;}];
+  };
+
+  sort = (import ./lib.nix).sortBy (a: b: builtins.lessThan a.key b.key);
+
+in sort closure