JsArrayUnsafeSetIntElementTest
`Array.set` on an `Array Int` replaces the element at a valid index, and returns the array unchanged for an index out of range. It sets index 0 and the last index, 3, each starting from the same four-element array, and then sets index 100, which leaves `[1,2,3,4]`.
Results
elm-0.19.1
passran in 64 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. original: [1,2,3,4] set_0: [99,2,3,4] set_3: [1,2,3,42] set_oob: [1,2,3,4]
elm-0.19.2
passran in 79 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. original: [1,2,3,4] set_0: [99,2,3,4] set_3: [1,2,3,42] set_oob: [1,2,3,4]
elm-0.19.3
passran in 61 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. original: [1,2,3,4] set_0: [99,2,3,4] set_3: [1,2,3,42] set_oob: [1,2,3,4]
lamdera-1.5.0
passran in 58 msOutput
original: [1,2,3,4] set_0: [99,2,3,4] set_3: [1,2,3,42] set_oob: [1,2,3,4]
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/JsArrayUnsafeSetIntElementTest] in its title.
Source
The -- CHECK: lines give the expected output.
module JsArrayUnsafeSetIntElementTest exposing (main)
{-| `Array.set` on an `Array Int` replaces the element at a valid index, and returns the array unchanged for an index out of range.
It sets index 0 and the last index, 3, each starting from the same four-element array, and then sets index 100, which leaves `[1,2,3,4]`.
-}
-- CHECK: original: [1,2,3,4]
-- CHECK: set_0: [99,2,3,4]
-- CHECK: set_3: [1,2,3,42]
-- CHECK: set_oob: [1,2,3,4]
import Array
import Html exposing (text)
main =
let
arr : Array.Array Int
arr =
Array.fromList [ 1, 2, 3, 4 ]
_ =
Debug.log "original" (Array.toList arr)
_ =
Debug.log "set_0" (Array.toList (Array.set 0 99 arr))
_ =
Debug.log "set_3" (Array.toList (Array.set 3 42 arr))
_ =
Debug.log "set_oob" (Array.toList (Array.set 100 0 arr))
in
text "done"