ArrayEqAfterPushTest
Tags:elm-unspecced
An `Array` built by `Array.push` from empty is equal under `==` to `Array.initialize` of the same elements, for lengths 96, 128 and 160. Tagged `elm-unspecced`: `Array.initialize`, `Array.empty` and `Array.push` are library functions of `Array`, which A Standard Definition of Elm? puts outside the definition (Appendix C, Library functions). Within the definition an array reaches a program only through a port or its flags, and equality of arrays is checked by `ArrayEqualityFlagsTest`; this test checks that elm/core's arrays compare equal whatever their internal shape.
Results
elm-0.19.1
passran in 75 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. push96: True push128: True push160: True
elm-0.19.2
passran in 74 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. push96: True push128: True push160: True
elm-0.19.3
passran in 56 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. push96: True push128: True push160: True
lamdera-1.5.0
passran in 52 msOutput
push96: True push128: True push160: True
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/ArrayEqAfterPushTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ArrayEqAfterPushTest exposing (main)
{-| An `Array` built by `Array.push` from empty is equal under `==` to `Array.initialize` of the
same elements, for lengths 96, 128 and 160.
Tagged `elm-unspecced`: `Array.initialize`, `Array.empty` and `Array.push` are library functions
of `Array`, which A Standard Definition of Elm? puts outside the definition (Appendix C, Library
functions). Within the definition an array reaches a program only through a port or its flags,
and equality of arrays is checked by `ArrayEqualityFlagsTest`; this test checks that elm/core's
arrays compare equal whatever their internal shape.
-}
-- TAGS: elm-unspecced
-- CHECK: push96: True
-- CHECK: push128: True
-- CHECK: push160: True
import Array
import Html exposing (text)
pushBuild : Int -> Array.Array Int
pushBuild n =
List.foldl Array.push Array.empty (List.range 0 (n - 1))
main =
let
_ = Debug.log "push96" (Array.initialize 96 identity == pushBuild 96)
_ = Debug.log "push128" (Array.initialize 128 identity == pushBuild 128)
_ = Debug.log "push160" (Array.initialize 160 identity == pushBuild 160)
in
text "done"