Added various (QuickCheck) Result helper functions to the TestUtils module
This commit is contained in:
parent
8d89a88735
commit
140bd94ce3
|
@ -547,10 +547,6 @@ pickFuncRep gr = Map.fromList $ map (helpApplyFunc . getMetaFunc) (labNodes gr)
|
||||||
g m = everywhereM (mkM $ replaceM m (replaceMeta m))
|
g m = everywhereM (mkM $ replaceM m (replaceMeta m))
|
||||||
|
|
||||||
|
|
||||||
-- | A form of equality that yields a (QuickCheck) Result rather than a Bool, with the arguments pretty-printed
|
|
||||||
(*==*) :: (Data a, Eq a) => a -> a -> Result
|
|
||||||
(*==*) x y = Result {ok = Just (x == y), arguments = [pshow x, pshow y], stamp = []}
|
|
||||||
|
|
||||||
-- | It is important to have these functions in the right ratio. The number of possible trees is
|
-- | It is important to have these functions in the right ratio. The number of possible trees is
|
||||||
-- 2^N, where N is the test size. Therefore I suggest keeping N <= 10 as a sensible limit.
|
-- 2^N, where N is the test size. Therefore I suggest keeping N <= 10 as a sensible limit.
|
||||||
-- Hence, if there are 1000 tests, we divide the test number by 100 to get the test size.
|
-- Hence, if there are 1000 tests, we divide the test number by 100 to get the test size.
|
||||||
|
|
|
@ -71,6 +71,21 @@ scaleQC (low,med,high,ext) test level
|
||||||
run :: Testable a => Int -> a -> IO ()
|
run :: Testable a => Int -> a -> IO ()
|
||||||
run n = check (defaultConfig { configMaxTest = n })
|
run n = check (defaultConfig { configMaxTest = n })
|
||||||
|
|
||||||
|
-- | A form of equality that yields a (QuickCheck) Result rather than a Bool, with the arguments pretty-printed
|
||||||
|
(*==*) :: (Data a, Eq a) => a -> a -> Result
|
||||||
|
(*==*) x y = Result {ok = Just (x == y), arguments = [pshow x, pshow y], stamp = []}
|
||||||
|
|
||||||
|
-- | Joins together two results from (*==*). Not sure what to do with other Results (when will ok be Nothing?).
|
||||||
|
(*&&*) :: Result -> Result -> Result
|
||||||
|
(*&&*) x@(Result (Just False) _ _) _ = x
|
||||||
|
(*&&*) _ y = y
|
||||||
|
|
||||||
|
mkPassResult :: Result
|
||||||
|
mkPassResult = Result (Just True) [] []
|
||||||
|
|
||||||
|
mkFailResult :: String -> Result
|
||||||
|
mkFailResult s = Result (Just False) [s] []
|
||||||
|
|
||||||
-- | An abbreviation for using 'emptyMeta'. TODO: This should really be removed (and all uses of it replaced with 'emptyMeta') for clarity.
|
-- | An abbreviation for using 'emptyMeta'. TODO: This should really be removed (and all uses of it replaced with 'emptyMeta') for clarity.
|
||||||
m :: Meta
|
m :: Meta
|
||||||
m = emptyMeta
|
m = emptyMeta
|
||||||
|
|
Loading…
Reference in New Issue
Block a user