diff options
author | inoas <mail@inoas.com> | 2022-04-12 00:06:15 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-04-16 10:23:34 +0100 |
commit | b14529894f84b127cf931014a4e30eed6cfa4648 (patch) | |
tree | 969db15ab7dd4b25bfb7a167320effadf4dd2128 /test | |
parent | 75802b6408842e4f59521bd52e72237ef31cd64e (diff) | |
download | gleam_stdlib-b14529894f84b127cf931014a4e30eed6cfa4648.tar.gz gleam_stdlib-b14529894f84b127cf931014a4e30eed6cfa4648.zip |
repeat tests
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/float_test.gleam | 41 | ||||
-rw-r--r-- | test/gleam/int_test.gleam | 10 |
2 files changed, 35 insertions, 16 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam index c043741..edecc3c 100644 --- a/test/gleam/float_test.gleam +++ b/test/gleam/float_test.gleam @@ -302,18 +302,29 @@ pub fn product_test() { } pub fn random_lower_boundary_test() { - { float.random_uniform() >=. 0. } - |> should.be_true() - { float.random_uniform() <. 0. } - |> should.be_false() + let one_random_lower_boundary_test_set = { + { float.random_uniform() >=. 0. } + |> should.be_true() + { float.random_uniform() <. 0. } + |> should.be_false() + } + list.range(0, 100) + |> iterator.from_list + |> iterator.fold(Nil, one_random_lower_boundary_test_set) } if erlang { pub fn random_upper_boundary_test() { - { float.random_uniform() <. 1. } - |> should.be_true() - { float.random_uniform() >=. 1. } - |> should.be_false() + let one_random_upper_boundary_test_set = fn(_acc, _e) { + { float.random_uniform() <. 1. } + |> should.be_true() + { float.random_uniform() >=. 1. } + |> should.be_false() + } + + list.range(0, 100) + |> iterator.from_list + |> iterator.fold(Nil, one_random_upper_boundary_test_set) } } @@ -321,9 +332,15 @@ 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_upper_boundary_test() { - { float.random_uniform() <=. 1. } - |> should.be_true() - { float.random_uniform() >. 1. } - |> should.be_false() + let one_random_upper_boundary_test_set = fn(_acc, _e) { + { float.random_uniform() <=. 1. } + |> should.be_true() + { float.random_uniform() >. 1. } + |> should.be_false() + } + + list.range(0, 100) + |> iterator.from_list + |> iterator.fold(Nil, one_random_upper_boundary_test_set) } } diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam index 90b573e..28502ab 100644 --- a/test/gleam/int_test.gleam +++ b/test/gleam/int_test.gleam @@ -320,7 +320,7 @@ pub fn undigits_test() { } pub fn random_below_test() { - let do_random_below_test = fn(_acc, _e) { + let one_random_below_test_set = fn(_acc, _e) { int.random_below(0) |> should.equal(0) @@ -344,13 +344,14 @@ pub fn random_below_test() { |> list.contains([0, 1, 2, 3], _) |> should.be_true } + list.range(0, 100) |> iterator.from_list - |> iterator.fold(Nil, do_random_below_test) + |> iterator.fold(Nil, one_random_below_test_set) } pub fn random_between_test() { - let do_random_between_test = fn(_acc, _e) { + let one_random_between_test_set = fn(_acc, _e) { int.random_between(0, 0) |> should.equal(0) @@ -366,7 +367,8 @@ pub fn random_between_test() { |> list.contains([-1, 0, 1], _) |> should.be_true } + list.range(0, 100) |> iterator.from_list - |> iterator.fold(Nil, do_random_between_test) + |> iterator.fold(Nil, one_random_between_test_set) } |