Skip to content

Commit 0dacb89

Browse files
committed
Fix tests.
1 parent c17012f commit 0dacb89

File tree

4 files changed

+17
-61
lines changed

4 files changed

+17
-61
lines changed

src/Maybe.gren

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ map3 func ma mb mc =
211211

212212
{-| Combine multiple `Maybe`s. Helpful when [map2](#map2) and [map3](#map3) aren't enough.
213213

214-
Just (++)
214+
Just (\a b c -> a ++ b ++ c)
215215
|> andMap (Just "one ")
216216
|> andMap (Just "more ")
217217
|> andMap (Just "time")

src/Random.gren

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,6 @@ of a time you get an `Empty` tree. A third of the time you get a `Leaf` with
532532
some interesting value. And a third of the time you get a `Node` full of more
533533
QuadTree` values. How are those subtrees generated though? Well, we use our
534534
quadTree` generator!
535-
536-
**Exercises:** Can `quadTree` generate infinite `QuadTree` values? Is there
537-
some way to limit the depth of the `QuadTree`? Can you render the `QuadTree`
538-
to HTML using absolute positions and fractional dimensions? Can you render
539-
the `QuadTree` to SVG?
540-
541-
**Note:** Check out the docs for [`lazy`](#lazy) to learn why that is needed
542-
to define a recursive `Generator` like this one.
543535
-}
544536
andMap : Generator a -> Generator (a -> b) -> Generator b
545537
andMap =

tests/src/Test/Maybe.gren

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -114,71 +114,41 @@ tests =
114114
)
115115
, describe "map4"
116116
(let
117-
f =
118-
\a b c d -> a + b + c + d
117+
f a b c d =
118+
a + b + c + d
119+
120+
map4 fn a b c d =
121+
Just fn
122+
|> Maybe.andMap a
123+
|> Maybe.andMap b
124+
|> Maybe.andMap c
125+
|> Maybe.andMap d
119126
in
120127
[ test "on (Just, Just, Just, Just)" <|
121128
\{} ->
122129
Expect.equal
123130
(Just 4)
124-
(Maybe.map4 f (Just 1) (Just 1) (Just 1) (Just 1))
131+
(map4 f (Just 1) (Just 1) (Just 1) (Just 1))
125132
, test "on (Just, Just, Just, Nothing)" <|
126133
\{} ->
127134
Expect.equal
128135
Nothing
129-
(Maybe.map4 f (Just 1) (Just 1) (Just 1) Nothing)
136+
(map4 f (Just 1) (Just 1) (Just 1) Nothing)
130137
, test "on (Just, Just, Nothing, Just)" <|
131138
\{} ->
132139
Expect.equal
133140
Nothing
134-
(Maybe.map4 f (Just 1) (Just 1) Nothing (Just 1))
141+
(map4 f (Just 1) (Just 1) Nothing (Just 1))
135142
, test "on (Just, Nothing, Just, Just)" <|
136143
\{} ->
137144
Expect.equal
138145
Nothing
139-
(Maybe.map4 f (Just 1) Nothing (Just 1) (Just 1))
146+
(map4 f (Just 1) Nothing (Just 1) (Just 1))
140147
, test "on (Nothing, Just, Just, Just)" <|
141148
\{} ->
142149
Expect.equal
143150
Nothing
144-
(Maybe.map4 f Nothing (Just 1) (Just 1) (Just 1))
145-
]
146-
)
147-
, describe "map5"
148-
(let
149-
f =
150-
\a b c d e -> a + b + c + d + e
151-
in
152-
[ test "on (Just, Just, Just, Just, Just)" <|
153-
\{} ->
154-
Expect.equal
155-
(Just 5)
156-
(Maybe.map5 f (Just 1) (Just 1) (Just 1) (Just 1) (Just 1))
157-
, test "on (Just, Just, Just, Just, Nothing)" <|
158-
\{} ->
159-
Expect.equal
160-
Nothing
161-
(Maybe.map5 f (Just 1) (Just 1) (Just 1) (Just 1) Nothing)
162-
, test "on (Just, Just, Just, Nothing, Just)" <|
163-
\{} ->
164-
Expect.equal
165-
Nothing
166-
(Maybe.map5 f (Just 1) (Just 1) (Just 1) Nothing (Just 1))
167-
, test "on (Just, Just, Nothing, Just, Just)" <|
168-
\{} ->
169-
Expect.equal
170-
Nothing
171-
(Maybe.map5 f (Just 1) (Just 1) Nothing (Just 1) (Just 1))
172-
, test "on (Just, Nothing, Just, Just, Just)" <|
173-
\{} ->
174-
Expect.equal
175-
Nothing
176-
(Maybe.map5 f (Just 1) Nothing (Just 1) (Just 1) (Just 1))
177-
, test "on (Nothing, Just, Just, Just, Just)" <|
178-
\{} ->
179-
Expect.equal
180-
Nothing
181-
(Maybe.map5 f Nothing (Just 1) (Just 1) (Just 1) (Just 1))
151+
(map4 f Nothing (Just 1) (Just 1) (Just 1))
182152
]
183153
)
184154
, describe "keepIf"

tests/src/Test/Result.gren

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ add4 a b c d =
3434
a + b + c + d
3535

3636

37-
add5 a b c d e =
38-
a + b + c + d + e
39-
40-
4137
tests : Test
4238
tests =
4339
describe "Result"
@@ -58,10 +54,8 @@ tests =
5854
, test "map2 Err" <| \{} -> Expect.equal (Err "x") (Result.map2 (+) (Ok 1) (Err "x"))
5955
, test "map3 Ok" <| \{} -> Expect.equal (Ok 6) (Result.map3 add3 (Ok 1) (Ok 2) (Ok 3))
6056
, test "map3 Err" <| \{} -> Expect.equal (Err "x") (Result.map3 add3 (Ok 1) (Ok 2) (Err "x"))
61-
, test "map4 Ok" <| \{} -> Expect.equal (Ok 10) (Result.map4 add4 (Ok 1) (Ok 2) (Ok 3) (Ok 4))
62-
, test "map4 Err" <| \{} -> Expect.equal (Err "x") (Result.map4 add4 (Ok 1) (Ok 2) (Ok 3) (Err "x"))
63-
, test "map5 Ok" <| \{} -> Expect.equal (Ok 15) (Result.map5 add5 (Ok 1) (Ok 2) (Ok 3) (Ok 4) (Ok 5))
64-
, test "map5 Err" <| \{} -> Expect.equal (Err "x") (Result.map5 add5 (Ok 1) (Ok 2) (Ok 3) (Ok 4) (Err "x"))
57+
, test "andMap Ok" <| \{} -> Expect.equal (Ok 10) (Ok add4 |> Result.andMap (Ok 1) |> Result.andMap (Ok 2) |> Result.andMap (Ok 3) |> Result.andMap (Ok 4))
58+
, test "andMap Err" <| \{} -> Expect.equal (Err "x") (Ok add4 |> Result.andMap (Ok 1) |> Result.andMap (Ok 2) |> Result.andMap (Ok 3) |> Result.andMap (Err "x"))
6559
]
6660
, describe "andThen"
6761
[ test "andThen Ok" <| \{} -> Expect.equal (Ok 42) (toIntResult "42" |> Result.andThen isEven)

0 commit comments

Comments
 (0)