CharUnconsPatternTest
A Char taken from a String by `String.uncons` matches the Char literal pattern `'"'`, and is `==` to the literal. `String.uncons "\"x"` gives `Just ( '"', "x" )`. The first case matches it with the literal pattern, the second binds the Char and compares it with `==`. Both should log `"y"`. The same patterns on Chars written as literals are checked by elm's CharLiteralPatternMatchMinimalTest.
Results
elm-0.19.1
passran in 58 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. uncons_pat: "y" uncons_eq: "y"
elm-0.19.2
passran in 58 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. uncons_pat: "y" uncons_eq: "y"
elm-0.19.3
passran in 74 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. uncons_pat: "y" uncons_eq: "y"
lamdera-1.5.0
passran in 38 msOutput
uncons_pat: "y" uncons_eq: "y"
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/CharUnconsPatternTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CharUnconsPatternTest exposing (main)
{-| A Char taken from a String by `String.uncons` matches the Char literal pattern `'"'`, and is
`==` to the literal.
`String.uncons "\"x"` gives `Just ( '"', "x" )`. The first case matches it with the literal
pattern, the second binds the Char and compares it with `==`. Both should log `"y"`. The same
patterns on Chars written as literals are checked by elm's CharLiteralPatternMatchMinimalTest.
-}
-- CHECK: uncons_pat: "y"
-- CHECK: uncons_eq: "y"
import Html exposing (text)
main =
let
withPattern =
case String.uncons "\"x" of
Just ( '"', _ ) ->
"y"
_ ->
"n"
withEq =
case String.uncons "\"x" of
Just ( c, _ ) ->
if c == '"' then
"y"
else
"n"
Nothing ->
"n"
_ =
Debug.log "uncons_pat" withPattern
_ =
Debug.log "uncons_eq" withEq
in
text "done"