aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gleam/float_test.gleam30
-rw-r--r--test/gleam/int_test.gleam10
2 files changed, 23 insertions, 17 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index 65878bf..e13112f 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -335,7 +335,12 @@ pub fn random_between_test() {
|> fn(x) { x >=. 0.0 && x <. 1.0 }
|> should.be_true
+ float.random_between(1.0, 0.0)
+ |> fn(x) { x >=. 0.0 && x <. 1.0 }
+ |> should.be_true
+
float.random_between(0.0, -1.0)
+ |> function.tap(io.debug)
|> fn(x) { x >=. -1.0 && x <. 0.0 }
|> should.be_true
@@ -343,12 +348,20 @@ pub fn random_between_test() {
|> fn(x) { x >=. -1.0 && x <. 0.0 }
|> should.be_true
- float.random_between(0.0, -2.0)
- |> fn(x) { x >=. -2.0 && x <. 0.0 }
+ float.random_between(0.0, -10.0)
+ |> fn(x) { x >=. -10.0 && x <. 0.0 }
+ |> should.be_true
+
+ float.random_between(-10.0, 0.0)
+ |> fn(x) { x >=. -10.0 && x <. 0.0 }
|> should.be_true
- float.random_between(-2.0, 0.0)
- |> fn(x) { x >=. -2.0 && x <. 0.0 }
+ float.random_between(-10.0, 10.0)
+ |> fn(x) { x >=. -10.0 && x <. 10.0 }
+ |> should.be_true
+
+ float.random_between(-10.0, 10.0)
+ |> fn(x) { x >=. -10.0 && x <. 10.0 }
|> should.be_true
}
@@ -370,11 +383,14 @@ pub fn random_to_test() {
|> fn(x) { x >=. 0.0 && x <. 1.0 }
|> should.be_true
- float.random_to(2.0)
- |> fn(x) { x >=. 0.0 && x <. 2.0 }
+ float.random_to(10.0)
+ |> fn(x) { x >=. 0.0 && x <. 10.0 }
|> should.be_true
- }
+ float.random_to(-10.0)
+ |> fn(x) { x >=. -10.0 && x <. 0.0 }
+ |> should.be_true
+ }
list.range(0, 100)
|> iterator.from_list
|> iterator.fold(Nil, one_random_to_test_set)
diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam
index aeec7e7..017596a 100644
--- a/test/gleam/int_test.gleam
+++ b/test/gleam/int_test.gleam
@@ -323,20 +323,16 @@ pub fn random_between_test() {
let one_random_between_test_set = fn(_acc, _e) {
int.random_between(0, 0)
|> should.equal(0)
-
int.random_between(-1, 0)
|> list.contains([-1, 0], _)
|> should.be_true
-
int.random_between(-1, 1)
|> list.contains([-1, 0], _)
|> should.be_true
-
int.random_between(-1, 2)
|> list.contains([-1, 0, 1], _)
|> should.be_true
}
-
list.range(0, 100)
|> iterator.from_list
|> iterator.fold(Nil, one_random_between_test_set)
@@ -346,28 +342,22 @@ pub fn random_to_test() {
let one_random_to_test_set = fn(_acc, _e) {
int.random_to(0)
|> should.equal(0)
-
int.random_to(-1)
|> list.contains([-1], _)
|> should.be_true
-
int.random_to(1)
|> list.contains([0], _)
|> should.be_true
-
int.random_to(2)
|> list.contains([0, 1], _)
|> should.be_true
-
int.random_to(3)
|> list.contains([0, 1, 2], _)
|> should.be_true
-
int.random_to(4)
|> list.contains([0, 1, 2, 3], _)
|> should.be_true
}
-
list.range(0, 100)
|> iterator.from_list
|> iterator.fold(Nil, one_random_to_test_set)