Elm Exactly
Results / elm-bytes /

DecodeSignedInt16BETest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Bytes.Decode.signedInt16 BE reads back a negative value written by
Bytes.Encode.signedInt16 BE.

The value -1000 is encoded and decoded big-endian, and the logged result is
-1000. A failed decode would log 0.

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.
DecodeSignedInt16BETest: -1000

elm-0.19.2

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

elm-0.19.3

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

lamdera-1.5.0

passran in 46 ms
Output
DecodeSignedInt16BETest: -1000

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module DecodeSignedInt16BETest exposing (main)
{-| Bytes.Decode.signedInt16 BE reads back a negative value written by
Bytes.Encode.signedInt16 BE.
The value -1000 is encoded and decoded big-endian, and the logged result is
-1000. A failed decode would log 0.
-}
-- CHECK: DecodeSignedInt16BETest: -1000
import Bytes exposing (Bytes, Endianness(..))
import Bytes.Decode as D
import Bytes.Encode as E
import Html exposing (text)
main =
let
bytes =
E.encode (E.signedInt16 BE -1000)
result =
D.decode (D.signedInt16 BE) bytes
|> Maybe.withDefault 0
_ =
Debug.log "DecodeSignedInt16BETest" result
in
text (String.fromInt result)