BytesIssue15BytesEqualityTest
Tags:elm19-bug
Issue: elm/bytes#15
`==` on two `Bytes` values is always True. <https://github.com/elm/bytes/issues/15> Elm 0.19.1 (elm/bytes 1.0.8) compares the underlying DataViews structurally; they have no enumerable fields, so an empty `Bytes` equals a two-byte one. Values with different contents (and different widths) must not be equal.
Results
elm-0.19.1
failran in 48 msMissing pattern: empty == two bytes: False --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. empty == two bytes: True [1] == [2]: True
elm-0.19.2
failran in 55 msMissing pattern: empty == two bytes: False --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. empty == two bytes: True [1] == [2]: True
elm-0.19.3
failran in 48 msMissing pattern: empty == two bytes: False --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. empty == two bytes: True [1] == [2]: True
lamdera-1.5.0
failran in 52 msMissing pattern: empty == two bytes: False --- output --- empty == two bytes: True [1] == [2]: True
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-bytes/BytesIssue15BytesEqualityTest] in its title.
Source
The -- CHECK: lines give the expected output.
module BytesIssue15BytesEqualityTest exposing (main)
{-| `==` on two `Bytes` values is always True.
<https://github.com/elm/bytes/issues/15>
Elm 0.19.1 (elm/bytes 1.0.8) compares the underlying DataViews structurally; they have no
enumerable fields, so an empty `Bytes` equals a two-byte one. Values with different contents (and
different widths) must not be equal.
-}
-- TAGS: elm19-bug
-- CHECK: empty == two bytes: False
-- CHECK: [1] == [2]: False
import Bytes exposing (Bytes)
import Bytes.Encode as E
import Html exposing (text)
fromList : List Int -> Bytes
fromList xs =
E.encode (E.sequence (List.map E.unsignedInt8 xs))
main =
let
_ =
Debug.log "empty == two bytes" (fromList [] == fromList [ 125, 211 ])
_ =
Debug.log "[1] == [2]" (fromList [ 1 ] == fromList [ 2 ])
in
text "done"