diff options
author | Louis Pilfold <louis@lpil.uk> | 2021-08-08 18:46:14 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-08-08 18:46:14 +0100 |
commit | 7ca5f50aff6cb19c43ac39170e829cce1a48fdb9 (patch) | |
tree | b794a97a7d839f87532fb7ece92f627840d91a9b /test | |
parent | dd8a7bacc5db670bb084e8c77b02c0c1c44f605d (diff) | |
download | gleam_stdlib-7ca5f50aff6cb19c43ac39170e829cce1a48fdb9.tar.gz gleam_stdlib-7ca5f50aff6cb19c43ac39170e829cce1a48fdb9.zip |
JS float functions
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/float_test.gleam | 135 |
1 files changed, 66 insertions, 69 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam index 9eff3a3..a449f79 100644 --- a/test/gleam/float_test.gleam +++ b/test/gleam/float_test.gleam @@ -1,9 +1,6 @@ import gleam/should import gleam/float - -if erlang { - import gleam/order -} +import gleam/order pub fn parse_test() { "1.23" @@ -49,92 +46,92 @@ pub fn to_string_test() { |> should.equal("-8.1") } -if erlang { - pub fn clamp_test() { - float.clamp(1.4, min: 1.3, max: 1.5) - |> should.equal(1.4) +pub fn clamp_test() { + float.clamp(1.4, min: 1.3, max: 1.5) + |> should.equal(1.4) - float.clamp(1.2, min: 1.3, max: 1.5) - |> should.equal(1.3) + float.clamp(1.2, min: 1.3, max: 1.5) + |> should.equal(1.3) - float.clamp(1.6, min: 1.3, max: 1.5) - |> should.equal(1.5) - } + float.clamp(1.6, min: 1.3, max: 1.5) + |> should.equal(1.5) +} - pub fn compare_test() { - float.compare(0., 0.) - |> should.equal(order.Eq) +pub fn compare_test() { + float.compare(0., 0.) + |> should.equal(order.Eq) - float.compare(0.1, 0.1) - |> should.equal(order.Eq) + float.compare(0.1, 0.1) + |> should.equal(order.Eq) - float.compare(0., 0.1) - |> should.equal(order.Lt) + float.compare(0., 0.1) + |> should.equal(order.Lt) - float.compare(-2., -1.9) - |> should.equal(order.Lt) + float.compare(-2., -1.9) + |> should.equal(order.Lt) - float.compare(2., 1.9) - |> should.equal(order.Gt) + float.compare(2., 1.9) + |> should.equal(order.Gt) - float.compare(-1.9, -2.) - |> should.equal(order.Gt) - } + float.compare(-1.9, -2.) + |> should.equal(order.Gt) +} - pub fn ceiling_test() { - 8.1 - |> float.ceiling - |> should.equal(9.0) +pub fn ceiling_test() { + 8.1 + |> float.ceiling + |> should.equal(9.0) - -8.1 - |> float.ceiling - |> should.equal(-8.0) + -8.1 + |> float.ceiling + |> should.equal(-8.0) - -8.0 - |> float.ceiling - |> should.equal(-8.0) - } + -8.0 + |> float.ceiling + |> should.equal(-8.0) +} - pub fn floor_test() { - 8.1 - |> float.floor - |> should.equal(8.0) +pub fn floor_test() { + 8.1 + |> float.floor + |> should.equal(8.0) - -8.1 - |> float.floor - |> should.equal(-9.0) + -8.1 + |> float.floor + |> should.equal(-9.0) - -8.0 - |> float.floor - |> should.equal(-8.0) - } + -8.0 + |> float.floor + |> should.equal(-8.0) +} - pub fn round_test() { - 8.1 - |> float.round - |> should.equal(8) +pub fn round_test() { + 8.1 + |> float.round + |> should.equal(8) - 8.4 - |> float.round - |> should.equal(8) + 8.4 + |> float.round + |> should.equal(8) - 8.499 - |> float.round - |> should.equal(8) + 8.499 + |> float.round + |> should.equal(8) - 8.5 - |> float.round - |> should.equal(9) + 8.5 + |> float.round + |> should.equal(9) - -8.1 - |> float.round - |> should.equal(-8) + -8.1 + |> float.round + |> should.equal(-8) - -7.5 - |> float.round - |> should.equal(-8) - } + -7.5 + |> float.round + |> should.equal(-8) +} +if erlang { pub fn truncate_test() { 8.1 |> float.truncate |