ResultMapTest
Checks that `Result.map` applies its function to an `Ok` value (`Ok 42` doubled gives `Ok 84`) and leaves an `Err` unchanged.
Results
elm-0.19.1
passran in 75 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. map1: Ok 84 map2: Err "error"
elm-0.19.2
passran in 45 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. map1: Ok 84 map2: Err "error"
elm-0.19.3
passran in 46 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. map1: Ok 84 map2: Err "error"
lamdera-1.5.0
passran in 50 msOutput
map1: Ok 84 map2: Err "error"
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/ResultMapTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ResultMapTest exposing (main)
{-| Checks that `Result.map` applies its function to an `Ok` value (`Ok 42` doubled gives `Ok 84`) and leaves an `Err` unchanged.
-}
-- CHECK: map1: Ok 84
-- CHECK: map2: Err "error"
import Html exposing (text)
main =
let
_ = Debug.log "map1" (Result.map (\x -> x * 2) (Ok 42))
_ = Debug.log "map2" (Result.map (\x -> x * 2) (Err "error"))
in
text "done"