Results / elm-parser /
ParserAdvancedInContextTest
`Parser.Advanced.inContext` records its context on the dead ends of a parser that fails inside it. The inner parser is a `chompIf` whose predicate rejects every character, so running it on `"abc"` fails. The test checks that the first dead end's `contextStack` is not empty. Among what is not tested: which context the stack holds, its position, and nested contexts.
Results
elm-0.19.1
passran in 47 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. failed_with_context: True
elm-0.19.2
passran in 58 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. failed_with_context: True
elm-0.19.3
passran in 71 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. failed_with_context: True
lamdera-1.5.0
passran in 57 msOutput
failed_with_context: True
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-parser/ParserAdvancedInContextTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ParserAdvancedInContextTest exposing (main)
{-| `Parser.Advanced.inContext` records its context on the dead ends of a parser that fails inside it.
The inner parser is a `chompIf` whose predicate rejects every character, so
running it on `"abc"` fails. The test checks that the first dead end's
`contextStack` is not empty.
Among what is not tested: which context the stack holds, its position, and
nested contexts.
-}
-- CHECK: failed_with_context: True
import Html exposing (text)
import List
import Parser.Advanced as PA
type Context
= Definition String
type Prob
= ExpectedChar
p : PA.Parser Context Prob ()
p =
PA.inContext (Definition "top")
(PA.chompIf (\_ -> False) ExpectedChar)
main =
let
result = PA.run p "abc"
hasContext =
case result of
Err (de :: _) ->
List.length de.contextStack > 0
_ ->
False
_ = Debug.log "failed_with_context" hasContext
in
text "done"