Elm Exactly
Results / elm-bytes /

DecodeInsufficientBytesTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Decoding a 32-bit unsigned integer from a single byte returns `Nothing` rather than a partial value.

Results

elm-0.19.1

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

elm-0.19.2

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

elm-0.19.3

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

lamdera-1.5.0

passran in 57 ms
Output
DecodeInsufficientBytesTest: True

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module DecodeInsufficientBytesTest exposing (main)
{-| Decoding a 32-bit unsigned integer from a single byte returns `Nothing` rather than a partial value.
-}
-- CHECK: DecodeInsufficientBytesTest: True
import Bytes exposing (Bytes, Endianness(..))
import Bytes.Decode as D
import Bytes.Encode as E
import Html exposing (text)
main =
let
-- Only 1 byte but trying to read 4
bytes =
E.encode (E.unsignedInt8 42)
result =
D.decode (D.unsignedInt32 BE) bytes
isNothing =
result == Nothing
_ =
Debug.log "DecodeInsufficientBytesTest" isNothing
in
text (if isNothing then "True" else "False")