Skip to content

Commit e6539a2

Browse files
authored
Merge pull request #242 from jfmengels/documentation-improvements
Fix imports in documentation examples
2 parents 7b71ef3 + 88a58a9 commit e6539a2

4 files changed

Lines changed: 78 additions & 62 deletions

File tree

src/Expect.elm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,9 @@ equalSets expected actual =
578578

579579
{-| Always passes.
580580
581+
import Expect
581582
import Json.Decode exposing (decodeString, int)
582583
import Test exposing (test)
583-
import Expect
584584
585585
586586
test "Json.Decode.int can decode the number 42." <|
@@ -600,9 +600,9 @@ pass =
600600

601601
{-| Fails with the given message.
602602
603+
import Expect
603604
import Json.Decode exposing (decodeString, int)
604605
import Test exposing (test)
605-
import Expect
606606
607607
608608
test "Json.Decode.int can decode the number 42." <|

src/Test.elm

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ concat tests =
7373

7474
{-| Apply a description to a list of tests.
7575
76-
import Test exposing (describe, test, fuzz)
77-
import Fuzz exposing (int)
7876
import Expect
77+
import Fuzz exposing (int)
78+
import Test exposing (describe, fuzz, test)
7979
8080
8181
describe "List"
8282
[ describe "reverse"
8383
[ test "has no effect on an empty list" <|
84-
\_ ->
84+
\() ->
8585
List.reverse []
8686
|> Expect.equal []
8787
, fuzz int "has no effect on a one-item list" <|
@@ -141,12 +141,12 @@ describe untrimmedDesc tests =
141141
{-| Return a [`Test`](#Test) that evaluates a single
142142
[`Expectation`](../Expect#Expectation).
143143
144-
import Test exposing (fuzz)
145144
import Expect
145+
import Test exposing (test)
146146
147147
148148
test "the empty list has 0 length" <|
149-
\_ ->
149+
\() ->
150150
List.length []
151151
|> Expect.equal 0
152152
@@ -213,7 +213,7 @@ an `only` inside a `skip`, it will also get skipped.
213213
[ only <|
214214
describe "reverse"
215215
[ test "has no effect on an empty list" <|
216-
\_ ->
216+
\() ->
217217
List.reverse []
218218
|> Expect.equal []
219219
, fuzz int "has no effect on a one-item list" <|
@@ -222,7 +222,7 @@ an `only` inside a `skip`, it will also get skipped.
222222
|> Expect.equal [ num ]
223223
]
224224
, test "This will not get run, because of the `only` above!" <|
225-
\_ ->
225+
\() ->
226226
List.length []
227227
|> Expect.equal 0
228228
]
@@ -249,7 +249,7 @@ an `only` inside a `skip`, it will also get skipped.
249249
[ skip <|
250250
describe "reverse"
251251
[ test "has no effect on an empty list" <|
252-
\_ ->
252+
\() ->
253253
List.reverse []
254254
|> Expect.equal []
255255
, fuzz int "has no effect on a one-item list" <|
@@ -258,7 +258,7 @@ an `only` inside a `skip`, it will also get skipped.
258258
|> Expect.equal [ num ]
259259
]
260260
, test "This is the only test that will get run; the other was skipped!" <|
261-
\_ ->
261+
\() ->
262262
List.length []
263263
|> Expect.equal 0
264264
]
@@ -276,9 +276,9 @@ skip =
276276
277277
The number of times to run each fuzz test. (Default is 100.)
278278
279-
import Test exposing (fuzzWith)
280-
import Fuzz exposing (list, int)
281279
import Expect
280+
import Fuzz exposing (int, list)
281+
import Test exposing (fuzzWith, noDistribution)
282282
283283
fuzzWith { runs = 350, distribution = noDistribution }
284284
(list int)
@@ -297,10 +297,10 @@ The number of times to run each fuzz test. (Default is 100.)
297297
A way to report/enforce a statistical distribution of your input values.
298298
(Default is `noDistribution`.)
299299
300-
import Test exposing (fuzzWith)
301-
import Test.Distribution
302-
import Fuzz exposing (list, int)
303300
import Expect
301+
import Fuzz exposing (int, list)
302+
import Test exposing (expectDistribution, fuzzWith)
303+
import Test.Distribution
304304
305305
fuzzWith
306306
{ runs = 350
@@ -330,9 +330,9 @@ Note that there is no `fuzzWith2`, but you can always pass more fuzz values in
330330
using [`Fuzz.pair`](Fuzz#pair), [`Fuzz.triple`](Fuzz#triple),
331331
for example like this:
332332
333-
import Test exposing (fuzzWith)
334-
import Fuzz exposing (pair, list, int)
335333
import Expect
334+
import Fuzz exposing (int, list, pair)
335+
import Test exposing (fuzzWith, noDistribution)
336336
337337
338338
fuzzWith { runs = 4200, distribution = noDistribution }
@@ -393,10 +393,9 @@ You may find them elsewhere called [property-based tests](http://blog.jessitron.
393393
[generative tests](http://www.pivotaltracker.com/community/tracker-blog/generative-testing), or
394394
[QuickCheck-style tests](https://en.wikipedia.org/wiki/QuickCheck).
395395
396-
import Test exposing (fuzz)
397-
import Fuzz exposing (list, int)
398396
import Expect
399-
397+
import Fuzz exposing (int, list)
398+
import Test exposing (fuzz)
400399
401400
fuzz (list int) "List.length should never be negative" <|
402401
-- This anonymous function will be run 100 times, each time with a
@@ -422,8 +421,9 @@ This is a convenience function that lets you skip calling [`Fuzz.pair`](Fuzz#pai
422421
423422
See [`fuzzWith`](#fuzzWith) for an example of writing this using tuples.
424423
424+
import Expect
425+
import Fuzz exposing (int, list)
425426
import Test exposing (fuzz2)
426-
import Fuzz exposing (list, int)
427427
428428
429429
fuzz2 (list int) int "List.reverse never influences List.member" <|

src/Test/Html/Event.elm

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ type Event msg
5454

5555
{-| Simulate an event on a node.
5656
57+
import Html
58+
import Html.Events exposing (onInput)
59+
import Test exposing (test)
5760
import Test.Html.Event as Event
61+
import Test.Html.Query as Query
5862
5963
type Msg
6064
= Change String
@@ -75,7 +79,11 @@ simulate =
7579

7680
{-| Passes if the given message is triggered by the simulated event.
7781
82+
import Html
83+
import Html.Events exposing (onInput)
84+
import Test exposing (test)
7885
import Test.Html.Event as Event
86+
import Test.Html.Query as Query
7987
8088
type Msg
8189
= Change String
@@ -113,7 +121,11 @@ expect msg (Event event (QueryInternal.Single showTrace query)) =
113121
Note that Event.expect gives nicer messages; this is generally more useful
114122
when testing that an event handler is _not_ present.
115123
124+
import Html
125+
import Html.Events exposing (onInput)
126+
import Test exposing (test)
116127
import Test.Html.Event as Event
128+
import Test.Html.Query as Query
117129
118130
119131
test "Input produces expected Msg" <|
@@ -309,9 +321,12 @@ focus =
309321
{-| Simulate a custom event. The `String` is the event name, and the `Value` is the event object
310322
the browser would send to the event listener callback.
311323
312-
import Test.Html.Event as Event
324+
import Html
325+
import Html.Events exposing (onInput)
313326
import Json.Encode as Encode exposing (Value)
314-
327+
import Test exposing (test)
328+
import Test.Html.Event as Event
329+
import Test.Html.Query as Query
315330
316331
type Msg
317332
= Change String
@@ -328,10 +343,10 @@ the browser would send to the event listener callback.
328343
)
329344
]
330345
in
331-
Html.input [ onInput Change ] [ ]
332-
|> Query.fromHtml
333-
|> Event.simulate (Event.custom "input" simulatedEventObject)
334-
|> Event.expect (Change "cats")
346+
Html.input [ onInput Change ] [ ]
347+
|> Query.fromHtml
348+
|> Event.simulate (Event.custom "input" simulatedEventObject)
349+
|> Event.expect (Change "cats")
335350
336351
-}
337352
custom : String -> Value -> ( String, Value )

0 commit comments

Comments
 (0)