diff options
author | inoas <mail@inoas.com> | 2022-05-03 09:29:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 10:29:02 +0100 |
commit | 4d13e36b03e31ee4ea17e0e615fd215815c4b3c6 (patch) | |
tree | 9e6eb88b2fb4f30d603c1c0401f7a7f4f3588b4f /test | |
parent | 83c3b6c4bd79b9be858011f05683634469c06458 (diff) | |
download | gleam_stdlib-4d13e36b03e31ee4ea17e0e615fd215815c4b3c6.tar.gz gleam_stdlib-4d13e36b03e31ee4ea17e0e615fd215815c4b3c6.zip |
Power and square_root for ints
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/int_test.gleam | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam index 7dc5d0d..7c7ba0f 100644 --- a/test/gleam/int_test.gleam +++ b/test/gleam/int_test.gleam @@ -255,6 +255,37 @@ pub fn is_odd_test() { |> should.be_true } +pub fn power_test() { + int.power(2, 2.0) + |> should.equal(4.0) + + int.power(-5, 3.0) + |> should.equal(-125.0) + + int.power(10, 0.0) + |> should.equal(1.0) + + int.power(16, 0.5) + |> should.equal(4.0) + + int.power(2, -1.0) + |> should.equal(0.5) +} + +pub fn square_root_test() { + int.square_root(4) + |> should.equal(Ok(2.0)) + + int.square_root(16) + |> should.equal(Ok(4.0)) + + int.square_root(0) + |> should.equal(Ok(0.0)) + + int.square_root(-4) + |> should.equal(Error(Nil)) +} + pub fn negate_test() { int.negate(-1) |> should.equal(1) |