Skip to content

Commit

Permalink
Revert change to Test.Runner.fuzz
Browse files Browse the repository at this point in the history
Those functions are exported and a change affects the public API. That
wasn't the intention.
  • Loading branch information
jwoudenberg committed Jun 5, 2017
1 parent 84066b3 commit 497a200
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
19 changes: 12 additions & 7 deletions src/Test/Runner.elm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ These functions give you the ability to run fuzzers separate of running fuzz tes
-}

import Expect exposing (Expectation)
import Fuzz.Internal exposing (ValidFuzzer)
import Fuzz.Internal exposing (Fuzzer)
import Lazy.List as LazyList exposing (LazyList)
import Random.Pcg
import RoseTree exposing (RoseTree(Rose))
Expand Down Expand Up @@ -373,13 +373,18 @@ type Shrinkable a
{-| Given a fuzzer, return a random generator to produce a value and a
Shrinkable. The value is what a fuzz test would have received as input.
-}
fuzz : ValidFuzzer a -> Random.Pcg.Generator ( a, Shrinkable a )
fuzz : Fuzzer a -> Random.Pcg.Generator ( a, Shrinkable a )
fuzz fuzzer =
fuzzer
|> Random.Pcg.map
(\(Rose root children) ->
( root, Shrinkable { down = children, over = LazyList.empty } )
)
case fuzzer of
Ok validFuzzer ->
validFuzzer
|> Random.Pcg.map
(\(Rose root children) ->
( root, Shrinkable { down = children, over = LazyList.empty } )
)

Err reason ->
Debug.crash <| "Cannot call `fuzz` with an invalid fuzzer: " ++ reason


{-| Given a Shrinkable, attempt to shrink the value further. Pass `False` to
Expand Down
22 changes: 6 additions & 16 deletions tests/FuzzerTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,9 @@ manualFuzzerTests =
n % 2 == 0

pair =
case fuzzer of
Ok validFuzzer ->
Random.step (Test.Runner.fuzz validFuzzer) seed
|> Tuple.first
|> Just

Err _ ->
Nothing
Random.step (Test.Runner.fuzz fuzzer) seed
|> Tuple.first
|> Just

unfold acc maybePair =
case maybePair of
Expand Down Expand Up @@ -199,14 +194,9 @@ manualFuzzerTests =
String.contains "e"

pair =
case fuzzer of
Ok validFuzzer ->
Random.step (Test.Runner.fuzz validFuzzer) seed
|> Tuple.first
|> Just

Err _ ->
Nothing
Random.step (Test.Runner.fuzz fuzzer) seed
|> Tuple.first
|> Just

unfold acc maybePair =
case maybePair of
Expand Down

0 comments on commit 497a200

Please sign in to comment.