StringToIntFloatTest
Checks that `String.toInt` and `String.toFloat` return `Just` the number for a numeric string and `Nothing` for a non-numeric one.
Results
elm-0.19.1
passran in 46 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. toInt_ok: Just 42 toInt_fail: Nothing toFloat_ok: Just 3.14 toFloat_fail: Nothing
elm-0.19.2
passran in 50 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. toInt_ok: Just 42 toInt_fail: Nothing toFloat_ok: Just 3.14 toFloat_fail: Nothing
elm-0.19.3
passran in 49 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. toInt_ok: Just 42 toInt_fail: Nothing toFloat_ok: Just 3.14 toFloat_fail: Nothing
lamdera-1.5.0
passran in 36 msOutput
toInt_ok: Just 42 toInt_fail: Nothing toFloat_ok: Just 3.14 toFloat_fail: Nothing
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/StringToIntFloatTest] in its title.
Source
The -- CHECK: lines give the expected output.
module StringToIntFloatTest exposing (main)
{-| Checks that `String.toInt` and `String.toFloat` return `Just` the number for a numeric string and `Nothing` for a non-numeric one.
-}
-- CHECK: toInt_ok: Just 42
-- CHECK: toInt_fail: Nothing
-- CHECK: toFloat_ok: Just 3.14
-- CHECK: toFloat_fail: Nothing
import Html exposing (text)
main =
let
_ = Debug.log "toInt_ok" (String.toInt "42")
_ = Debug.log "toInt_fail" (String.toInt "abc")
_ = Debug.log "toFloat_ok" (String.toFloat "3.14")
_ = Debug.log "toFloat_fail" (String.toFloat "xyz")
in
text "done"