Elm Exactly
Results / elm-url /

UrlPercentDecodePlusTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Url.percentDecode` leaves a `+` as a `+`, so a query value `c++` reads back as `c++`.

The tests decode "a+b", decode "c%2B%2B", and parse the query parameter `q` of
`"http://x/?q=c++"` with `Url.Parser.Query.string`.

Results

elm-0.19.1

passran in 51 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
decode plus: "Just \"a+b\""
decode encoded plus: "Just \"c++\""
query plus: "Just (Just \"c++\")"

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.
decode plus: "Just \"a+b\""
decode encoded plus: "Just \"c++\""
query plus: "Just (Just \"c++\")"

elm-0.19.3

passran in 42 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
decode plus: "Just \"a+b\""
decode encoded plus: "Just \"c++\""
query plus: "Just (Just \"c++\")"

lamdera-1.5.0

passran in 66 ms
Output
decode plus: "Just \"a+b\""
decode encoded plus: "Just \"c++\""
query plus: "Just (Just \"c++\")"

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module UrlPercentDecodePlusTest exposing (main)
{-| `Url.percentDecode` leaves a `+` as a `+`, so a query value `c++` reads back as `c++`.
The tests decode "a+b", decode "c%2B%2B", and parse the query parameter `q` of
`"http://x/?q=c++"` with `Url.Parser.Query.string`.
-}
-- MODE-GUARD: a Char equality must give the same answer as under --optimize
-- NO-SKIP: an edge case every compiler must run
-- CHECK: decode plus: "Just \"a+b\""
-- CHECK: decode encoded plus: "Just \"c++\""
-- CHECK: query plus: "Just (Just \"c++\")"
import ConformanceHelp exposing (logAll, worker)
import Url
import Url.Parser
import Url.Parser.Query
show : a -> String
show =
Debug.toString
queryQ : Maybe (Maybe String)
queryQ =
Url.fromString "http://x/?q=c++"
|> Maybe.andThen
(Url.Parser.parse (Url.Parser.query (Url.Parser.Query.string "q")))
report : ()
report =
logAll
[ ( "decode plus", show (Url.percentDecode "a+b") )
, ( "decode encoded plus", show (Url.percentDecode "c%2B%2B") )
, ( "query plus", show queryQ )
]
main : Program () () ()
main =
worker report