Results / elm-parser /
ParserChompWhileTest
`Parser.chompWhile` chomps characters while the predicate holds and stops at the first that fails it. With `Char.isAlpha` on `"abc123"`, `getChompedString` returns `Ok "abc"`. The run succeeds although `"123"` is left, because nothing requires the end of input.
Results
elm-0.19.1
passran in 60 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. chomped: Ok "abc"
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. chomped: Ok "abc"
elm-0.19.3
passran in 72 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. chomped: Ok "abc"
lamdera-1.5.0
passran in 52 msOutput
chomped: Ok "abc"
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-parser/ParserChompWhileTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ParserChompWhileTest exposing (main)
{-| `Parser.chompWhile` chomps characters while the predicate holds and stops at the first that fails it.
With `Char.isAlpha` on `"abc123"`, `getChompedString` returns `Ok "abc"`. The
run succeeds although `"123"` is left, because nothing requires the end of
input.
-}
-- CHECK: chomped: Ok "abc"
import Char
import Html exposing (text)
import Parser
alphaP : Parser.Parser String
alphaP =
Parser.getChompedString (Parser.chompWhile Char.isAlpha)
main =
let
result = Parser.run alphaP "abc123"
_ = Debug.log "chomped" result
in
text "done"