arowM/elm-parser-test/1.1.0

Parser.Test

Helper functions to develop/test your own parser using elm/parser.

Core

run : Parser a -> String -> ( Result (List DeadEnd) a, Bool )

Check if a parser is backtrackable or not.

import Parser


run (Parser.keyword "import") "imp" |> Tuple.mapFirst (Result.mapError (\_ -> ()))
--> (Err (), True)


run (Parser.keyword "import") "import"
--> (Ok (), False)


run Parser.spaces "  "
--> (Ok (), False)


run (Parser.backtrackable Parser.spaces) "  "
--> (Ok (), True)
run_ : Parser a -> String -> ( Maybe a, Bool )

Same as run but returns Maybe a instead. This is useful to implement tests for your own parsers.

import Parser


run_ (Parser.keyword "import") "imp"
--> (Nothing, True)


run_ (Parser.keyword "import") "import"
--> (Just (), False)