EncodeSequenceTest
`Bytes.Encode.sequence` of mixed-width encoders produces the sum of their widths. The sequence holds an `unsignedInt8`, a big-endian `unsignedInt16` and a big-endian `unsignedInt32`, so the logged width is 1 + 2 + 4 = 7.
Results
elm-0.19.1
passran in 58 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. EncodeSequenceTest: 7
elm-0.19.2
passran in 63 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. EncodeSequenceTest: 7
elm-0.19.3
passran in 62 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. EncodeSequenceTest: 7
lamdera-1.5.0
passran in 63 msOutput
EncodeSequenceTest: 7
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-bytes/EncodeSequenceTest] in its title.
Source
The -- CHECK: lines give the expected output.
module EncodeSequenceTest exposing (main)
{-| `Bytes.Encode.sequence` of mixed-width encoders produces the sum of their widths.
The sequence holds an `unsignedInt8`, a big-endian `unsignedInt16` and a big-endian
`unsignedInt32`, so the logged width is 1 + 2 + 4 = 7.
-}
-- CHECK: EncodeSequenceTest: 7
import Bytes exposing (Bytes, Endianness(..))
import Bytes.Encode as E
import Html exposing (text)
main =
let
bytes =
E.encode
(E.sequence
[ E.unsignedInt8 1
, E.unsignedInt16 BE 2
, E.unsignedInt32 BE 3
]
)
result =
Bytes.width bytes
_ =
Debug.log "EncodeSequenceTest" result
in
text (String.fromInt result)