aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2022-04-12 01:57:46 +0200
committerLouis Pilfold <louis@lpil.uk>2022-04-16 10:23:34 +0100
commitdc71009b74846164a70814b103d36ff7381cfc82 (patch)
treeda42505702dfa1bfbff656e3b12085e698daa32e /test
parentaa77e878fd9a9e6289d0f41f0c5156c00e54a8a3 (diff)
downloadgleam_stdlib-dc71009b74846164a70814b103d36ff7381cfc82.tar.gz
gleam_stdlib-dc71009b74846164a70814b103d36ff7381cfc82.zip
erlang-bug
Diffstat (limited to 'test')
-rw-r--r--test/gleam/float_test.gleam57
-rw-r--r--test/gleam/int_test.gleam96
2 files changed, 99 insertions, 54 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index 6c87f65..39fa9a8 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -3,6 +3,8 @@ import gleam/float
import gleam/order
import gleam/list
import gleam/iterator
+import gleam/function
+import gleam/io
pub fn parse_test() {
"1.23"
@@ -307,11 +309,13 @@ pub fn random_uniform_test() {
let one_random_uniform_test_set = fn(_acc, _e) {
{ float.random_uniform() >=. 0. }
|> should.be_true()
+
{ float.random_uniform() <. 0. }
|> should.be_false()
{ float.random_uniform() <. 1. }
|> should.be_true()
+
{ float.random_uniform() >=. 1. }
|> should.be_false()
@@ -321,3 +325,56 @@ pub fn random_uniform_test() {
|> iterator.from_list
|> iterator.fold(Nil, one_random_uniform_test_set)
}
+
+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)
+ |> 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)
+}
+// 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)
+// }
diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam
index 203eb37..b7a425b 100644
--- a/test/gleam/int_test.gleam
+++ b/test/gleam/int_test.gleam
@@ -318,57 +318,45 @@ pub fn undigits_test() {
int.undigits([1, 1, 2], 2)
|> should.equal(Error(int.InvalidBase))
}
-
-pub fn random_between_test() {
- let one_random_between_test_set = fn(_acc, _e) {
- int.random_between(0, 0)
- |> should.equal(0)
-
- int.random_between(-1, 0)
- |> list.contains([-1, 0], _)
- |> should.be_true
-
- int.random_between(-1, 1)
- |> list.contains([-1, 0], _)
- |> should.be_true
-
- int.random_between(-1, 2)
- |> list.contains([-1, 0, 1], _)
- |> should.be_true
- }
-
- list.range(0, 100)
- |> iterator.from_list
- |> iterator.fold(Nil, one_random_between_test_set)
-}
-
-pub fn random_below_test() {
- let one_random_below_test_set = fn(_acc, _e) {
- int.random_below(0)
- |> should.equal(0)
-
- int.random_below(-1)
- |> list.contains([-1], _)
- |> should.be_true
-
- int.random_below(1)
- |> list.contains([0], _)
- |> should.be_true
-
- int.random_below(2)
- |> list.contains([0, 1], _)
- |> should.be_true
-
- int.random_below(3)
- |> list.contains([0, 1, 2], _)
- |> should.be_true
-
- int.random_below(4)
- |> list.contains([0, 1, 2, 3], _)
- |> should.be_true
- }
-
- list.range(0, 100)
- |> iterator.from_list
- |> iterator.fold(Nil, one_random_below_test_set)
-}
+// pub fn random_between_test() {
+// let one_random_between_test_set = fn(_acc, _e) {
+// int.random_between(0, 0)
+// |> should.equal(0)
+// int.random_between(-1, 0)
+// |> list.contains([-1, 0], _)
+// |> should.be_true
+// int.random_between(-1, 1)
+// |> list.contains([-1, 0], _)
+// |> should.be_true
+// int.random_between(-1, 2)
+// |> list.contains([-1, 0, 1], _)
+// |> 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) {
+// int.random_to(0)
+// |> should.equal(0)
+// int.random_to(-1)
+// |> list.contains([-1], _)
+// |> should.be_true
+// int.random_to(1)
+// |> list.contains([0], _)
+// |> should.be_true
+// int.random_to(2)
+// |> list.contains([0, 1], _)
+// |> should.be_true
+// int.random_to(3)
+// |> list.contains([0, 1, 2], _)
+// |> should.be_true
+// int.random_to(4)
+// |> list.contains([0, 1, 2, 3], _)
+// |> should.be_true
+// }
+// list.range(0, 100)
+// |> iterator.from_list
+// |> iterator.fold(Nil, one_random_to_test_set)
+// }