Elm Exactly
Results / elm-parser /

ParserIssue53ChompUntilOffsetPositionTest

Tags:elm19-bug

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

Issue: elm/parser#53

`chompUntil` leaves the parser's offset and its row/column out of sync.

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

`Elm.Kernel.Parser.findSubString` returns the offset of the start of the searched string but the
row and column after its end. After `chompUntil "bar"` on "foobar" (one line, so column = offset
+ 1), Elm 0.19.1 (elm/parser 1.1.0) reports offset 3 and column 7. They must agree: (3,4) or
(6,7).

Results

elm-0.19.1

failran in 60 ms
Missing pattern: {{(^|\n)offset and column: Ok \((3,4|6,7)\)(\n|$)}}
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
offset and column: Ok (3,7)

elm-0.19.2

failran in 65 ms
Missing pattern: {{(^|\n)offset and column: Ok \((3,4|6,7)\)(\n|$)}}
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
offset and column: Ok (3,7)

elm-0.19.3

failran in 74 ms
Missing pattern: {{(^|\n)offset and column: Ok \((3,4|6,7)\)(\n|$)}}
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
offset and column: Ok (3,7)

lamdera-1.5.0

failran in 53 ms
Missing pattern: {{(^|\n)offset and column: Ok \((3,4|6,7)\)(\n|$)}}
--- output ---
offset and column: Ok (3,7)

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module ParserIssue53ChompUntilOffsetPositionTest exposing (main)
{-| `chompUntil` leaves the parser's offset and its row/column out of sync.
<https://github.com/elm/parser/issues/53>
`Elm.Kernel.Parser.findSubString` returns the offset of the start of the searched string but the
row and column after its end. After `chompUntil "bar"` on "foobar" (one line, so column = offset
+ 1), Elm 0.19.1 (elm/parser 1.1.0) reports offset 3 and column 7. They must agree: (3,4) or
(6,7).
-}
-- TAGS: elm19-bug
-- CHECK: {{(^|\n)offset and column: Ok \((3,4|6,7)\)(\n|$)}}
import Html exposing (text)
import Parser exposing ((|.), (|=))
main =
let
p =
Parser.succeed Tuple.pair
|. Parser.chompUntil "bar"
|= Parser.getOffset
|= Parser.getCol
_ =
Debug.log "offset and column" (Parser.run p "foobar")
in
text "done"