From 5a7f75db6a2b170c289faf265035568cfaed22d8 Mon Sep 17 00:00:00 2001 From: inoas Date: Fri, 8 Apr 2022 23:45:32 +0200 Subject: do not put lies in tests --- test/gleam/float_test.gleam | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'test') 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() + } } -- cgit v1.2.3