hspec-leancheck 0.0.1 → 0.0.2
raw patch · 2 files changed
+24/−7 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Test.Hspec.LeanCheck: propertyWith :: Testable a => Int -> a -> Property
+ Test.Hspec.LeanCheck: propertyFor :: Testable a => Int -> a -> Property
Files
- hspec-leancheck.cabal +2/−2
- src/Test/Hspec/LeanCheck.hs +22/−5
hspec-leancheck.cabal view
@@ -1,6 +1,6 @@ -- Cabal file for hspec-leancheck name: hspec-leancheck-version: 0.0.1+version: 0.0.2 synopsis: LeanCheck support for the Hspec test framework. description: LeanCheck support for the Hspec test framework.@@ -48,7 +48,7 @@ source-repository this type: git location: https://github.com/rudymatela/hspec-leancheck- tag: v0.0.1+ tag: v0.0.2 library exposed-modules: Test.Hspec.LeanCheck
src/Test/Hspec/LeanCheck.hs view
@@ -47,7 +47,7 @@ -- for more details. module Test.Hspec.LeanCheck ( property- , propertyWith+ , propertyFor , module Test.LeanCheck ) where@@ -63,14 +63,24 @@ data Property = Ok | Failed String --- TODO: catch errors-propertyWith :: Testable a => Int -> a -> Property-propertyWith m p = case counterExample m p of+-- | Like 'property' but allows setting the maximum number of tests.+propertyFor :: Testable a => Int -> a -> Property+propertyFor m p = case counterExample m p of Nothing -> Ok Just ce -> Failed $ unwords ce+-- TODO: catch errors above +-- | Allows a LeanCheck 'Testable' property to appear in a Spec.+-- Like so:+--+-- > spec :: Spec+-- > spec = do+-- > describe "thing" $ do+-- > it "is so and so" $ property $ \x... -> ...+-- > it "is like this" $ property $ \y... -> ...+-- > ... property :: Testable a => a -> Property-property = propertyWith 200+property = propertyFor 200 instance Example Property where evaluateExample p _ _ _ = return . Result ""@@ -78,6 +88,13 @@ Ok -> Success Failed s -> Failure Nothing (Reason s) +-- | Allows @should*@ to appear inside LeanCheck properties+--+-- Example:+--+-- > describe "sort" $ do+-- > it "is idempotent" $+-- > LC.property $ \xs -> sort (sort xs :: [Int]) `shouldBe` sort xs instance Testable (IO a) where resultiers action = unsafePerformIO $ do r <- try action