Elm Exactly
Results / elm-core /

JsArrayUnsafeGetIntTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Array.get` returns `Just` the element at a valid index and `Nothing` for an index past the end.

It reads from arrays of `Int`, `Float` and `Char`. The out-of-range case is index 99 of a three-element `Int` array.

Results

elm-0.19.1

passran in 38 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
int_at_0: Just 10
int_at_2: Just 30
float_at_1: Just 2.5
char_at_0: Just 'a'
oob: Nothing

elm-0.19.2

passran in 69 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
int_at_0: Just 10
int_at_2: Just 30
float_at_1: Just 2.5
char_at_0: Just 'a'
oob: Nothing

elm-0.19.3

passran in 51 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
int_at_0: Just 10
int_at_2: Just 30
float_at_1: Just 2.5
char_at_0: Just 'a'
oob: Nothing

lamdera-1.5.0

passran in 79 ms
Output
int_at_0: Just 10
int_at_2: Just 30
float_at_1: Just 2.5
char_at_0: Just 'a'
oob: Nothing

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module JsArrayUnsafeGetIntTest exposing (main)
{-| `Array.get` returns `Just` the element at a valid index and `Nothing` for an index past the end.
It reads from arrays of `Int`, `Float` and `Char`. The out-of-range case is index 99 of a three-element `Int` array.
-}
-- CHECK: int_at_0: Just 10
-- CHECK: int_at_2: Just 30
-- CHECK: float_at_1: Just 2.5
-- CHECK: char_at_0: Just 'a'
-- CHECK: oob: Nothing
import Array
import Html exposing (text)
main =
let
ints =
Array.fromList [ 10, 20, 30 ]
floats =
Array.fromList [ 1.5, 2.5, 3.5 ]
chars =
Array.fromList [ 'a', 'b', 'c' ]
_ =
Debug.log "int_at_0" (Array.get 0 ints)
_ =
Debug.log "int_at_2" (Array.get 2 ints)
_ =
Debug.log "float_at_1" (Array.get 1 floats)
_ =
Debug.log "char_at_0" (Array.get 0 chars)
_ =
Debug.log "oob" (Array.get 99 ints)
in
text "done"