Elm Exactly
Results / elm-core /

StringSliceTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks `String.slice` with positive indexes and with negative indexes, which count back from the end of the string.

`String.slice 1 -1 "Hello"` drops the first and last characters, giving
`"ell"`, and `String.slice -3 5 "World"` gives the last three characters,
`"rld"`.

Results

elm-0.19.1

passran in 69 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
slice1: "ell"
slice_neg: "ell"
slice_start: "Hel"
slice_end: "rld"

elm-0.19.2

passran in 44 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
slice1: "ell"
slice_neg: "ell"
slice_start: "Hel"
slice_end: "rld"

elm-0.19.3

passran in 47 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
slice1: "ell"
slice_neg: "ell"
slice_start: "Hel"
slice_end: "rld"

lamdera-1.5.0

passran in 45 ms
Output
slice1: "ell"
slice_neg: "ell"
slice_start: "Hel"
slice_end: "rld"

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringSliceTest exposing (main)
{-| Checks `String.slice` with positive indexes and with negative indexes, which count back from the end of the string.
`String.slice 1 -1 "Hello"` drops the first and last characters, giving
`"ell"`, and `String.slice -3 5 "World"` gives the last three characters,
`"rld"`.
-}
-- CHECK: slice1: "ell"
-- CHECK: slice_neg: "ell"
-- CHECK: slice_start: "Hel"
-- CHECK: slice_end: "rld"
import Html exposing (text)
main =
let
_ = Debug.log "slice1" (String.slice 1 4 "Hello")
_ = Debug.log "slice_neg" (String.slice 1 -1 "Hello")
_ = Debug.log "slice_start" (String.slice 0 3 "Hello World")
_ = Debug.log "slice_end" (String.slice -3 (String.length "World") "World")
in
text "done"