Elm Exactly
Results / elm-core /

StringAstralLengthTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`String.length` counts UTF-16 code units, so a character outside the Basic Multilingual Plane counts as 2.

U+1F600 (๐Ÿ˜€) is encoded as a surrogate pair. `String.length "๐Ÿ˜€"` is 2, and
`String.length "a๐Ÿ˜€b"` is 4. The test also requires such a character to survive
inside a string literal.

Results

elm-0.19.1

passran in 43 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
len_astral: 2
len_mixed: 4

elm-0.19.2

passran in 35 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
len_astral: 2
len_mixed: 4

elm-0.19.3

passran in 61 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
len_astral: 2
len_mixed: 4

lamdera-1.5.0

passran in 38 ms
Output
len_astral: 2
len_mixed: 4

Discussions

Discuss this testยทSearch the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringAstralLengthTest exposing (main)
{-| `String.length` counts UTF-16 code units, so a character outside the Basic Multilingual Plane counts as 2.
U+1F600 (๐Ÿ˜€) is encoded as a surrogate pair. `String.length "๐Ÿ˜€"` is 2, and
`String.length "a๐Ÿ˜€b"` is 4. The test also requires such a character to survive
inside a string literal.
-}
-- CHECK: len_astral: 2
-- CHECK: len_mixed: 4
import Html exposing (text)
main =
let
_ =
Debug.log "len_astral" (String.length "๐Ÿ˜€")
_ =
Debug.log "len_mixed" (String.length "a๐Ÿ˜€b")
in
text "done"