RoundTripKeyValuePairsTest
`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 msOutput
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 msOutput
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 msOutput
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 msOutput
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"