packages feed

chell-quickcheck 0.1.0.1 → 0.2

raw patch · 2 files changed

+42/−57 lines, 2 filesdep −textdep ~basedep ~chellPVP ok

version bump matches the API change (PVP)

Dependencies removed: text

Dependency ranges changed: base, chell

API changes (from Hackage documentation)

- Test.Chell.QuickCheck: property :: Testable prop => Text -> prop -> Suite
+ Test.Chell.QuickCheck: property :: Testable prop => String -> prop -> Test

Files

chell-quickcheck.cabal view
@@ -1,5 +1,5 @@ name: chell-quickcheck-version: 0.1.0.1+version: 0.2 license: MIT license-file: license.txt author: John Millikin <jmillikin@gmail.com>@@ -10,27 +10,26 @@ bug-reports: mailto:jmillikin@gmail.com homepage: https://john-millikin.com/software/chell/ -synopsis: QuickCheck support for Chell, a quiet test runner+synopsis: QuickCheck support for the Chell testing library  source-repository head   type: bazaar-  location: https://john-millikin.com/software/chell/+  location: https://john-millikin.com/branches/chell-quickcheck/0.2/  source-repository this   type: bazaar-  location: https://john-millikin.com/software/chell/-  tag: chell-quickcheck_0.1.0.1+  location: https://john-millikin.com/branches/chell-quickcheck/0.2/+  tag: chell-quickcheck_0.2  library   hs-source-dirs: lib   ghc-options: -Wall -O2    build-depends:-      base >= 4 && < 5-    , chell >= 0.1 && < 0.3+      base >= 4.0 && < 5.0+    , chell >= 0.3 && < 0.4     , QuickCheck >= 2.3 && < 2.5     , random-    , text    exposed-modules:     Test.Chell.QuickCheck
lib/Test/Chell/QuickCheck.hs view
@@ -1,12 +1,9 @@-{-# LANGUAGE OverloadedStrings #-}- module Test.Chell.QuickCheck 	( property 	) where -import           Data.Text (Text, pack)- import           System.Random (mkStdGen)+ import qualified Test.Chell as Chell import qualified Test.QuickCheck as QuickCheck import qualified Test.QuickCheck.Gen as Gen@@ -14,58 +11,47 @@ import qualified Test.QuickCheck.Test as Test import qualified Test.QuickCheck.Text as Text --- | Convert a QuickCheck property to a Chell 'Chell.Suite'.+-- | Convert a QuickCheck property to a Chell 'Chell.Test'. -- -- @ --import Test.Chell --import Test.Chell.QuickCheck --import Test.QuickCheck hiding (property) -----tests :: [Suite]---tests =---    [ suite \"foo\"---        [ property \"bar\" (\xs -> not (null xs) ==> length xs > 0)---        ]---    ]+--test_NullLength :: Test+--test_NullLength = property \"null-length\"+--    (\xs -> not (null xs) ==> length xs > 0) -- @-property :: QuickCheck.Testable prop => Text -> prop -> Chell.Suite-property name prop = Chell.test (Chell.Test name chell_io) where-	chell_io opts = do-		let seed = Chell.testOptionSeed opts-		-		term <- Text.newNullTerminal-		-		let args = QuickCheck.stdArgs-		let state = State.MkState-			{ State.terminal = term-			, State.maxSuccessTests = QuickCheck.maxSuccess args-			, State.maxDiscardedTests = QuickCheck.maxDiscard args-			, State.computeSize = computeSize-			  	(QuickCheck.maxSize args)-			  	(QuickCheck.maxSuccess args)-			, State.numSuccessTests = 0-			, State.numDiscardedTests = 0-			, State.collected = []-			, State.expectedFailure = False-			, State.randomSeed = mkStdGen seed-			, State.numSuccessShrinks = 0-			, State.numTryShrinks = 0-			}-		-		result <- Test.test state (Gen.unGen (QuickCheck.property prop))-		let output = pack (Test.output result)-		return $ case result of-			Test.Success{} -> Chell.TestPassed-				[("seed", pack (show seed))]-			Test.Failure{} -> Chell.TestFailed-				[("seed", pack (show seed))]-				[Chell.Failure Nothing output]-			Test.GaveUp{} -> Chell.TestAborted-				[("seed", pack (show seed))]-				output-			Test.NoExpectedFailure{} -> Chell.TestFailed-				[("seed", pack (show seed))]-				[Chell.Failure Nothing output]+property :: QuickCheck.Testable prop => String -> prop -> Chell.Test+property name prop = Chell.test name $ \opts -> do+	let seed = Chell.testOptionSeed opts+	+	term <- Text.newNullTerminal+	+	let args = QuickCheck.stdArgs+	let state = State.MkState+		{ State.terminal = term+		, State.maxSuccessTests = QuickCheck.maxSuccess args+		, State.maxDiscardedTests = QuickCheck.maxDiscard args+		, State.computeSize = computeSize (QuickCheck.maxSize args) (QuickCheck.maxSuccess args)+		, State.numSuccessTests = 0+		, State.numDiscardedTests = 0+		, State.collected = []+		, State.expectedFailure = False+		, State.randomSeed = mkStdGen seed+		, State.numSuccessShrinks = 0+		, State.numTryShrinks = 0+		}+	+	result <- Test.test state (Gen.unGen (QuickCheck.property prop))+	let output = Test.output result+	let notes = [("seed", show seed)]+	let failure = Chell.failure { Chell.failureMessage = output }+	return $ case result of+		Test.Success{} -> Chell.TestPassed notes+		Test.Failure{} -> Chell.TestFailed notes [failure]+		Test.GaveUp{} -> Chell.TestAborted notes output+		Test.NoExpectedFailure{} -> Chell.TestFailed notes [failure]  -- copied from quickcheck-2.4.1.1/src/Test/QuickCheck/Test.hs computeSize :: Int -> Int -> Int -> Int -> Int