Results / elm-parser /
ParserPipelineTest
Checks that `|=` and `|.` build a record from parsed fields while discarding punctuation.
`point` parses `"(3,4)"` into `Ok { x = 3, y = 4 }` using the `Point` record
constructor.Results
elm-0.19.1
passran in 54 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
point: Ok { x = 3, y = 4 }
elm-0.19.2
passran in 70 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
point: Ok { x = 3, y = 4 }
elm-0.19.3
passran in 58 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
point: Ok { x = 3, y = 4 }
lamdera-1.5.0
passran in 50 msOutput
point: Ok { x = 3, y = 4 }
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-parser/ParserPipelineTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ParserPipelineTest exposing (main)
{-| Checks that `|=` and `|.` build a record from parsed fields while discarding punctuation.
`point` parses `"(3,4)"` into `Ok { x = 3, y = 4 }` using the `Point` record
constructor.
-}
-- CHECK: point: Ok { x = 3, y = 4 }
import Html exposing (text)
import Parser exposing ((|.), (|=))
type alias Point =
{ x : Int, y : Int }
point : Parser.Parser Point
point =
Parser.succeed Point
|. Parser.symbol "("
|= Parser.int
|. Parser.symbol ","
|= Parser.int
|. Parser.symbol ")"
main =
let
result = Parser.run point "(3,4)"
_ = Debug.log "point" result
in
text "done"