DecodeInsufficientBytesTest
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 msOutput
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 msOutput
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 msOutput
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 msOutput
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")