Elm Exactly
Results / elm-parser /

ParserIssue20ChompUntilChompedStringTest

Tags:elm19-bug

elm-0.19.1 failelm-0.19.2 failelm-0.19.3 faillamdera-1.5.0 fail

Issue: elm/parser#20

After `chompUntil`, the chomped string and the position disagree.

<https://github.com/elm/parser/issues/20>

On "foobar", `getChompedString (chompUntil "bar")` followed by `getPosition` gives
`Ok ("foo",(1,7))` in Elm 0.19.1 (elm/parser 1.1.0): the position is past "bar" but the chomped
string (and the offset) stop before it. Either both include "bar", `("foobar",(1,7))`, or neither
does, `("foo",(1,4))`.

Results

elm-0.19.1

failran in 63 ms
Missing pattern: {{(^|\n)result: Ok \((("foobar",\(1,7\))|("foo",\(1,4\)))\)(\n|$)}}
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
result: Ok ("foo",(1,7))

elm-0.19.2

failran in 80 ms
Missing pattern: {{(^|\n)result: Ok \((("foobar",\(1,7\))|("foo",\(1,4\)))\)(\n|$)}}
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
result: Ok ("foo",(1,7))

elm-0.19.3

failran in 67 ms
Missing pattern: {{(^|\n)result: Ok \((("foobar",\(1,7\))|("foo",\(1,4\)))\)(\n|$)}}
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
result: Ok ("foo",(1,7))

lamdera-1.5.0

failran in 73 ms
Missing pattern: {{(^|\n)result: Ok \((("foobar",\(1,7\))|("foo",\(1,4\)))\)(\n|$)}}
--- output ---
result: Ok ("foo",(1,7))

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module ParserIssue20ChompUntilChompedStringTest exposing (main)
{-| After `chompUntil`, the chomped string and the position disagree.
<https://github.com/elm/parser/issues/20>
On "foobar", `getChompedString (chompUntil "bar")` followed by `getPosition` gives
`Ok ("foo",(1,7))` in Elm 0.19.1 (elm/parser 1.1.0): the position is past "bar" but the chomped
string (and the offset) stop before it. Either both include "bar", `("foobar",(1,7))`, or neither
does, `("foo",(1,4))`.
-}
-- TAGS: elm19-bug
-- CHECK: {{(^|\n)result: Ok \((("foobar",\(1,7\))|("foo",\(1,4\)))\)(\n|$)}}
import Html exposing (text)
import Parser exposing ((|=))
main =
let
chomper =
Parser.succeed Tuple.pair
|= Parser.getChompedString (Parser.chompUntil "bar")
|= Parser.getPosition
_ =
Debug.log "result" (Parser.run chomper "foobar")
in
text "done"