Elm Exactly
Results / elm-json /

RoundTripKeyValuePairsTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Json.Decode.keyValuePairs` decodes an object encoded from `[ ( "a", 1 ), ( "b", 2 ) ]` back to the same pairs, in the same order.

Results

elm-0.19.1

passran in 48 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
rt_kvp: Ok [("a",1),("b",2)]

elm-0.19.2

passran in 40 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
rt_kvp: Ok [("a",1),("b",2)]

elm-0.19.3

passran in 69 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
rt_kvp: Ok [("a",1),("b",2)]

lamdera-1.5.0

passran in 73 ms
Output
rt_kvp: Ok [("a",1),("b",2)]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module RoundTripKeyValuePairsTest exposing (main)
{-| `Json.Decode.keyValuePairs` decodes an object encoded from `[ ( "a", 1 ), ( "b", 2 ) ]` back to the same pairs, in the same order.
-}
-- CHECK: rt_kvp: Ok [("a",1),("b",2)]
import Html exposing (text)
import Json.Decode as Decode
import Json.Encode as Encode
main =
let
json = Encode.encode 0 (Encode.object [ ( "a", Encode.int 1 ), ( "b", Encode.int 2 ) ])
_ = Debug.log "rt_kvp" (Decode.decodeString (Decode.keyValuePairs Decode.int) json)
in
text "done"