BytesWidthOfSliceTest
`Bytes.width` of the `Bytes` value that `Bytes.Decode.bytes 40` takes from a 50-byte buffer is 40. The buffer is 50 bytes of 7.
Results
elm-0.19.1
passran in 49 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. slice_width: 40
elm-0.19.2
passran in 42 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. slice_width: 40
elm-0.19.3
passran in 50 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. slice_width: 40
lamdera-1.5.0
passran in 66 msOutput
slice_width: 40
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-bytes/BytesWidthOfSliceTest] in its title.
Source
The -- CHECK: lines give the expected output.
module BytesWidthOfSliceTest exposing (main)
{-| `Bytes.width` of the `Bytes` value that `Bytes.Decode.bytes 40` takes from a 50-byte buffer
is 40.
The buffer is 50 bytes of 7.
-}
-- CHECK: slice_width: 40
import Bytes exposing (Bytes, Endianness(..))
import Bytes.Decode as D
import Bytes.Encode as E
import Html exposing (text)
main =
let
buffer =
E.encode (E.sequence (List.repeat 50 (E.unsignedInt8 7)))
sliceWidth =
D.decode (D.bytes 40) buffer
|> Maybe.map Bytes.width
|> Maybe.withDefault -1
_ =
Debug.log "slice_width" sliceWidth
in
text "done"