Elm Exactly
Results / elm-parser /

ParserFloatTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Parser.float` parses a decimal number, with or without an exponent.

`"3.14"` gives `Ok 3.14` and `"1.5e-2"` gives `Ok 0.015`.

Among what is not tested: integers without a decimal point, signs, and
rejected forms such as hexadecimal.

Results

elm-0.19.1

passran in 48 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
parsed_float: Ok 3.14
parsed_exp: Ok 0.015

elm-0.19.2

passran in 48 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
parsed_float: Ok 3.14
parsed_exp: Ok 0.015

elm-0.19.3

passran in 61 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
parsed_float: Ok 3.14
parsed_exp: Ok 0.015

lamdera-1.5.0

passran in 72 ms
Output
parsed_float: Ok 3.14
parsed_exp: Ok 0.015

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-parser/ParserFloatTest] in its title.

Source

The -- CHECK: lines give the expected output.

module ParserFloatTest exposing (main)
{-| `Parser.float` parses a decimal number, with or without an exponent.
`"3.14"` gives `Ok 3.14` and `"1.5e-2"` gives `Ok 0.015`.
Among what is not tested: integers without a decimal point, signs, and
rejected forms such as hexadecimal.
-}
-- CHECK: parsed_float: Ok 3.14
-- CHECK: parsed_exp: Ok 0.015
import Html exposing (text)
import Parser
main =
let
_ = Debug.log "parsed_float" (Parser.run Parser.float "3.14")
_ = Debug.log "parsed_exp" (Parser.run Parser.float "1.5e-2")
in
text "done"