Skip to content

Instantly share code, notes, and snippets.

@wking-io
Last active January 11, 2019 14:14
Show Gist options
  • Select an option

  • Save wking-io/70862deefc5cc82a4dfb265fd248563e to your computer and use it in GitHub Desktop.

Select an option

Save wking-io/70862deefc5cc82a4dfb265fd248563e to your computer and use it in GitHub Desktop.
{-| This is the error I am getting:
-- NAMING ERROR ----------------- /Users/wking/sites/elm-pair/tests/PairSpec.elm
I cannot find a `Pair.from` variable:
17| Pair.from 0 randomMaybe
^^^^^^^^^
The `Pair` module does not expose a `from` variable. These names seem close
though:
Pair.suite
List.drop
Basics.acos
Basics.cos
Hint: Read <https://elm-lang.org/0.19.0/imports> to see how `import`
declarations work in Elm.
-}
{-| The basic folder structure of the project I am working on is:
elm.json
src
-- Pair.elm
tests
-- PairSpec.elm
-}
{-| This is the test file:
-}
module PairSpec exposing (suite)
import Expect exposing (Expectation)
import Fuzz exposing (Fuzzer, int, maybe)
import Pair
import Test exposing (..)
suite : Test
suite =
describe "The Pair module"
[ describe "Pair.mapMaybe"
[ fuzz (maybe int) "Map over Maybe inside of a Pair and return Pair inside of maybe with the new value" <|
\randomMaybe ->
let
result =
Pair.from 0 randomMaybe
|> Pair.mapMaybe ((*) 2)
compareResult num pair =
(num * 2) == Pair.right pair
in
Expect.all
[ Expect.notEqual Nothing
, Expect.equal <| (Maybe.map2 compareResult randomMaybe result |> Maybe.withDefault false)
]
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment