hspec-hedgehog 0.0.1.2 → 0.1.0.0
raw patch · 4 files changed
+31/−14 lines, 4 filesdep −HUnitdep ~hspecdep ~hspec-core
Dependencies removed: HUnit
Dependency ranges changed: hspec, hspec-core
Files
- ChangeLog.md +11/−0
- hspec-hedgehog.cabal +3/−4
- src/Test/Hspec/Hedgehog.hs +12/−10
- test/Spec.hs +5/−0
ChangeLog.md view
@@ -1,5 +1,16 @@ # Changelog for hspec-hedgehog +## 0.1.0.0++- [#25](https://github.com/parsonsmatt/hspec-hedgehog/pull/25) @sol+ - Suppress internal source locations.+- [#24](https://github.com/parsonsmatt/hspec-hedgehog/pull/24) @sol+ - Regard `--color` / `--no-color`.+- [#23](https://github.com/parsonsmatt/hspec-hedgehog/pull/23) @ocharles+ - Improve type inference by constraining the base monad of `PropertyT` to+ `IO`. This makes explicitly using `hedgehog` redundant in many+ situations.+ ## 0.0.1.2 - [#7](https://github.com/parsonsmatt/hspec-hedgehog/pull/7) @parsonsmatt
hspec-hedgehog.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: hspec-hedgehog-version: 0.0.1.2+version: 0.1.0.0 description: Please see the README on GitHub at <https://github.com/parsonsmatt/hspec-hedgehog#readme> synopsis: Integrate Hedgehog and Hspec! category: Testing@@ -27,10 +27,9 @@ src build-depends: base >= 4.7 && < 5- , hspec >= 2.4.4 && < 3- , hspec-core >= 2.4.4 && < 3+ , hspec >= 2.11.0 && < 3+ , hspec-core >= 2.11.0 && < 3 , hedgehog >= 1.0.2 && < 2- , HUnit >= 1.5 && < 2 , QuickCheck >= 2.9.2 && < 3 , splitmix >= 0.0.1 && < 1 default-language: Haskell2010
src/Test/Hspec/Hedgehog.hs view
@@ -94,8 +94,9 @@ import Control.Monad.IO.Class (liftIO) import Data.Coerce (coerce) import Data.IORef (newIORef, readIORef, writeIORef)+import GHC.Stack (withFrozenCallStack) import Hedgehog-import Hedgehog.Internal.Config (detectColor)+import Hedgehog.Internal.Config (UseColor(..)) import Hedgehog.Internal.Property (DiscardLimit (..), Property (..), PropertyConfig (..), ShrinkLimit (..),@@ -112,7 +113,6 @@ import Test.Hspec.QuickCheck (modifyArgs, modifyMaxDiscardRatio, modifyMaxShrinks, modifyMaxSize, modifyMaxSuccess)-import Test.HUnit.Base (assertFailure) import Test.QuickCheck.Random (QCGen (..)) import Test.QuickCheck.Test (Args (..)) @@ -142,10 +142,13 @@ -- of 'Example' for a function for more details. -- -- @since 0.0.0.0-instance Example (PropertyT IO ()) where- type Arg (PropertyT IO ()) = ()+instance m ~ IO => Example (PropertyT m ()) where+ type Arg (PropertyT m ()) = () evaluateExample e = evaluateExample (\() -> e) +propertyWithoutCallStack :: PropertyT IO () -> Property+propertyWithoutCallStack = withFrozenCallStack property+ -- | Warning: orphan instance! This instance is used to embed a "Hedgehog" -- property seamlessly into the @hspec@ framework. --@@ -155,13 +158,12 @@ -- Hedgehog tests. -- -- @since 0.0.0.0-instance Example (a -> PropertyT IO ()) where- type Arg (a -> PropertyT IO ()) = a+instance (m ~ IO) => Example (a -> PropertyT m ()) where+ type Arg (a -> PropertyT m ()) = a - evaluateExample (fmap property -> aprop) params aroundAction progressCallback = do+ evaluateExample (fmap propertyWithoutCallStack -> aprop) params aroundAction progressCallback = do ref <- newIORef (Result "" (Pending Nothing Nothing)) aroundAction $ \a -> do- color <- detectColor let size = 0 prop = aprop a propConfig = useQuickCheckArgs (propertyConfig prop)@@ -197,7 +199,7 @@ Nothing -> Seed.random Just (rng, _) -> pure (uncurry Seed (unseedSMGen (coerce rng))) hedgeResult <- checkReport propConfig size seed (propertyTest prop) cb- ppresult <- renderResult color Nothing hedgeResult+ ppresult <- renderResult EnableColor Nothing hedgeResult writeIORef ref $ Result "" $ case reportStatus hedgeResult of Failed FailureReport{..} -> let@@ -208,7 +210,7 @@ , locationColumn = coerce spanStartColumn } in- Hspec.Failure (fromSpan <$> failureLocation) $ Reason ppresult+ Hspec.Failure (fromSpan <$> failureLocation) $ ColorizedReason ppresult GaveUp -> Failure Nothing (Reason "GaveUp") OK ->
test/Spec.hs view
@@ -23,6 +23,11 @@ x <- forAll $ Gen.integral (Range.linear 0 1000) y <- forAll $ Gen.integral (Range.linear 0 5000) diff (x + y) (>=) (x :: Integer)+ + it "lets you use PropertyT directly without forcing the type" $ do+ x <- forAll $ Gen.integral (Range.linear 0 1000)+ y <- forAll $ Gen.integral (Range.linear 0 5000)+ diff (x + y) (>=) (x :: Integer) it "renders a progress bit" $ hedgehog $ do x <- forAll $ Gen.integral (Range.linear 0 1000)