RoundTripIndexTest
`Json.Decode.index 1` reads the second element of a JSON array encoded from `[ "hello", "world" ]`.
Results
elm-0.19.1
passran in 82 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. rt_index: Ok "world"
elm-0.19.2
passran in 52 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. rt_index: Ok "world"
elm-0.19.3
passran in 47 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. rt_index: Ok "world"
lamdera-1.5.0
passran in 50 msOutput
rt_index: Ok "world"
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-json/RoundTripIndexTest] in its title.
Source
The -- CHECK: lines give the expected output.
module RoundTripIndexTest exposing (main)
{-| `Json.Decode.index 1` reads the second element of a JSON array encoded from `[ "hello", "world" ]`.
-}
-- CHECK: rt_index: Ok "world"
import Html exposing (text)
import Json.Decode as Decode
import Json.Encode as Encode
main =
let
json = Encode.encode 0 (Encode.list Encode.string [ "hello", "world" ])
_ = Debug.log "rt_index" (Decode.decodeString (Decode.index 1 Decode.string) json)
in
text "done"