Results / elm-parser /
ParserNumberTest
Checks that `Parser.number` reads decimal and hexadecimal integers. With int, hex, octal and binary enabled and floats disabled, `"42"` gives `Ok 42` and `"0xff"` gives `Ok 255`. Among what is not tested: octal and binary input (see `ParserOctalBinaryIntTest`), and failure cases.
Results
elm-0.19.1
passran in 66 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. int_value: Ok 42 hex_value: Ok 255
elm-0.19.2
passran in 59 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. int_value: Ok 42 hex_value: Ok 255
elm-0.19.3
passran in 63 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. int_value: Ok 42 hex_value: Ok 255
lamdera-1.5.0
passran in 74 msOutput
int_value: Ok 42 hex_value: Ok 255
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-parser/ParserNumberTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ParserNumberTest exposing (main)
{-| Checks that `Parser.number` reads decimal and hexadecimal integers.
With int, hex, octal and binary enabled and floats disabled, `"42"` gives
`Ok 42` and `"0xff"` gives `Ok 255`.
Among what is not tested: octal and binary input (see
`ParserOctalBinaryIntTest`), and failure cases.
-}
-- CHECK: int_value: Ok 42
-- CHECK: hex_value: Ok 255
import Html exposing (text)
import Parser
myNum : Parser.Parser Int
myNum =
Parser.number
{ int = Just identity
, hex = Just identity
, octal = Just identity
, binary = Just identity
, float = Nothing
}
main =
let
_ = Debug.log "int_value" (Parser.run myNum "42")
_ = Debug.log "hex_value" (Parser.run myNum "0xff")
in
text "done"