Results / elm-parser /
ParserIssue46LineCommentNewlineTest
Tags:elm19-bug
Issue: elm/parser#46
`lineComment` counts the ending newline in the row but leaves it in the input, so the newline is counted twice. <https://github.com/elm/parser/issues/46> On "-- hi\nx", `lineComment "--"` followed by `spaces` and `getPosition` gives `(3,1)` in Elm 0.19.1 (elm/parser 1.1.0): `lineComment` moves the row past the newline without consuming it, and `spaces` then counts it again. `x` is on row 2, column 1.
Results
elm-0.19.1
failran in 61 msMissing pattern: position: Ok (2,1) --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. position: Ok (3,1)
elm-0.19.2
failran in 53 msMissing pattern: position: Ok (2,1) --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. position: Ok (3,1)
elm-0.19.3
failran in 75 msMissing pattern: position: Ok (2,1) --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. position: Ok (3,1)
lamdera-1.5.0
failran in 50 msMissing pattern: position: Ok (2,1) --- output --- position: Ok (3,1)
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-parser/ParserIssue46LineCommentNewlineTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ParserIssue46LineCommentNewlineTest exposing (main)
{-| `lineComment` counts the ending newline in the row but leaves it in the input, so the newline
is counted twice.
<https://github.com/elm/parser/issues/46>
On "-- hi\nx", `lineComment "--"` followed by `spaces` and `getPosition` gives `(3,1)` in Elm
0.19.1 (elm/parser 1.1.0): `lineComment` moves the row past the newline without consuming it, and
`spaces` then counts it again. `x` is on row 2, column 1.
-}
-- TAGS: elm19-bug
-- CHECK: position: Ok (2,1)
import Html exposing (text)
import Parser exposing ((|.), (|=))
main =
let
p =
Parser.succeed identity
|. Parser.lineComment "--"
|. Parser.spaces
|= Parser.getPosition
_ =
Debug.log "position" (Parser.run p "-- hi\nx")
in
text "done"