Elm Exactly
Results / elm-bytes /

EncodeNestedSequenceTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
A `Bytes.Encode.sequence` that contains other sequences produces the sum of all their widths.

The outer sequence holds a two-byte inner sequence, a big-endian `unsignedInt16`, and a
second two-byte inner sequence, so the logged width is 2 + 2 + 2 = 6.

Results

elm-0.19.1

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

elm-0.19.2

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

elm-0.19.3

passran in 54 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
EncodeNestedSequenceTest: 6

lamdera-1.5.0

passran in 55 ms
Output
EncodeNestedSequenceTest: 6

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module EncodeNestedSequenceTest exposing (main)
{-| A `Bytes.Encode.sequence` that contains other sequences produces the sum of all their widths.
The outer sequence holds a two-byte inner sequence, a big-endian `unsignedInt16`, and a
second two-byte inner sequence, so the logged width is 2 + 2 + 2 = 6.
-}
-- CHECK: EncodeNestedSequenceTest: 6
import Bytes exposing (Bytes, Endianness(..))
import Bytes.Encode as E
import Html exposing (text)
main =
let
inner1 =
E.sequence [ E.unsignedInt8 1, E.unsignedInt8 2 ]
inner2 =
E.sequence [ E.unsignedInt8 3, E.unsignedInt8 4 ]
bytes =
E.encode
(E.sequence
[ inner1
, E.unsignedInt16 BE 0x0506
, inner2
]
)
result =
Bytes.width bytes
_ =
Debug.log "EncodeNestedSequenceTest" result
in
text (String.fromInt result)