From be18df1dab501f3fff0da6272697bb1b5a893bfb Mon Sep 17 00:00:00 2001 From: sterni Date: Mon, 19 Sep 2022 12:52:24 +0200 Subject: test(tvix/eval): assert flipped compareVersions behaves correctly Change-Id: I7c239340de5c83a3124dc6a8ba0c70290466966d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6698 Reviewed-by: grfn Reviewed-by: tazjin Tested-by: BuildkiteCI --- .../eval-okay-builtins-compareVersions.nix | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'tvix') 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" "") ] -- cgit 1.4.1