diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-04-22 22:33:15 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-04-22 22:33:15 +0000 |
commit | 077aaf3468c640b84ff53fc92171292ddae55bf4 (patch) | |
tree | a152edcc2240f053681ca6ba315dfeb9ed8fa793 /test/int_test.gleam | |
parent | afdabad5cd2df77eb3f309aab9da3d34e36a0b49 (diff) | |
download | gleam_stdlib-077aaf3468c640b84ff53fc92171292ddae55bf4.tar.gz gleam_stdlib-077aaf3468c640b84ff53fc92171292ddae55bf4.zip |
Int and float modules
Diffstat (limited to 'test/int_test.gleam')
-rw-r--r-- | test/int_test.gleam | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/int_test.gleam b/test/int_test.gleam new file mode 100644 index 0000000..d5f0f58 --- /dev/null +++ b/test/int_test.gleam @@ -0,0 +1,52 @@ +import expect +import int + +pub fn to_string() { + 123 + |> int:to_string + |> expect:equal(_, "123") + + -123 + |> int:to_string + |> expect:equal(_, "-123") + + 0123 + |> int:to_string + |> expect:equal(_, "123") +} + +pub fn parse() { + "123" + |> int:parse + |> expect:equal(_, Ok(123)) + + "-123" + |> int:parse + |> expect:equal(_, Ok(-123)) + + "0123" + |> int:parse + |> expect:equal(_, Ok(123)) + + "" + |> int:parse + |> expect:is_error + + "what" + |> int:parse + |> expect:is_error + + "1.23" + |> int:parse + |> expect:is_error +} + +pub fn to_base_string() { + 100 + |> int:to_base_string(_, 16) + |> expect:equal(_, "64") + + -100 + |> int:to_base_string(_, 16) + |> expect:equal(_, "-64") +} |