about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-09-19T10·52+0200
committersterni <sternenseemann@systemli.org>2022-09-20T10·59+0000
commitbe18df1dab501f3fff0da6272697bb1b5a893bfb (patch)
tree48e703b030b3f766ba48a94800abbf53406f8880 /tvix
parent7506983ce2748fadef56aa390e61003dbf556a98 (diff)
test(tvix/eval): assert flipped compareVersions behaves correctly r/4938
Change-Id: I7c239340de5c83a3124dc6a8ba0c70290466966d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6698
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-builtins-compareVersions.nix29
1 files changed, 19 insertions, 10 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-compareVersions.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-compareVersions.nix
index 769de79ad583..4c3ed5987509 100644
--- a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-compareVersions.nix
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-compareVersions.nix
@@ -1,12 +1,21 @@
+let
+  cmp = a: b:
+    let
+      ord1 = builtins.compareVersions a b;
+      ord2 = builtins.compareVersions b a;
+    in
+      assert ord1 == -ord2; ord1;
+in
+
 [
-  (builtins.compareVersions "1.2.3" "1.2.3")
-  (builtins.compareVersions "1.2.2" "1.2.3")
-  (builtins.compareVersions "1.2.3" "1.2.40")
-  (builtins.compareVersions "1.2.3" ".1.2.3")
-  (builtins.compareVersions "1.2.3" "1..2.3")
-  (builtins.compareVersions "1.2.3" "1.2.3.")
-  (builtins.compareVersions "1.2.3" "1.2")
-  (builtins.compareVersions "1.2.3" "1.2.a")
-  (builtins.compareVersions "1a.b" "1a.2")
-  (builtins.compareVersions "1" "")
+  (cmp "1.2.3" "1.2.3")
+  (cmp "1.2.2" "1.2.3")
+  (cmp "1.2.3" "1.2.40")
+  (cmp "1.2.3" ".1.2.3")
+  (cmp "1.2.3" "1..2.3")
+  (cmp "1.2.3" "1.2.3.")
+  (cmp "1.2.3" "1.2")
+  (cmp "1.2.3" "1.2.a")
+  (cmp "1a.b" "1a.2")
+  (cmp "1" "")
 ]