aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorConnor Schembor <cschembor96@gmail.com>2020-08-26 19:38:50 -0400
committerLouis Pilfold <louis@lpil.uk>2020-08-27 13:55:55 +0100
commit66653cae1a57435140b591683f3de429b3e87c3e (patch)
treedcfedeb9dc4f8893811ebc4064a2e9ce1468da7f /test
parent41d2256cb18cfb657ab6a0eaccb4f315e390b618 (diff)
downloadgleam_stdlib-66653cae1a57435140b591683f3de429b3e87c3e.tar.gz
gleam_stdlib-66653cae1a57435140b591683f3de429b3e87c3e.zip
Add square_root function for floats
Diffstat (limited to 'test')
-rw-r--r--test/gleam/float_test.gleam14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index 234df59..79bece2 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -217,3 +217,17 @@ pub fn power_test() {
float.power(2.0, -1.0)
|> should.equal(0.5)
}
+
+pub fn square_root_test() {
+ float.square_root(4.0)
+ |> should.equal(Ok(2.0))
+
+ float.square_root(16.0)
+ |> should.equal(Ok(4.0))
+
+ float.square_root(0.0)
+ |> should.equal(Ok(0.0))
+
+ float.square_root(-4.0)
+ |> should.equal(Error(Nil))
+}