aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2022-04-08 23:45:32 +0200
committerLouis Pilfold <louis@lpil.uk>2022-04-16 10:23:34 +0100
commit5a7f75db6a2b170c289faf265035568cfaed22d8 (patch)
treedba7d6a65c4f5ceceae19b4b5c387a4a7d406126 /test
parent83c81cc9310667658d7780acadb88592f61edc51 (diff)
downloadgleam_stdlib-5a7f75db6a2b170c289faf265035568cfaed22d8.tar.gz
gleam_stdlib-5a7f75db6a2b170c289faf265035568cfaed22d8.zip
do not put lies in tests
Diffstat (limited to 'test')
-rw-r--r--test/gleam/float_test.gleam21
1 files changed, 16 insertions, 5 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index dcb9ed2..a743eff 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -302,11 +302,22 @@ pub fn product_test() {
}
pub fn random_test() {
- let random = float.random()
-
- { random >=. 0. }
+ { float.random() >=. 0. }
|> should.be_true()
+}
- { random <. 1. }
- |> should.be_true()
+if erlang {
+ pub fn random_test2() {
+ { float.random() <. 1. }
+ |> should.be_true()
+ }
+}
+
+if javascript {
+ // Due to IEEE 754 floating point numbers
+ // the ceiling may be rounded to 1.0 even if it should not
+ pub fn random_test2() {
+ { float.random() <=. 1. }
+ |> should.be_true()
+ }
}