diff options
author | inoas <mail@inoas.com> | 2022-04-08 23:45:32 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-04-16 10:23:34 +0100 |
commit | 5a7f75db6a2b170c289faf265035568cfaed22d8 (patch) | |
tree | dba7d6a65c4f5ceceae19b4b5c387a4a7d406126 /test | |
parent | 83c81cc9310667658d7780acadb88592f61edc51 (diff) | |
download | gleam_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.gleam | 21 |
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() + } } |