Elm Exactly
Results / elm-core /

CharUnconsPatternTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
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 ms
Output
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 ms
Output
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 ms
Output
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 ms
Output
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"