Elm Exactly
Results / elm-bytes /

DecodeBytesTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Bytes.Decode.bytes 3` takes the first three bytes of a five-byte sequence as a `Bytes` value of width 3.

Results

elm-0.19.1

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

elm-0.19.2

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

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.
DecodeBytesTest: 3

lamdera-1.5.0

passran in 47 ms
Output
DecodeBytesTest: 3

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module DecodeBytesTest exposing (main)
{-| `Bytes.Decode.bytes 3` takes the first three bytes of a five-byte sequence as a `Bytes` value of width 3.
-}
-- CHECK: DecodeBytesTest: 3
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.sequence
[ E.unsignedInt8 1
, E.unsignedInt8 2
, E.unsignedInt8 3
, E.unsignedInt8 4
, E.unsignedInt8 5
]
)
decoder =
D.bytes 3
result =
D.decode decoder bytes
|> Maybe.map Bytes.width
|> Maybe.withDefault -1
_ =
Debug.log "DecodeBytesTest" result
in
text (String.fromInt result)