diff options
author | inoas <mail@inoas.com> | 2022-04-12 03:04:03 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-04-16 10:23:34 +0100 |
commit | 7f1c0f03b4e825fe86fe1d49a8017bf4c4bcb7bb (patch) | |
tree | c30e3321451be230e7d8a874817c1e994d734f08 /test | |
parent | dc71009b74846164a70814b103d36ff7381cfc82 (diff) | |
download | gleam_stdlib-7f1c0f03b4e825fe86fe1d49a8017bf4c4bcb7bb.tar.gz gleam_stdlib-7f1c0f03b4e825fe86fe1d49a8017bf4c4bcb7bb.zip |
wip: still missing some refactoring and average/median tests
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/float_test.gleam | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam index 39fa9a8..65878bf 100644 --- a/test/gleam/float_test.gleam +++ b/test/gleam/float_test.gleam @@ -327,54 +327,55 @@ pub fn random_uniform_test() { } pub fn random_between_test() { - // let one_random_between_test_set = fn(_acc, _e) { - // float.random_between(0.0, 0.0) - // |> should.equal(0.0) - // } - float.random_between(-1.0, 0.0) - |> function.tap(io.debug) - // |> function.tap(fn(x) { - // fn(x) { x >=. -1.0 }(x) - // |> should.be_true - // }) - |> function.tap(fn(x) { - fn(x) { x <. 0.0 }(x) + let one_random_between_test_set = fn(_acc, _e) { + float.random_between(0.0, 0.0) + |> should.equal(0.0) + + float.random_between(0.0, 1.0) + |> fn(x) { x >=. 0.0 && x <. 1.0 } + |> should.be_true + + float.random_between(0.0, -1.0) + |> fn(x) { x >=. -1.0 && x <. 0.0 } + |> should.be_true + + float.random_between(-1.0, 0.0) + |> fn(x) { x >=. -1.0 && x <. 0.0 } + |> should.be_true + + float.random_between(0.0, -2.0) + |> fn(x) { x >=. -2.0 && x <. 0.0 } |> should.be_true - }) - // float.random_between(0.0, -1.0) - // |> fn(x) { x >=. -1.0 && x <. 0.0 } - // |> should.be_true - // float.random_between(-1.0, 1.0) - // |> fn(x) { x >=. -1.0 && x <. 1.0 } - // |> should.be_true - // float.random_between(1.0, -1.0) - // |> fn(x) { x >=. -1.0 && x <. 1.0 } - // |> should.be_true - // float.random_between(-1.0, 2.0) - // |> fn(x) { x >=. -1.0 && x <. 2.0 } - // |> should.be_true - // float.random_between(2.0, -1.0) - // |> fn(x) { x >=. -1.0 && x <. 2.0 } - // |> should.be_true - // list.range(0, 1) - // |> iterator.from_list - // |> iterator.fold(Nil, one_random_between_test_set) + + float.random_between(-2.0, 0.0) + |> fn(x) { x >=. -2.0 && x <. 0.0 } + |> should.be_true + } + + list.range(0, 100) + |> iterator.from_list + |> iterator.fold(Nil, one_random_between_test_set) +} + +pub fn random_to_test() { + let one_random_to_test_set = fn(_acc, _e) { + float.random_to(0.0) + |> should.equal(0.0) + + float.random_to(-1.0) + |> fn(x) { x >=. -1.0 && x <. 0.0 } + |> should.be_true + + float.random_to(1.0) + |> fn(x) { x >=. 0.0 && x <. 1.0 } + |> should.be_true + + float.random_to(2.0) + |> fn(x) { x >=. 0.0 && x <. 2.0 } + |> should.be_true + } + + list.range(0, 100) + |> iterator.from_list + |> iterator.fold(Nil, one_random_to_test_set) } -// pub fn random_to_test() { -// let one_random_to_test_set = fn(_acc, _e) { -// float.random_to(0.0) -// |> should.equal(0.0) -// float.random_to(-1.0) -// |> fn(x) { x >=. -1.0 && x <. 0.0 } -// |> should.be_true -// float.random_to(1.0) -// |> fn(x) { x >=. 0.0 && x <. 1.0 } -// |> should.be_true -// float.random_to(2.0) -// |> fn(x) { x >=. 0.0 && x <. 2.0 } -// |> should.be_true -// } -// list.range(0, 100) -// |> iterator.from_list -// |> iterator.fold(Nil, one_random_to_test_set) -// } |