Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Test.elm
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ test untrimmedDesc thunk =
Internal.blankDescriptionFailure

else
Internal.ElmTestVariant__Labeled desc (Internal.ElmTestVariant__UnitTest (\() -> [ thunk () ]))
Internal.ElmTestVariant__Labeled desc (Internal.ElmTestVariant__UnitTest (\() -> thunk ()))


{-| Returns a [`Test`](#Test) that is "TODO" (not yet implemented). These tests
Expand Down
7 changes: 3 additions & 4 deletions src/Test/Fuzz.elm
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ validatedFuzzTest desc fuzzer getExpectation distribution =
in
case runResult.failure of
Nothing ->
[ Pass { distributionReport = runResult.distributionReport } ]
Pass { distributionReport = runResult.distributionReport }

Just failure ->
[ { failure
{ failure
| expectation =
failure.expectation
|> Test.Expectation.withDistributionReport runResult.distributionReport
}
}
|> formatExpectation
]
)


Expand Down
6 changes: 3 additions & 3 deletions src/Test/Internal.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ For more information, see <https://github.com/elm-explorations/test/pull/153>

-}
type Test
= ElmTestVariant__UnitTest (() -> List Expectation)
| ElmTestVariant__FuzzTest (Random.Seed -> Int -> List Expectation)
= ElmTestVariant__UnitTest (() -> Expectation)
| ElmTestVariant__FuzzTest (Random.Seed -> Int -> Expectation)
| ElmTestVariant__Labeled String Test
| ElmTestVariant__Skipped Test
| ElmTestVariant__Only Test
Expand All @@ -27,7 +27,7 @@ type Test
failNow : { description : String, reason : Reason } -> Test
failNow record =
ElmTestVariant__UnitTest
(\() -> [ Test.Expectation.fail record ])
(\() -> Test.Expectation.fail record)


blankDescriptionFailure : Test
Expand Down
12 changes: 8 additions & 4 deletions src/Test/Runner.elm
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ import Test.Runner.Failure exposing (Reason(..))
{-| An unevaluated test.
-}
type Runnable
= Thunk (() -> List Expectation)
= Thunk (() -> Expectation)


{-| A function which, when evaluated, produces a list of expectations. Also a
list of labels which apply to this outcome.

NOTE: Even though a list is returned, that list only ever contains exactly one
expectation. Changing it to return just `Expectation` would be a breaking change.

-}
type alias Runner =
{ run : () -> List Expectation
Expand Down Expand Up @@ -136,14 +140,14 @@ countRunnables runnable =
countRunnables runner


run : Runnable -> List Expectation
run : Runnable -> Expectation
run (Thunk fn) =
case runThunk fn of
Ok test ->
test

Err message ->
[ Expect.fail ("This test failed because it threw an exception: \"" ++ message ++ "\"") ]
Expect.fail ("This test failed because it threw an exception: \"" ++ message ++ "\"")


runThunk : (() -> a) -> Result String a
Expand All @@ -161,7 +165,7 @@ fromRunnableTreeHelp labels runner =
case runner of
Runnable runnable ->
[ { labels = labels
, run = \_ -> run runnable
, run = \_ -> [ run runnable ]
}
]

Expand Down