/usr/lib/hugs/packages/QuickCheck/Test/QuickCheck/Utils.hs is in libhugs-quickcheck-bundled 98.200609.21-5.4+b3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | -----------------------------------------------------------------------------
-- |
-- Module : Test.QuickCheck.Utils
-- Copyright : (c) Andy Gill 2001
-- License : BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
-- Portability : portable
--
-- These are some general purpose utilities for use with QuickCheck.
--
-----------------------------------------------------------------------------
module Test.QuickCheck.Utils
( isAssociativeBy
, isAssociative
, isCommutableBy
, isCommutable
, isTotalOrder
) where
import Prelude
import Test.QuickCheck
isAssociativeBy :: (Show a,Testable prop)
=> (a -> a -> prop) -> Gen a -> (a -> a -> a) -> Property
isAssociativeBy (===) src (**) =
forAll src $ \ a ->
forAll src $ \ b ->
forAll src $ \ c ->
((a ** b) ** c) === (a ** (b ** c))
isAssociative :: (Arbitrary a,Show a,Eq a) => (a -> a -> a) -> Property
isAssociative = isAssociativeBy (==) arbitrary
isCommutableBy :: (Show a,Testable prop)
=> (b -> b -> prop) -> Gen a -> (a -> a -> b) -> Property
isCommutableBy (===) src (**) =
forAll src $ \ a ->
forAll src $ \ b ->
(a ** b) === (b ** a)
isCommutable :: (Arbitrary a,Show a,Eq b) => (a -> a -> b) -> Property
isCommutable = isCommutableBy (==) arbitrary
isTotalOrder :: (Arbitrary a,Show a,Ord a) => a -> a -> Property
isTotalOrder x y =
classify (x > y) "less than" $
classify (x == y) "equals" $
classify (x < y) "greater than" $
x < y || x == y || x > y
|