Elm Exactly
Results / elm-bytes /

RoundtripSignedInt8Test

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Integers survive a `signedInt8` encode and decode with elm/bytes, including both ends of the signed 8-bit range.

The values 0, 1, -1, 127 and -128 are each round-tripped, and the program logs
`True` only if all of them come back unchanged.

Results

elm-0.19.1

passran in 63 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
RoundtripSignedInt8Test: True

elm-0.19.2

passran in 58 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
RoundtripSignedInt8Test: True

elm-0.19.3

passran in 56 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
RoundtripSignedInt8Test: True

lamdera-1.5.0

passran in 62 ms
Output
RoundtripSignedInt8Test: True

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module RoundtripSignedInt8Test exposing (main)
{-| Integers survive a `signedInt8` encode and decode with elm/bytes, including both ends of the signed 8-bit range.
The values 0, 1, -1, 127 and -128 are each round-tripped, and the program logs
`True` only if all of them come back unchanged.
-}
-- CHECK: RoundtripSignedInt8Test: True
import Bytes exposing (Bytes)
import Bytes.Decode as D
import Bytes.Encode as E
import Html exposing (text)
roundtrip : Int -> Bool
roundtrip n =
let
encoded =
E.encode (E.signedInt8 n)
decoded =
D.decode D.signedInt8 encoded
in
decoded == Just n
main =
let
allPass =
roundtrip 0
&& roundtrip 1
&& roundtrip -1
&& roundtrip 127
&& roundtrip -128
_ =
Debug.log "RoundtripSignedInt8Test" allPass
in
text (if allPass then "True" else "False")