DecodeStringTest
Bytes.Decode.string reads back a string written by Bytes.Encode.string. `"hello"` is encoded and decoded with `string 5`, and the logged result is `"hello"`. A failed decode would log `"FAIL"`.
Results
elm-0.19.1
passran in 80 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. DecodeStringTest: "hello"
elm-0.19.2
passran in 53 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. DecodeStringTest: "hello"
elm-0.19.3
passran in 73 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. DecodeStringTest: "hello"
lamdera-1.5.0
passran in 52 msOutput
DecodeStringTest: "hello"
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-bytes/DecodeStringTest] in its title.
Source
The -- CHECK: lines give the expected output.
module DecodeStringTest exposing (main)
{-| Bytes.Decode.string reads back a string written by Bytes.Encode.string.
`"hello"` is encoded and decoded with `string 5`, and the logged result is
`"hello"`. A failed decode would log `"FAIL"`.
-}
-- CHECK: DecodeStringTest: "hello"
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 "hello")
result =
D.decode (D.string 5) bytes
|> Maybe.withDefault "FAIL"
_ =
Debug.log "DecodeStringTest" result
in
text result