HtmlLazyTest
`Html.Lazy.lazy` to `lazy8` call their view function with the arguments they were given, in order. Each of the eight builds a node whose view function logs its arguments as a list, so `lazyN` must log `[1,..,N]`. When the view functions run, and so the order of these lines relative to each other, is left to the implementation and not checked. The program also logs that the list holds 8 nodes.
Results
elm-0.19.1
passran in 36 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. built: 8 lazy1: [1] lazy2: [1,2] lazy3: [1,2,3] lazy4: [1,2,3,4] lazy5: [1,2,3,4,5] lazy6: [1,2,3,4,5,6] lazy7: [1,2,3,4,5,6,7] lazy8: [1,2,3,4,5,6,7,8]
elm-0.19.2
passran in 48 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. built: 8 lazy1: [1] lazy2: [1,2] lazy3: [1,2,3] lazy4: [1,2,3,4] lazy5: [1,2,3,4,5] lazy6: [1,2,3,4,5,6] lazy7: [1,2,3,4,5,6,7] lazy8: [1,2,3,4,5,6,7,8]
elm-0.19.3
passran in 37 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. built: 8 lazy1: [1] lazy2: [1,2] lazy3: [1,2,3] lazy4: [1,2,3,4] lazy5: [1,2,3,4,5] lazy6: [1,2,3,4,5,6] lazy7: [1,2,3,4,5,6,7] lazy8: [1,2,3,4,5,6,7,8]
lamdera-1.5.0
passran in 49 msOutput
built: 8 lazy1: [1] lazy2: [1,2] lazy3: [1,2,3] lazy4: [1,2,3,4] lazy5: [1,2,3,4,5] lazy6: [1,2,3,4,5,6] lazy7: [1,2,3,4,5,6,7] lazy8: [1,2,3,4,5,6,7,8]
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-html/HtmlLazyTest] in its title.
Source
The -- CHECK: lines give the expected output.
module HtmlLazyTest exposing (main)
{-| `Html.Lazy.lazy` to `lazy8` call their view function with the arguments they were given, in order.
Each of the eight builds a node whose view function logs its arguments as a
list, so `lazyN` must log `[1,..,N]`. When the view functions run, and so the
order of these lines relative to each other, is left to the implementation and
not checked. The program also logs that the list holds 8 nodes.
-}
-- CHECK-DAG: lazy1: [1]
-- CHECK-DAG: lazy2: [1,2]
-- CHECK-DAG: lazy3: [1,2,3]
-- CHECK-DAG: lazy4: [1,2,3,4]
-- CHECK-DAG: lazy5: [1,2,3,4,5]
-- CHECK-DAG: lazy6: [1,2,3,4,5,6]
-- CHECK-DAG: lazy7: [1,2,3,4,5,6,7]
-- CHECK-DAG: lazy8: [1,2,3,4,5,6,7,8]
-- CHECK: built: 8
import Html exposing (Html)
import Html.Lazy as Lazy
{-| Logs `args` under `label` and returns a text node showing `label`.
-}
view : String -> List Int -> Html msg
view label args =
let
_ =
Debug.log label args
in
Html.text label
main =
let
nodes =
[ Lazy.lazy (\a -> view "lazy1" [ a ]) 1
, Lazy.lazy2 (\a b -> view "lazy2" [ a, b ]) 1 2
, Lazy.lazy3 (\a b c -> view "lazy3" [ a, b, c ]) 1 2 3
, Lazy.lazy4 (\a b c d -> view "lazy4" [ a, b, c, d ]) 1 2 3 4
, Lazy.lazy5 (\a b c d e -> view "lazy5" [ a, b, c, d, e ]) 1 2 3 4 5
, Lazy.lazy6 (\a b c d e f -> view "lazy6" [ a, b, c, d, e, f ]) 1 2 3 4 5 6
, Lazy.lazy7 (\a b c d e f g -> view "lazy7" [ a, b, c, d, e, f, g ]) 1 2 3 4 5 6 7
, Lazy.lazy8 (\a b c d e f g h -> view "lazy8" [ a, b, c, d, e, f, g, h ]) 1 2 3 4 5 6 7 8
]
_ =
Debug.log "built" (List.length nodes)
in
Html.div [] nodes