Elm Exactly
Results / elm-parser /

ParserKeywordTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks that `Parser.keyword` matches a whole word but not the prefix of a longer identifier.

`keyword "let"` succeeds on `"let "`, where a space follows, and fails on
`"letter"`, where the next character could continue the word. Compare
`ParserTokenTest`, where `token "let"` succeeds on `"letter"`.

Results

elm-0.19.1

passran in 59 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
letok: True
letterfail: True

elm-0.19.2

passran in 45 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
letok: True
letterfail: True

elm-0.19.3

passran in 64 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
letok: True
letterfail: True

lamdera-1.5.0

passran in 78 ms
Output
letok: True
letterfail: True

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module ParserKeywordTest exposing (main)
{-| Checks that `Parser.keyword` matches a whole word but not the prefix of a longer identifier.
`keyword "let"` succeeds on `"let "`, where a space follows, and fails on
`"letter"`, where the next character could continue the word. Compare
`ParserTokenTest`, where `token "let"` succeeds on `"letter"`.
-}
-- CHECK: letok: True
-- CHECK: letterfail: True
import Html exposing (text)
import Parser
main =
let
ok_ = Parser.run (Parser.keyword "let") "let "
_ = Debug.log "letok"
(case ok_ of
Ok _ -> True
Err _ -> False
)
bad = Parser.run (Parser.keyword "let") "letter"
_ = Debug.log "letterfail"
(case bad of
Err _ -> True
Ok _ -> False
)
in
text "done"