diff options
-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() + } } |