-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds ability to be able to statistically verify that a result is correct. It does not _yet_ add the ability to cancel running tests if they can never reach the specified coverage.
- Loading branch information
1 parent
8b02b09
commit 05a99d2
Showing
9 changed files
with
301 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
module Test.Example.Confidence where | ||
|
||
import Hedgehog | ||
import qualified Hedgehog.Range as Range | ||
import qualified Hedgehog.Internal.Gen as Gen | ||
|
||
------------------------------------------------------------------------ | ||
-- Example 0: This test will certify that it is impossible to get 60% | ||
-- coverage for the property label "number == 1" | ||
-- | ||
-- Note that it will abort running once it knows its task is | ||
-- impossible - it will not run 1000000 tests | ||
-- | ||
prop_without_confidence :: Property | ||
prop_without_confidence = | ||
verifiedTermination . withConfidence (10^9) . withTests 1000000 . property $ do | ||
number <- forAll (Gen.int $ Range.constant 1 2) | ||
cover 60 "number == 1" $ number == 1 | ||
|
||
------------------------------------------------------------------------ | ||
tests :: IO Bool | ||
tests = | ||
checkSequential $$(discover) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.