Add more examples for Integer.parse

- show behavior of parsing with unparsable suffix bits
- show behavior of parsing float as integer
This commit is contained in:
Jay Hayes
2016-06-13 09:13:46 -05:00
parent 2127c9ea27
commit ec08c7fd7a
2 changed files with 10 additions and 0 deletions

View File

@@ -39,6 +39,14 @@ defmodule Numbers do
assert Integer.parse("2A", 16) == {___, ""}
end
koan "The remaining unparsable part is also returned" do
assert Integer.parse("5 years") == {5, ___}
end
koan "What if you parse a floating point value as an integer?" do
assert Integer.parse("1.2") == {___, ___}
end
koan "Just want to parse to a float" do
assert Float.parse("34.5") == {___, ""}
end