Elm Exactly
Results / elm-bytes /

DecodeStringEmptyTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Bytes.Decode.string 0 decodes the empty string.

The empty string is encoded, which produces no bytes, and `string 0` reads it
back. `Debug.log` shows the result as `""`; a failed decode would log `"FAIL"`.

Results

elm-0.19.1

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

elm-0.19.2

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

elm-0.19.3

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

lamdera-1.5.0

passran in 54 ms
Output
DecodeStringEmptyTest: ""

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module DecodeStringEmptyTest exposing (main)
{-| Bytes.Decode.string 0 decodes the empty string.
The empty string is encoded, which produces no bytes, and `string 0` reads it
back. `Debug.log` shows the result as `""`; a failed decode would log `"FAIL"`.
-}
-- CHECK: DecodeStringEmptyTest: ""
import Bytes exposing (Bytes)
import Bytes.Decode as D
import Bytes.Encode as E
import Html exposing (text)
main =
let
bytes =
E.encode (E.string "")
result =
D.decode (D.string 0) bytes
|> Maybe.withDefault "FAIL"
_ =
Debug.log "DecodeStringEmptyTest" result
in
text ("result: " ++ result)