DecodeSignedInt16BETest
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 msOutput
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 msOutput
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 msOutput
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 msOutput
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)