Results / elm-parser /
ParserAdvancedDeadEndTest
`Parser.Advanced.run` reports a failed `token` with the custom problem value given in its `Token`. The parser expects the token `"hello"` and is run on `"world"`. The test checks that the run fails and that the first dead end's `problem` is `Expected "hello"`, the value supplied with the token. Among what is not tested: the dead end's row, column and context stack, and any dead ends after the first.
Results
elm-0.19.1
passran in 44 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. custom_problem: True
elm-0.19.2
passran in 43 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. custom_problem: True
elm-0.19.3
passran in 61 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. custom_problem: True
lamdera-1.5.0
passran in 43 msOutput
custom_problem: True
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-parser/ParserAdvancedDeadEndTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ParserAdvancedDeadEndTest exposing (main)
{-| `Parser.Advanced.run` reports a failed `token` with the custom problem value given in its `Token`.
The parser expects the token `"hello"` and is run on `"world"`. The test
checks that the run fails and that the first dead end's `problem` is
`Expected "hello"`, the value supplied with the token.
Among what is not tested: the dead end's row, column and context stack, and
any dead ends after the first.
-}
-- CHECK: custom_problem: True
import Html exposing (text)
import Parser.Advanced as PA
type MyProblem
= Expected String
p : PA.Parser c MyProblem ()
p =
PA.token (PA.Token "hello" (Expected "hello"))
main =
let
result = PA.run p "world"
hasExpected =
case result of
Err (de :: _) ->
case de.problem of
Expected s ->
s == "hello"
_ ->
False
_ = Debug.log "custom_problem" hasExpected
in
text "done"