Elm Exactly
Results / elm-core /

StringToIntFloatTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
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 ms
Output
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 ms
Output
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 ms
Output
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 ms
Output
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"