Elm Exactly
Results / elm-json /

EncodeIntTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Json.Encode.int` encodes zero, positive and negative integers, including the 32-bit extremes 2147483647 and -2147483648, as plain decimal JSON numbers.

Each value is encoded with `Json.Encode.encode 0`, so the output has no whitespace, and the
log shows the encoded string in quotes.

Results

elm-0.19.1

passran in 83 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
zero: "0"
positive: "42"
negative: "-7"
max_i32: "2147483647"
min_i32: "-2147483648"

elm-0.19.2

passran in 66 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
zero: "0"
positive: "42"
negative: "-7"
max_i32: "2147483647"
min_i32: "-2147483648"

elm-0.19.3

passran in 70 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
zero: "0"
positive: "42"
negative: "-7"
max_i32: "2147483647"
min_i32: "-2147483648"

lamdera-1.5.0

passran in 73 ms
Output
zero: "0"
positive: "42"
negative: "-7"
max_i32: "2147483647"
min_i32: "-2147483648"

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module EncodeIntTest exposing (main)
{-| `Json.Encode.int` encodes zero, positive and negative integers, including the 32-bit extremes 2147483647 and -2147483648, as plain decimal JSON numbers.
Each value is encoded with `Json.Encode.encode 0`, so the output has no whitespace, and the
log shows the encoded string in quotes.
-}
-- CHECK: zero: "0"
-- CHECK: positive: "42"
-- CHECK: negative: "-7"
-- CHECK: max_i32: "2147483647"
-- CHECK: min_i32: "-2147483648"
import Html exposing (text)
import Json.Encode as Encode
main =
let
_ =
Debug.log "zero" (Encode.encode 0 (Encode.int 0))
_ =
Debug.log "positive" (Encode.encode 0 (Encode.int 42))
_ =
Debug.log "negative" (Encode.encode 0 (Encode.int -7))
_ =
Debug.log "max_i32" (Encode.encode 0 (Encode.int 2147483647))
_ =
Debug.log "min_i32" (Encode.encode 0 (Encode.int -2147483648))
in
text "done"