StringAstralReverseTest
`String.reverse` keeps a character outside the Basic Multilingual Plane, such as an emoji, whole, rather than reversing the two UTF-16 units it is stored as. The test checks that reversing `"a๐b"` equals reversing its `String.toList`, that it gives `"b๐a"`, and that reversing `"x๐๐y"` twice returns it unchanged.
Results
elm-0.19.1
passran in 60 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. rev_matches_codepoint: True rev_pair_kept: True rev_twice_id: True
elm-0.19.2
passran in 53 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. rev_matches_codepoint: True rev_pair_kept: True rev_twice_id: True
elm-0.19.3
passran in 48 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. rev_matches_codepoint: True rev_pair_kept: True rev_twice_id: True
lamdera-1.5.0
passran in 44 msOutput
rev_matches_codepoint: True rev_pair_kept: True rev_twice_id: True
Discussions
Discuss this testยทSearch the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/StringAstralReverseTest] in its title.
Source
The -- CHECK: lines give the expected output.
module StringAstralReverseTest exposing (main)
{-| `String.reverse` keeps a character outside the Basic Multilingual Plane,
such as an emoji, whole, rather than reversing the two UTF-16 units it is
stored as.
The test checks that reversing `"a๐b"` equals reversing its `String.toList`,
that it gives `"b๐a"`, and that reversing `"x๐๐y"` twice returns it unchanged.
-}
-- CHECK: rev_matches_codepoint: True
-- CHECK: rev_pair_kept: True
-- CHECK: rev_twice_id: True
import Html exposing (text)
main =
let
_ =
Debug.log "rev_matches_codepoint"
(String.reverse "a๐b"
== String.fromList (List.reverse (String.toList "a๐b"))
)
_ =
Debug.log "rev_pair_kept" (String.reverse "a๐b" == "b๐a")
_ =
Debug.log "rev_twice_id" (String.reverse (String.reverse "x๐๐y") == "x๐๐y")
in
text "done"