aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2021-08-06 10:35:09 +0100
committerLouis Pilfold <louis@lpil.uk>2021-08-06 10:35:09 +0100
commit4bc5ec9bcca768c52b07b7398b385a574d0a6b15 (patch)
treea81e935912f439c4a6a0d62b07c0d34ff18cfcff /test
parent8ef4b3b7cb02674b06a6f172ce83697a158e53ac (diff)
downloadgleam_stdlib-4bc5ec9bcca768c52b07b7398b385a574d0a6b15.tar.gz
gleam_stdlib-4bc5ec9bcca768c52b07b7398b385a574d0a6b15.zip
float.parse
Diffstat (limited to 'test')
-rw-r--r--test/gleam/float_test.gleam55
1 files changed, 33 insertions, 22 deletions
diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam
index 79dba56..774f448 100644
--- a/test/gleam/float_test.gleam
+++ b/test/gleam/float_test.gleam
@@ -1,34 +1,45 @@
+import gleam/should
+import gleam/float
+
if erlang {
- import gleam/should
- import gleam/float
import gleam/order
+}
- pub fn parse_test() {
- "1.23"
- |> float.parse
- |> should.equal(Ok(1.23))
+pub fn parse_test() {
+ "1.23"
+ |> float.parse
+ |> should.equal(Ok(1.23))
- "5.0"
- |> float.parse
- |> should.equal(Ok(5.0))
+ "+1.23"
+ |> float.parse
+ |> should.equal(Ok(1.23))
- "0.123456789"
- |> float.parse
- |> should.equal(Ok(0.123456789))
+ "-1.23"
+ |> float.parse
+ |> should.equal(Ok(1.23))
- ""
- |> float.parse
- |> should.equal(Error(Nil))
+ "5.0"
+ |> float.parse
+ |> should.equal(Ok(5.0))
- "what"
- |> float.parse
- |> should.equal(Error(Nil))
+ "0.123456789"
+ |> float.parse
+ |> should.equal(Ok(0.123456789))
- "1"
- |> float.parse
- |> should.equal(Error(Nil))
- }
+ ""
+ |> float.parse
+ |> should.equal(Error(Nil))
+
+ "what"
+ |> float.parse
+ |> should.equal(Error(Nil))
+ "1"
+ |> float.parse
+ |> should.equal(Error(Nil))
+}
+
+if erlang {
pub fn to_string_test() {
123.0
|> float.to_string