Elm Exactly
Results / elm-bytes /

DecodeEmptyBytesTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Decoding an unsigned 8-bit integer from an empty byte sequence returns `Nothing`.

Results

elm-0.19.1

passran in 69 ms
Output
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 ms
Output
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 ms
Output
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 ms
Output
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")