Elm Exactly
Results / elm-core /

StringSplitTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks `String.split` with a single-character separator, a multi-character separator and a trailing separator, plus the number of pieces.

The pieces are joined with `"|"` before logging, so the expected output does
not depend on how a `List String` is printed. A trailing separator yields a
final empty piece: splitting `"a,"` on `","` gives `[ "a", "" ]`.

Results

elm-0.19.1

passran in 44 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
split_comma: "a|b|c"
split_multichar: "ab|cd"
split_trailing: "a|"
split_count: 3

elm-0.19.2

passran in 37 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
split_comma: "a|b|c"
split_multichar: "ab|cd"
split_trailing: "a|"
split_count: 3

elm-0.19.3

passran in 42 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
split_comma: "a|b|c"
split_multichar: "ab|cd"
split_trailing: "a|"
split_count: 3

lamdera-1.5.0

passran in 38 ms
Output
split_comma: "a|b|c"
split_multichar: "ab|cd"
split_trailing: "a|"
split_count: 3

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringSplitTest exposing (main)
{-| Checks `String.split` with a single-character separator, a multi-character separator and a trailing separator, plus the number of pieces.
The pieces are joined with `"|"` before logging, so the expected output does
not depend on how a `List String` is printed. A trailing separator yields a
final empty piece: splitting `"a,"` on `","` gives `[ "a", "" ]`.
-}
-- CHECK: split_comma: "a|b|c"
-- CHECK: split_multichar: "ab|cd"
-- CHECK: split_trailing: "a|"
-- CHECK: split_count: 3
import Html exposing (text)
main =
let
_ =
Debug.log "split_comma" (String.join "|" (String.split "," "a,b,c"))
_ =
Debug.log "split_multichar" (String.join "|" (String.split "::" "ab::cd"))
_ =
Debug.log "split_trailing" (String.join "|" (String.split "," "a,"))
_ =
Debug.log "split_count" (List.length (String.split "," "a,b,c"))
in
text "done"