From 3412ae495661e8073075bbb8c24ee0098ca2bede Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 23 Oct 2022 13:50:07 -0400 Subject: feat(tvix/eval): Implement builtins.sort This is a bit tricky because the comparator can throw errors, so we need to propagate them out if they exist and try to avoid sorting forever by returning a reasonable ordering in this case (as short-circuiting is not available). Co-Authored-By: Vincent Ambo Change-Id: Icae1d30f43ec1ae64b2ba51e73ee467605686792 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7072 Tested-by: BuildkiteCI Reviewed-by: sterni --- .../tests/nix_tests/notyetpassing/eval-okay-sort.exp | 1 - .../tests/nix_tests/notyetpassing/eval-okay-sort.nix | 20 -------------------- 2 files changed, 21 deletions(-) delete mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.exp delete mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.nix (limited to 'tvix/eval/src/tests/nix_tests/notyetpassing') diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.exp b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.exp deleted file mode 100644 index 899119e20e38..000000000000 --- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.exp +++ /dev/null @@ -1 +0,0 @@ -[ [ 42 77 147 249 483 526 ] [ 526 483 249 147 77 42 ] [ "bar" "fnord" "foo" "xyzzy" ] [ { key = 1; value = "foo"; } { key = 1; value = "fnord"; } { key = 2; value = "bar"; } ] [ [ ] [ ] [ 1 ] [ 1 4 ] [ 1 5 ] [ 1 6 ] [ 2 ] [ 2 3 ] [ 3 ] [ 3 ] ] ] diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.nix deleted file mode 100644 index 50aa78e40325..000000000000 --- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.nix +++ /dev/null @@ -1,20 +0,0 @@ -with builtins; - -[ (sort lessThan [ 483 249 526 147 42 77 ]) - (sort (x: y: y < x) [ 483 249 526 147 42 77 ]) - (sort lessThan [ "foo" "bar" "xyzzy" "fnord" ]) - (sort (x: y: x.key < y.key) - [ { key = 1; value = "foo"; } { key = 2; value = "bar"; } { key = 1; value = "fnord"; } ]) - (sort lessThan [ - [ 1 6 ] - [ ] - [ 2 3 ] - [ 3 ] - [ 1 5 ] - [ 2 ] - [ 1 ] - [ ] - [ 1 4 ] - [ 3 ] - ]) -] -- cgit 1.4.1