Elm Exactly
Results / elm-core /

ResultWithDefaultTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks that `Result.withDefault` returns the `Ok` value when there is one (`42`) and the default (`0`) for an `Err`.

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.
withDefault1: 42
withDefault2: 0

elm-0.19.2

passran in 67 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
withDefault1: 42
withDefault2: 0

elm-0.19.3

passran in 34 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
withDefault1: 42
withDefault2: 0

lamdera-1.5.0

passran in 61 ms
Output
withDefault1: 42
withDefault2: 0

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module ResultWithDefaultTest exposing (main)
{-| Checks that `Result.withDefault` returns the `Ok` value when there is one (`42`) and the default (`0`) for an `Err`.
-}
-- CHECK: withDefault1: 42
-- CHECK: withDefault2: 0
import Html exposing (text)
main =
let
_ = Debug.log "withDefault1" (Result.withDefault 0 (Ok 42))
_ = Debug.log "withDefault2" (Result.withDefault 0 (Err "error"))
in
text "done"