From d0a836b0e1ee1034144d1e5b71df6ab285c8450e Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 23 Oct 2022 13:37:11 -0400 Subject: feat(tvix/eval): Implement comparison for lists Lists are compared lexicographically in C++ nix as of [0], and our updated nix test suites depend on this. This implements comparison of list values in `Value::nix_cmp` using a very similar algorithm to what C++ does - similarly to there, this requires passing in the VM so we can force thunks in the list elements as we go. [0]: https://github.com/NixOS/nix/commit/09471d2680292af48b2788108de56a8da755d661# Change-Id: I5d8bb07f90647a1fec83f775243e21af856afbb1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7070 Autosubmit: grfn Reviewed-by: sterni Tested-by: BuildkiteCI --- .../src/tests/tvix_tests/eval-okay-compare-lists.exp | 1 + .../src/tests/tvix_tests/eval-okay-compare-lists.nix | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-compare-lists.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-compare-lists.nix (limited to 'tvix/eval/src/tests/tvix_tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-compare-lists.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-compare-lists.exp new file mode 100644 index 0000000000..3b7fd39819 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-compare-lists.exp @@ -0,0 +1 @@ +[ false true true true false true false false false true false false false true true ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-compare-lists.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-compare-lists.nix new file mode 100644 index 0000000000..9b73df61d8 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-compare-lists.nix @@ -0,0 +1,17 @@ +[ + ([1 2] < [1]) + ([1 2] < [2 3]) + ([1 2] < [2]) + ([1 2] < [1 2 3]) + ([3 4] < [1]) + ([1 2] > [1]) + ([1 2] > [2 3]) + ([1 2] > [2]) + ([1 2] > [1 2 3]) + ([3 4] > [1]) + ([1 2] <= [1]) + ([1 2] >= [2 3]) + ([1 2] >= [2]) + ([1 2] <= [1 2 3]) + ([3 4] >= [1]) +] -- cgit 1.4.1