Elm Exactly
Results / elm-core /

JsArrayGetSetTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Array.get` and `Array.set` on a three-element `Array Int`, at valid indices and out of range.

`get` returns `Just` for indices 0 and 2 and `Nothing` for 5 and -1. `set` at index 1 replaces the middle element, and `set` at index 5 leaves the array unchanged.

Results

elm-0.19.1

passran in 58 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
get_first: Just 10
get_last: Just 30
get_oob: Nothing
get_neg: Nothing
set_mid: [10,99,30]
set_oob: [10,20,30]

elm-0.19.2

passran in 71 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
get_first: Just 10
get_last: Just 30
get_oob: Nothing
get_neg: Nothing
set_mid: [10,99,30]
set_oob: [10,20,30]

elm-0.19.3

passran in 72 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
get_first: Just 10
get_last: Just 30
get_oob: Nothing
get_neg: Nothing
set_mid: [10,99,30]
set_oob: [10,20,30]

lamdera-1.5.0

passran in 57 ms
Output
get_first: Just 10
get_last: Just 30
get_oob: Nothing
get_neg: Nothing
set_mid: [10,99,30]
set_oob: [10,20,30]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module JsArrayGetSetTest exposing (main)
{-| `Array.get` and `Array.set` on a three-element `Array Int`, at valid indices and out of range.
`get` returns `Just` for indices 0 and 2 and `Nothing` for 5 and -1. `set` at index 1 replaces the middle element, and `set` at index 5 leaves the array unchanged.
-}
-- CHECK: get_first: Just 10
-- CHECK: get_last: Just 30
-- CHECK: get_oob: Nothing
-- CHECK: get_neg: Nothing
-- CHECK: set_mid: [10,99,30]
-- CHECK: set_oob: [10,20,30]
import Array
import Html exposing (text)
main =
let
arr = Array.fromList [10, 20, 30]
_ = Debug.log "get_first" (Array.get 0 arr)
_ = Debug.log "get_last" (Array.get 2 arr)
_ = Debug.log "get_oob" (Array.get 5 arr)
_ = Debug.log "get_neg" (Array.get -1 arr)
_ = Debug.log "set_mid" (Array.toList (Array.set 1 99 arr))
_ = Debug.log "set_oob" (Array.toList (Array.set 5 99 arr))
in
text "done"