From 4eafaae9e66c66a7765ff3854890039d7536a9b9 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 11 Aug 2022 11:37:04 +0300 Subject: feat(tvix/eval): implement binary comparison operators This is accomplished by simply delegating to the Rust implementations of (Partial)Ord and (Partial)Eq, which are implemented for Value and underlying wrapper types to behave like they do in Nix. To ease the implementation overhead, a new comparison operator macro has been added to the VM module. Incomparable types will raise a new error variant when a comparison is attempted, containing both supplied types. This mimics the information carried in the error thrown by C++ Nix. Change-Id: Ia19634d69119d40722f3ca672387bc3a80096998 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6143 Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/tests/tvix_tests/eval-okay-cmp-num-false.nix | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-cmp-num-false.nix (limited to 'tvix/eval/src/tests/tvix_tests/eval-okay-cmp-num-false.nix') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-cmp-num-false.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-cmp-num-false.nix new file mode 100644 index 0000000000..61b206c033 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-cmp-num-false.nix @@ -0,0 +1,8 @@ +{ + eq = 6.9 == 4; + ne = 4.0 != 4; + lt = 2.5 < 1; + le = 2 <= 1.5; + gt = 1 > 1.1; + ge = 1.5 >= 2; +} -- cgit 1.4.1