aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2022-04-13 03:00:34 +0200
committerLouis Pilfold <louis@lpil.uk>2022-04-16 10:23:34 +0100
commit711a7be12ac1a9ee6e5582b390ae92467d6d2d3b (patch)
treedec809dcea09e9820485faffdfbcaf4b51e263bf /test
parent4e06f94b78b3a47ed5b9745e7f646ed261fbe98c (diff)
downloadgleam_stdlib-711a7be12ac1a9ee6e5582b390ae92467d6d2d3b.tar.gz
gleam_stdlib-711a7be12ac1a9ee6e5582b390ae92467d6d2d3b.zip
remove public random_uniform, rename random_between to random
Diffstat (limited to 'test')
-rw-r--r--test/gleam/float_test.gleam39
-rw-r--r--test/gleam/int_test.gleam12
2 files changed, 15 insertions, 36 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index 126f27d..faf7d7c 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -330,53 +330,32 @@ pub fn product_test() {
|> should.equal(33.6)
}
-pub fn random_uniform_test() {
- let one_random_uniform_test_set = fn(_acc, _e) {
- { float.random_uniform() >=. 0. }
- |> should.be_true()
-
- { float.random_uniform() <. 0. }
- |> should.be_false()
-
- { float.random_uniform() <. 1. }
- |> should.be_true()
-
- { float.random_uniform() >=. 1. }
- |> should.be_false()
-
- Nil
- }
- list.range(0, 100)
- |> iterator.from_list
- |> iterator.fold(Nil, one_random_uniform_test_set)
-}
-
-pub fn random_between_test() {
+pub fn random_test() {
let test_boundaries = fn(_acc, _e) {
- float.random_between(0.0, 0.0)
+ float.random(0.0, 0.0)
|> should.equal(0.0)
- float.random_between(0.0, 10.0)
+ float.random(0.0, 10.0)
|> fn(x) { x >=. 0.0 && x <. 10.0 }
|> should.be_true
- float.random_between(10.0, 0.0)
+ float.random(10.0, 0.0)
|> fn(x) { x >=. 0.0 && x <. 10.0 }
|> should.be_true
- float.random_between(0.0, -10.0)
+ float.random(0.0, -10.0)
|> fn(x) { x >=. -10.0 && x <. 0.0 }
|> should.be_true
- float.random_between(-10.0, 0.0)
+ float.random(-10.0, 0.0)
|> fn(x) { x >=. -10.0 && x <. 0.0 }
|> should.be_true
- float.random_between(-10.0, 10.0)
+ float.random(-10.0, 10.0)
|> fn(x) { x >=. -10.0 && x <. 10.0 }
|> should.be_true
- float.random_between(10.0, -10.0)
+ float.random(10.0, -10.0)
|> fn(x) { x >=. -10.0 && x <. 10.0 }
|> should.be_true
}
@@ -395,7 +374,7 @@ pub fn random_between_test() {
|> iterator.from_list()
|> iterator.fold(
from: 0.0,
- with: fn(acc, _element) { acc +. float.random_between(min, max) },
+ with: fn(acc, _element) { acc +. float.random(min, max) },
)
|> fn(sum) { sum /. int.to_float(iterations) }
|> float.loosely_compare(expected_average, tolerance)
diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam
index 79c444b..9129c66 100644
--- a/test/gleam/int_test.gleam
+++ b/test/gleam/int_test.gleam
@@ -346,20 +346,20 @@ pub fn undigits_test() {
|> should.equal(Error(int.InvalidBase))
}
-pub fn random_between_test() {
+pub fn random_test() {
let test_boundaries = fn(_acc, _e) {
- int.random_between(0, 0)
+ int.random(0, 0)
|> should.equal(0)
- int.random_between(-1, 0)
+ int.random(-1, 0)
|> list.contains([-1, 0], _)
|> should.be_true
- int.random_between(-1, 1)
+ int.random(-1, 1)
|> list.contains([-1, 0], _)
|> should.be_true
- int.random_between(-1, 2)
+ int.random(-1, 2)
|> list.contains([-1, 0, 1], _)
|> should.be_true
}
@@ -373,7 +373,7 @@ pub fn random_between_test() {
|> iterator.from_list
|> iterator.fold(
from: 0,
- with: fn(acc, _element) { acc + int.random_between(min, max) },
+ with: fn(acc, _element) { acc + int.random(min, max) },
)
|> fn(sum) { sum / iterations }
|> fn(sum) {