Elm Exactly
Results / elm-core /

JsArrayPushSliceTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Array.push`, `Array.slice` and `Array.append` give the expected elements, including a negative slice start.

The test pushes onto a three-element array and onto `Array.empty`, and appends `[1,2]` and `[3,4,5]`. `Array.slice 1 3` of 1 to 5 gives `[2,3]`. `Array.slice -2 5` counts the start from the end of the array and gives `[4,5]`.

Results

elm-0.19.1

passran in 52 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
push1: [1,2,3,4]
push_empty: [42]
slice_mid: [2,3]
slice_neg: [4,5]
append1: [1,2,3,4,5]

elm-0.19.2

passran in 78 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
push1: [1,2,3,4]
push_empty: [42]
slice_mid: [2,3]
slice_neg: [4,5]
append1: [1,2,3,4,5]

elm-0.19.3

passran in 52 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
push1: [1,2,3,4]
push_empty: [42]
slice_mid: [2,3]
slice_neg: [4,5]
append1: [1,2,3,4,5]

lamdera-1.5.0

passran in 40 ms
Output
push1: [1,2,3,4]
push_empty: [42]
slice_mid: [2,3]
slice_neg: [4,5]
append1: [1,2,3,4,5]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module JsArrayPushSliceTest exposing (main)
{-| `Array.push`, `Array.slice` and `Array.append` give the expected elements, including a negative slice start.
The test pushes onto a three-element array and onto `Array.empty`, and appends `[1,2]` and `[3,4,5]`. `Array.slice 1 3` of 1 to 5 gives `[2,3]`. `Array.slice -2 5` counts the start from the end of the array and gives `[4,5]`.
-}
-- CHECK: push1: [1,2,3,4]
-- CHECK: push_empty: [42]
-- CHECK: slice_mid: [2,3]
-- CHECK: slice_neg: [4,5]
-- CHECK: append1: [1,2,3,4,5]
import Array
import Html exposing (text)
main =
let
arr = Array.fromList [1, 2, 3]
_ = Debug.log "push1" (Array.toList (Array.push 4 arr))
_ = Debug.log "push_empty" (Array.toList (Array.push 42 Array.empty))
_ = Debug.log "slice_mid" (Array.toList (Array.slice 1 3 (Array.fromList [1, 2, 3, 4, 5])))
_ = Debug.log "slice_neg" (Array.toList (Array.slice -2 5 (Array.fromList [1, 2, 3, 4, 5])))
_ = Debug.log "append1" (Array.toList (Array.append (Array.fromList [1, 2]) (Array.fromList [3, 4, 5])))
in
text "done"