Elm Exactly
Results / elm-core /

StringAstralToListFromListTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`String.toList` gives one `Char` for a character outside the Basic
Multilingual Plane, such as an emoji, and `String.fromList` turns it back into
the same string.

`String.toList "a๐Ÿ˜€b"` has 3 elements with codes `[97,128512,98]`, and
`String.fromList` of it equals `"a๐Ÿ˜€b"`. A list made with `Char.fromCode` from
`0x61`, `0x1F600` and `0x62` also gives `"a๐Ÿ˜€b"`, whose `String.length` is 4
because `String.length` counts UTF-16 units and the emoji takes two.

Results

elm-0.19.1

passran in 51 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
tolist_len: 3
tolist_codes: [97,128512,98]
roundtrip_ok: True
fromlist_ok: True
fromlist_units: 4

elm-0.19.2

passran in 55 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
tolist_len: 3
tolist_codes: [97,128512,98]
roundtrip_ok: True
fromlist_ok: True
fromlist_units: 4

elm-0.19.3

passran in 38 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
tolist_len: 3
tolist_codes: [97,128512,98]
roundtrip_ok: True
fromlist_ok: True
fromlist_units: 4

lamdera-1.5.0

passran in 48 ms
Output
tolist_len: 3
tolist_codes: [97,128512,98]
roundtrip_ok: True
fromlist_ok: True
fromlist_units: 4

Discussions

Discuss this testยทSearch the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringAstralToListFromListTest exposing (main)
{-| `String.toList` gives one `Char` for a character outside the Basic
Multilingual Plane, such as an emoji, and `String.fromList` turns it back into
the same string.
`String.toList "a๐Ÿ˜€b"` has 3 elements with codes `[97,128512,98]`, and
`String.fromList` of it equals `"a๐Ÿ˜€b"`. A list made with `Char.fromCode` from
`0x61`, `0x1F600` and `0x62` also gives `"a๐Ÿ˜€b"`, whose `String.length` is 4
because `String.length` counts UTF-16 units and the emoji takes two.
-}
-- CHECK: tolist_len: 3
-- CHECK: tolist_codes: [97,128512,98]
-- CHECK: roundtrip_ok: True
-- CHECK: fromlist_ok: True
-- CHECK: fromlist_units: 4
import Html exposing (text)
main =
let
built =
String.fromList (List.map Char.fromCode [ 0x61, 0x0001F600, 0x62 ])
_ =
Debug.log "tolist_len" (List.length (String.toList "a๐Ÿ˜€b"))
_ =
Debug.log "tolist_codes" (List.map Char.toCode (String.toList "a๐Ÿ˜€b"))
_ =
Debug.log "roundtrip_ok" (String.fromList (String.toList "a๐Ÿ˜€b") == "a๐Ÿ˜€b")
_ =
Debug.log "fromlist_ok" (built == "a๐Ÿ˜€b")
_ =
Debug.log "fromlist_units" (String.length built)
in
text "done"