StringLargeSliceTest
Checks that `String.slice` on a 500-character string returns a 250-character slice with the right content at both ends. The source is `"abcdefghij"` repeated 50 times. `String.slice 100 350` starts at index 100, which holds `'a'`, and stops before index 350, so the slice begins `"abcde"` and its last character is the `'j'` at index 349.
Results
elm-0.19.1
passran in 69 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. slice_len: 250 slice_head: "abcde" slice_tail: "fghij"
elm-0.19.2
passran in 55 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. slice_len: 250 slice_head: "abcde" slice_tail: "fghij"
elm-0.19.3
passran in 63 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. slice_tail: "fghij" slice_head: "abcde" slice_len: 250
lamdera-1.5.0
passran in 38 msOutput
slice_tail: "fghij" slice_head: "abcde" slice_len: 250
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/StringLargeSliceTest] in its title.
Source
The -- CHECK: lines give the expected output.
module StringLargeSliceTest exposing (main)
{-| Checks that `String.slice` on a 500-character string returns a 250-character slice with the right content at both ends.
The source is `"abcdefghij"` repeated 50 times. `String.slice 100 350` starts
at index 100, which holds `'a'`, and stops before index 350, so the slice
begins `"abcde"` and its last character is the `'j'` at index 349.
-}
-- CHECK: slice_len: 250
-- CHECK: slice_head: "abcde"
-- CHECK: slice_tail: "fghij"
import Html exposing (text)
main =
let
source =
String.repeat 50 "abcdefghij"
sl =
String.slice 100 350 source
_ =
Debug.log "slice_len" (String.length sl)
_ =
Debug.log "slice_head" (String.left 5 sl)
_ =
Debug.log "slice_tail" (String.right 5 sl)
in
text "done"