Elm Exactly
Results / elm-core /

StringWordsUnicodeSpaceTest

Tags:elm-unspecced

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`String.words` splits on non-ASCII whitespace (U+00A0, U+3000, U+2028) and gives `[""]` for a
string that is only whitespace.

The inputs have whitespace around one word, between two words, around and between two words,
and as the whole string.

A Standard Definition of Elm? does not decide this test: `String.words` is library, outside the
definition. `CoreIssue1019StringWordsEmptyTest` expects `[]`, not `[""]`, for a string that is
only whitespace; the two record different views of the library, not of the language.

Results

elm-0.19.1

passran in 60 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
nbsp around: ["a"]
nbsp between: ["a","b"]
ideographic only: [""]
mixed only: [""]
mixed around two: ["x","y"]

elm-0.19.2

passran in 60 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
nbsp around: ["a"]
nbsp between: ["a","b"]
ideographic only: [""]
mixed only: [""]
mixed around two: ["x","y"]

elm-0.19.3

passran in 40 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
nbsp around: ["a"]
nbsp between: ["a","b"]
ideographic only: [""]
mixed only: [""]
mixed around two: ["x","y"]

lamdera-1.5.0

passran in 48 ms
Output
nbsp around: ["a"]
nbsp between: ["a","b"]
ideographic only: [""]
mixed only: [""]
mixed around two: ["x","y"]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringWordsUnicodeSpaceTest exposing (main)
{-| `String.words` splits on non-ASCII whitespace (U+00A0, U+3000, U+2028) and gives `[""]` for a
string that is only whitespace.
The inputs have whitespace around one word, between two words, around and between two words,
and as the whole string.
A Standard Definition of Elm? does not decide this test: `String.words` is library, outside the
definition. `CoreIssue1019StringWordsEmptyTest` expects `[]`, not `[""]`, for a string that is
only whitespace; the two record different views of the library, not of the language.
-}
-- TAGS: elm-unspecced
-- MODE-GUARD: a Char equality must give the same answer as under --optimize
-- NO-SKIP: an edge case every compiler must run
-- UNICODE: 17.0
-- CHECK: nbsp around: ["a"]
-- CHECK: nbsp between: ["a","b"]
-- CHECK: ideographic only: [""]
-- CHECK: mixed only: [""]
-- CHECK: mixed around two: ["x","y"]
main : Program () () ()
main =
Platform.worker
{ init =
\_ ->
let
_ =
Debug.log "nbsp around" (String.words "\u{00A0}a\u{3000}")
_ =
Debug.log "nbsp between" (String.words "a\u{00A0}b")
_ =
Debug.log "ideographic only" (String.words "\u{3000}")
_ =
Debug.log "mixed only" (String.words " \u{00A0}\t\u{3000}\n")
_ =
Debug.log "mixed around two" (String.words "\u{3000} x\u{00A0}\u{00A0}y \u{2028}")
in
( (), Cmd.none )
, update = \_ model -> ( model, Cmd.none )
, subscriptions = \_ -> Sub.none
}