Elm Exactly
Results / elm-parser /

ParserEndTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Parser.end` succeeds only when no input is left.

The parser reads the symbol `"abc"` and then `end`. `at_end` runs it on
`"abc"` and checks for `Ok`; `not_end` runs it on `"abcx"` and checks for
`Err`.

Results

elm-0.19.1

passran in 53 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
at_end: True
not_end: True

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.
at_end: True
not_end: True

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.
at_end: True
not_end: True

lamdera-1.5.0

passran in 70 ms
Output
at_end: True
not_end: True

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module ParserEndTest exposing (main)
{-| `Parser.end` succeeds only when no input is left.
The parser reads the symbol `"abc"` and then `end`. `at_end` runs it on
`"abc"` and checks for `Ok`; `not_end` runs it on `"abcx"` and checks for
`Err`.
-}
-- CHECK: at_end: True
-- CHECK: not_end: True
import Html exposing (text)
import Parser exposing ((|.))
myParser : Parser.Parser ()
myParser =
Parser.succeed ()
|. Parser.symbol "abc"
|. Parser.end
main =
let
ok_ = Parser.run myParser "abc"
_ = Debug.log "at_end"
(case ok_ of
Ok _ -> True
Err _ -> False
)
bad = Parser.run myParser "abcx"
_ = Debug.log "not_end"
(case bad of
Err _ -> True
Ok _ -> False
)
in
text "done"