aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGiacomo Cavalieri <giacomo.cavalieri@icloud.com>2024-03-12 15:23:56 +0100
committerLouis Pilfold <louis@lpil.uk>2024-03-13 12:07:40 +0000
commit2f207523abc2e855f456bff5252c6704b48ed6c3 (patch)
tree26a39a8d749b2538306419628cde66edcfaa16f9 /test
parentb6894463caede28c8bce527c343895e28026f894 (diff)
downloadgleam_stdlib-2f207523abc2e855f456bff5252c6704b48ed6c3.tar.gz
gleam_stdlib-2f207523abc2e855f456bff5252c6704b48ed6c3.zip
Add `order.break_tie` and `order.lazy_break_tie`
Diffstat (limited to 'test')
-rw-r--r--test/gleam/order_test.gleam34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/gleam/order_test.gleam b/test/gleam/order_test.gleam
index e9929d3..b2f66e0 100644
--- a/test/gleam/order_test.gleam
+++ b/test/gleam/order_test.gleam
@@ -117,3 +117,37 @@ pub fn reverse_test() {
|> list.sort(by: order.reverse(int.compare))
|> should.equal([5, 4, 1])
}
+
+pub fn break_tie_test() {
+ order.break_tie(in: Eq, with: Lt)
+ |> should.equal(Lt)
+
+ order.break_tie(in: Eq, with: Gt)
+ |> should.equal(Gt)
+
+ order.break_tie(in: Eq, with: Eq)
+ |> should.equal(Eq)
+
+ order.break_tie(in: Gt, with: Lt)
+ |> should.equal(Gt)
+
+ order.break_tie(in: Lt, with: Gt)
+ |> should.equal(Lt)
+}
+
+pub fn lazy_break_tie_test() {
+ order.lazy_break_tie(in: Eq, with: fn() { Lt })
+ |> should.equal(Lt)
+
+ order.lazy_break_tie(in: Eq, with: fn() { Gt })
+ |> should.equal(Gt)
+
+ order.lazy_break_tie(in: Eq, with: fn() { Eq })
+ |> should.equal(Eq)
+
+ order.lazy_break_tie(in: Gt, with: fn() { panic })
+ |> should.equal(Gt)
+
+ order.lazy_break_tie(in: Lt, with: fn() { panic })
+ |> should.equal(Lt)
+}