Elm Exactly
Results / elm-core /

StringAstralMapTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`String.map` applies its function once to a character outside the Basic
Multilingual Plane, such as an emoji, and can produce such a character.

Mapping every character of `"a๐Ÿ˜€b"` to `'x'` gives `"xxx"`, of length 3.
`String.map identity` returns `"a๐Ÿ˜€b"` unchanged. Mapping every character of
`"ab๐Ÿ˜€"` to `'๐Ÿ˜€'` gives `"๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€"`, whose `String.length` is 6 because
`String.length` counts UTF-16 units and each emoji takes two.

Results

elm-0.19.1

passran in 36 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
map_const_len: 3
map_const_ok: True
map_id_ok: True
map_to_astral_ok: True
map_to_astral_len: 6

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.
map_const_len: 3
map_const_ok: True
map_id_ok: True
map_to_astral_ok: True
map_to_astral_len: 6

elm-0.19.3

passran in 49 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
map_const_len: 3
map_const_ok: True
map_id_ok: True
map_to_astral_ok: True
map_to_astral_len: 6

lamdera-1.5.0

passran in 36 ms
Output
map_const_len: 3
map_const_ok: True
map_id_ok: True
map_to_astral_ok: True
map_to_astral_len: 6

Discussions

Discuss this testยทSearch the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringAstralMapTest exposing (main)
{-| `String.map` applies its function once to a character outside the Basic
Multilingual Plane, such as an emoji, and can produce such a character.
Mapping every character of `"a๐Ÿ˜€b"` to `'x'` gives `"xxx"`, of length 3.
`String.map identity` returns `"a๐Ÿ˜€b"` unchanged. Mapping every character of
`"ab๐Ÿ˜€"` to `'๐Ÿ˜€'` gives `"๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€"`, whose `String.length` is 6 because
`String.length` counts UTF-16 units and each emoji takes two.
-}
-- CHECK: map_const_len: 3
-- CHECK: map_const_ok: True
-- CHECK: map_id_ok: True
-- CHECK: map_to_astral_ok: True
-- CHECK: map_to_astral_len: 6
import Html exposing (text)
main =
let
_ =
Debug.log "map_const_len" (String.length (String.map (\_ -> 'x') "a๐Ÿ˜€b"))
_ =
Debug.log "map_const_ok" (String.map (\_ -> 'x') "a๐Ÿ˜€b" == "xxx")
_ =
Debug.log "map_id_ok" (String.map identity "a๐Ÿ˜€b" == "a๐Ÿ˜€b")
_ =
Debug.log "map_to_astral_ok" (String.map (\_ -> '๐Ÿ˜€') "ab๐Ÿ˜€" == "๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€")
_ =
Debug.log "map_to_astral_len" (String.length (String.map (\_ -> '๐Ÿ˜€') "ab๐Ÿ˜€"))
in
text "done"