1 |
gienah 14/07/03 11:17:40 |
2 |
|
3 |
Added: testpack-2.1.2.1-quickcheck-2.7.patch |
4 |
Log: |
5 |
Patch testpack-2.1.2.1-r2 for quickcheck-2.7 |
6 |
|
7 |
(Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key 618E971F) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 dev-haskell/testpack/files/testpack-2.1.2.1-quickcheck-2.7.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-haskell/testpack/files/testpack-2.1.2.1-quickcheck-2.7.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-haskell/testpack/files/testpack-2.1.2.1-quickcheck-2.7.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: testpack-2.1.2.1-quickcheck-2.7.patch |
16 |
=================================================================== |
17 |
--- testpack-2.1.2.1-orig/testpack.cabal 2013-02-26 02:03:46.000000000 +1100 |
18 |
+++ testpack-2.1.2.1/testpack.cabal 2014-07-03 20:47:34.432871930 +1000 |
19 |
@@ -39,7 +39,7 @@ |
20 |
|
21 |
Build-Depends: base >= 3 && < 5, |
22 |
mtl, HUnit, |
23 |
- QuickCheck >= 2.1.0.3 && < 2.5 |
24 |
+ QuickCheck >= 2.1.0.3 && < 2.8 |
25 |
|
26 |
If flag(splitBase) |
27 |
Build-Depends: base >= 3 && < 5, containers, random |
28 |
--- testpack-2.1.2.1-orig/src/Test/HUnit/Tools.hs 2013-02-26 02:03:46.000000000 +1100 |
29 |
+++ testpack-2.1.2.1/src/Test/HUnit/Tools.hs 2014-07-03 21:01:50.373614959 +1000 |
30 |
@@ -25,7 +25,14 @@ |
31 |
import Test.QuickCheck.Property hiding (Result(reason)) |
32 |
import qualified Control.Exception |
33 |
import qualified Test.HUnit as HU |
34 |
-import System.Random |
35 |
+#if MIN_VERSION_QuickCheck(2,7,0) |
36 |
+import Test.QuickCheck.Random (newQCGen, QCGen(..)) |
37 |
+import System.Random (split) |
38 |
+#else |
39 |
+import System.Random (newStdGen, StdGen(..), split) |
40 |
+#define newStdGen newQCGen |
41 |
+#define StdGen QCGen |
42 |
+#endif |
43 |
import System.IO |
44 |
import Text.Printf |
45 |
|
46 |
@@ -96,7 +103,7 @@ |
47 |
|
48 |
{- |
49 |
-- | modified version of the tests function from Test.QuickCheck |
50 |
-tests :: Args -> Gen Result -> StdGen -> Int -> Int -> [[String]] -> IO () |
51 |
+tests :: Args -> Gen Result -> QCGen -> Int -> Int -> [[String]] -> IO () |
52 |
tests config gen rnd0 ntest nfail stamps |
53 |
| ntest == maxSuccess config = return () |
54 |
| nfail == maxDiscard config = assertFailure $ "Arguments exhausted after " ++ show ntest ++ " tests." |
55 |
@@ -128,7 +135,13 @@ |
56 |
> q "Integer -> Int (safe bounds)" prop_integer_to_int_pass] |
57 |
-} |
58 |
qc2hu :: QC.Testable a => Int -> String -> a -> HU.Test |
59 |
-qc2hu maxTest = qccheck (stdArgs {maxSuccess = maxTest, maxDiscard = 20000}) |
60 |
+qc2hu maxTest = qccheck (stdArgs {maxSuccess = maxTest, |
61 |
+#if MIN_VERSION_QuickCheck(2,5,0) |
62 |
+ maxDiscardRatio = if maxTest /= 0 then 20000 `div` maxTest else 10 |
63 |
+#else |
64 |
+ maxDiscard = 20000 |
65 |
+#endif |
66 |
+ }) |
67 |
|
68 |
{- | Run verbose tests. Example: |
69 |
|
70 |
@@ -163,18 +176,28 @@ |
71 |
-- | Tests a property, using test arguments, produces a test result, and prints the results to 'stdout'. |
72 |
localquickCheckWithResult :: Testable prop => Args -> prop -> IO Result |
73 |
localquickCheckWithResult args p = |
74 |
- do |
75 |
#if MIN_VERSION_QuickCheck(2,3,0) |
76 |
+#if MIN_VERSION_QuickCheck(2,6,0) |
77 |
+ (if chatty args then withStdioTerminal else withNullTerminal) $ \tm -> do |
78 |
+#else |
79 |
+ do |
80 |
tm <- if chatty args then newStdioTerminal else newNullTerminal |
81 |
+#endif |
82 |
#else |
83 |
+ do |
84 |
tm <- newTerminal |
85 |
#endif |
86 |
rnd <- case replay args of |
87 |
- Nothing -> newStdGen |
88 |
+ Nothing -> newQCGen |
89 |
Just (rnd,_) -> return rnd |
90 |
test MkState{ terminal = tm |
91 |
, maxSuccessTests = maxSuccess args |
92 |
- , maxDiscardedTests = maxDiscard args |
93 |
+ , maxDiscardedTests = |
94 |
+#if MIN_VERSION_QuickCheck(2,5,0) |
95 |
+ maxDiscardRatio args * maxSuccess args |
96 |
+#else |
97 |
+ maxDiscard args |
98 |
+#endif |
99 |
, computeSize = case replay args of |
100 |
Nothing -> \n d -> (n * maxSize args) |
101 |
`div` maxSuccess args |
102 |
@@ -190,17 +213,23 @@ |
103 |
#endif |
104 |
, numSuccessShrinks = 0 |
105 |
, numTryShrinks = 0 |
106 |
+#if MIN_VERSION_QuickCheck(2,7,0) |
107 |
+ , numRecentlyDiscardedTests = 0 |
108 |
+ , numTotTryShrinks = 0 |
109 |
+ } (unGen (unProperty (property p))) |
110 |
+#else |
111 |
} (unGen (property p)) |
112 |
+#endif |
113 |
where |
114 |
-------------------------------------------------------------------------- |
115 |
-- main test loop |
116 |
- test :: State -> (StdGen -> Int -> Prop) -> IO Result |
117 |
+ test :: State -> (QCGen -> Int -> Prop) -> IO Result |
118 |
test st f |
119 |
| numSuccessTests st >= maxSuccessTests st = doneTesting st f |
120 |
| numDiscardedTests st >= maxDiscardedTests st = giveUp st f |
121 |
| otherwise = runATest st f |
122 |
|
123 |
- doneTesting :: State -> (StdGen -> Int -> Prop) -> IO Result |
124 |
+ doneTesting :: State -> (QCGen -> Int -> Prop) -> IO Result |
125 |
doneTesting st f = |
126 |
do |
127 |
#if MIN_VERSION_QuickCheck(2,3,0) |
128 |
@@ -221,7 +250,7 @@ |
129 |
#endif |
130 |
} |
131 |
|
132 |
- giveUp :: State -> (StdGen -> Int -> Prop) -> IO Result |
133 |
+ giveUp :: State -> (QCGen -> Int -> Prop) -> IO Result |
134 |
giveUp st f = |
135 |
do |
136 |
#if MIN_VERSION_QuickCheck(2,3,0) |
137 |
@@ -234,7 +263,7 @@ |
138 |
#endif |
139 |
} |
140 |
|
141 |
- runATest :: State -> (StdGen -> Int -> Prop) -> IO Result |
142 |
+ runATest :: State -> (QCGen -> Int -> Prop) -> IO Result |
143 |
runATest st f = |
144 |
do |
145 |
let size = computeSize st (numSuccessTests st) (numDiscardedTests st) |
146 |
@@ -266,7 +295,12 @@ |
147 |
Just False -> -- failed test |
148 |
do |
149 |
#if MIN_VERSION_QuickCheck(2,3,0) |
150 |
+#if MIN_VERSION_QuickCheck(2,3,0) |
151 |
+ (numShrinks, totFailed, lastFailed) <- foundFailure st res ts |
152 |
+#else |
153 |
numShrinks <- foundFailure st res ts |
154 |
+#endif |
155 |
+ |
156 |
theOutput <- terminalOutput (terminal st) |
157 |
#else |
158 |
foundFailure st res ts |
159 |
@@ -288,5 +322,9 @@ |
160 |
, numShrinks = numShrinks |
161 |
, output = theOutput |
162 |
#endif |
163 |
+#if MIN_VERSION_QuickCheck(2,7,0) |
164 |
+ , numShrinkTries = totFailed |
165 |
+ , numShrinkFinal = lastFailed |
166 |
+#endif |
167 |
} |
168 |
where (rnd1,rnd2) = split (randomSeed st) |
169 |
--- testpack-2.1.2.1-orig/src/Test/QuickCheck/Tools.hs 2013-02-26 02:03:46.000000000 +1100 |
170 |
+++ testpack-2.1.2.1/src/Test/QuickCheck/Tools.hs 2014-07-03 21:01:23.932306995 +1000 |
171 |
@@ -23,15 +23,27 @@ |
172 |
|
173 |
) |
174 |
where |
175 |
+#if MIN_VERSION_QuickCheck(2,6,0) |
176 |
+import Test.QuickCheck.Property (Result(..), callbacks, expect, theException, ok, reason, stamp) |
177 |
+#if MIN_VERSION_QuickCheck(2,7,0) |
178 |
+#else |
179 |
+import Test.QuickCheck.Property (Result(..), callbacks, expect, interrupted, ok, reason, stamp) |
180 |
+#endif |
181 |
+#else |
182 |
import Test.QuickCheck hiding (Result, reason) |
183 |
import Test.QuickCheck.Property |
184 |
+#endif |
185 |
|
186 |
{- | Compare two values. If same, the test passes. If different, the result indicates |
187 |
what was expected and what was received as part of the error. -} |
188 |
(@=?) :: (Eq a, Show a) => a -> a -> Result |
189 |
expected @=? actual = |
190 |
MkResult {ok = Just (expected == actual), |
191 |
+#if MIN_VERSION_QuickCheck(2,7,0) |
192 |
+ expect = True, theException = Nothing, |
193 |
+#else |
194 |
expect = True, interrupted = False, |
195 |
+#endif |
196 |
reason = "Result: expected " ++ show expected ++ ", got " ++ show actual, |
197 |
stamp = [], callbacks = []} |