DecodeEmptyBytesTest
Decoding an unsigned 8-bit integer from an empty byte sequence returns `Nothing`.
Results
elm-0.19.1
passran in 69 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. DecodeEmptyBytesTest: True
elm-0.19.2
passran in 65 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. DecodeEmptyBytesTest: True
elm-0.19.3
passran in 73 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. DecodeEmptyBytesTest: True
lamdera-1.5.0
passran in 60 msOutput
DecodeEmptyBytesTest: True
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-bytes/DecodeEmptyBytesTest] in its title.
Source
The -- CHECK: lines give the expected output.
module DecodeEmptyBytesTest exposing (main)
{-| Decoding an unsigned 8-bit integer from an empty byte sequence returns `Nothing`.
-}
-- CHECK: DecodeEmptyBytesTest: True
import Bytes exposing (Bytes)
import Bytes.Decode as D
import Bytes.Encode as E
import Html exposing (text)
main =
let
bytes =
E.encode (E.sequence [])
result =
D.decode D.unsignedInt8 bytes
isNothing =
result == Nothing
_ =
Debug.log "DecodeEmptyBytesTest" isNothing
in
text (if isNothing then "True" else "False")