StringAstralMapTest
`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 msOutput
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 msOutput
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 msOutput
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 msOutput
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"