Skip to content

Commit 68e04fc

Browse files
committed
Merge branch 'master' of https://github.com/Frege/frege
Take over the QuickCheck port
2 parents c420804 + 0d8f432 commit 68e04fc

34 files changed

+2473
-632
lines changed

examples/Concurrent.fr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module examples.Concurrent where
22

3-
import frege.lib.Random
3+
import System.Random
44
import Java.Net (URL)
55
import Control.Concurrent as C
66

examples/Euler.fr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import frege.Prelude hiding(sum, product)
99
import frege.prelude.Math
1010
import Data.TreeMap except(union, delete, insert)
1111
import Data.List as DL hiding (lookup)
12-
import frege.lib.QuickCheck (forAll, `==>`, property)
12+
import frege.test.QuickCheck (forAll, `==>`, property)
1313

1414
bigs = Integer.arbitrary
1515

examples/Euler12.fr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module examples.Euler12 where
55

66
import examples.EulerLib
77
import Data.List
8-
import frege.lib.QuickCheck
8+
import frege.test.QuickCheck
99

1010
--- compute number of divisors from prime factors combinatorically
1111
nDivisors :: Long -> Int
@@ -15,7 +15,7 @@ nDivisors = prod . map ((1+) . length) . group . factors
1515
property_nDivisors = property law
1616
where
1717
-- law :: Long -> Property
18-
law n = trivial (n==0) $
18+
law n = (classify (n==0) "trivial" $
1919
n == 0 || nDivisors (abs n) == length (divisors (abs n))
2020

2121
main _ = println . head . dropUntil ((1000<) . nDivisors) . scanl1 (+) $ [1..]

examples/Euler92.fr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
module examples.Euler92 where
1919

2020
import frege.data.List
21-
import frege.lib.QuickCheck
21+
import frege.test.QuickCheck
2222

2323
-- You are the 13904th person to have solved this problem.
2424
-- runtime 191.446 wallclock seconds. (first version with Map and canonic numbers)

frege/Prelude.fr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
--- Public interface for the various prelude modules
22
package frege.Prelude where
33

4-
import frege.prelude.PreludeBase public hiding(Ordering)
4+
import frege.prelude.PreludeBase public hiding(Ordering, Integral.big)
55
import frege.control.Semigroupoid public (.)
66
import frege.control.Category public (id)
77
-- provide some names Haskellers are used to
88
import frege.prelude.PreludeBase public (Ordering(Eq EQ, Lt LT, Gt GT), != /=)
99
import frege.prelude.PreludeBase public (from toEnum, ord fromEnum)
10+
import frege.prelude.PreludeBase public (Integral.big toInteger)
1011
import frege.prelude.PreludeNative public
1112
import frege.prelude.PreludeList public
1213
import frege.prelude.PreludeList public (fold foldl', foldl1 foldl1')

frege/PreludeProperties.fr

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,18 @@
3535
«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•» -}
3636

3737
{--
38-
* Properties of the /Prelude/.
38+
* Properties of the _Prelude_.
3939
-}
4040

41-
{-
42-
* $Revision$
43-
* $Header: E:/iwcvs/fc/frege/test/PreludeProperties.fr,v 1.5 2009/04/24 19:09:19 iw Exp $
44-
* $Log: PreludeProperties.fr,v $
45-
-}
4641

4742
package frege.PreludeProperties where
4843

4944
import Data.List
5045

5146
import frege.prelude.Math (floor)
52-
import frege.lib.QuickCheck
53-
-- import frege.prelude.PreludeList (union)
47+
import Test.QuickCheck
48+
49+
trivial = (`classify` "trivial")
5450

5551
--* a generator for all 16-bit characters
5652
chars = arbitrary::Gen Char
@@ -75,6 +71,8 @@ derive Show Small
7571
derive Enum Small
7672
instance Arbitrary Small where
7773
arbitrary = elements [SA .. SM]
74+
75+
instance CoArbitrary Small where
7876
coarbitrary n = variant (ord n)
7977

8078
-- funs = oneof [(Int.+), (-)::Int->Int->Int, Int.min, Int.max] :: Gen (Int->Int->Int)
@@ -314,7 +312,9 @@ p_listDiff = property difflaw where
314312
difflaw :: [Char] -> [Char] -> Bool
315313
difflaw xs ys =
316314
(xs ++ ys) \\ xs == ys
317-
315+
316+
p_False = once false
317+
318318
main _ = do
319319
-- stop at first failed test
320320
allSingle <- foldM (checkAnd 1) true singleChecks
@@ -326,7 +326,8 @@ main _ = do
326326
else System.exit 1
327327
where
328328
checkAnd n false prop = return false
329-
checkAnd n true prop = check quick.{configMaxTest = n} prop
329+
checkAnd n true prop = quickCheckWithResult stdArgs.{maxSuccess = n} prop
330+
>>= return . isSuccess
330331
singleChecks = [p_DataList]
331332
laws = [ p_MatcherEquivMatchGroup0, p_listDiff ]
332333
checks = [ p_OrdChar, p_DoubleRoundFloor, p_Equality, p_FloatRoundFloor,

frege/StandardLibrary.fr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ import Java.lang.Reflect()
3131

3232
import Lib.ForkJoin()
3333
import Lib.PP()
34-
import Lib.QuickCheck()
35-
import Lib.Random()
34+
import Test.QuickCheck()
35+
import System.Random()
3636

frege/compiler/DocUtils.fr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import frege.compiler.Data as D hiding(JType)
5151
import frege.compiler.Import as I()
5252
import frege.compiler.Utilities as U(print, println, theClassLoader)
5353
import frege.compiler.Classtools as CT()
54-
import frege.lib.QuickCheck as QC(property)
54+
import Test.QuickCheck as QC(property)
5555

5656
--- Represents an abstract HTML document.
5757
data Docu = Doc [Paragraph]

frege/data/NonEmpty.fr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Data.Traversable (Traversable)
77
import Data.Monoid
88
import frege.data.List ()
99
import frege.data.Maybe
10-
import frege.lib.QuickCheck
10+
import frege.test.QuickCheck
1111

1212
{--
1313
A 'NonEmpty' is like a list, but never empty.

frege/data/TreeMap.fr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,13 @@ union s1 = Tree.insertList s1 . Tree.each
323323
intersection s1 s2 = (Tree.insertList empty . filter ((s2 `contains`) . fst) . Tree.each) s1
324324
diff s1 s2 = (Tree.insertList empty . filter (not . (s2 `contains`) . fst) . Tree.each) s1
325325

326-
import frege.lib.QuickCheck
326+
import Test.QuickCheck
327327

328-
instance Arbitrary (Ord k, Arbitrary k, Arbitrary v) => (Tree k v) where
328+
instance CoArbitrary (Ord k, CoArbitrary k, CoArbitrary v) => (Tree k v) where
329329
coarbitrary Tree.Nil = variant 0
330330
coarbitrary (Tree.Node _ l r k v)
331-
= variant 1 . l.coarbitrary . r.coarbitrary . k.coarbitrary . v.coarbitrary
331+
= variant 1 . l.coarbitrary . r.coarbitrary . k.coarbitrary . v.coarbitrary
332+
instance Arbitrary (Ord k, Arbitrary k, Arbitrary v) => (Tree k v) where
332333
arbitrary :: (Ord k, Arbitrary k, Arbitrary v) => Gen (Tree k v)
333334
arbitrary = liftM Tree.fromList arbitrary
334335

0 commit comments

Comments
 (0)