44
55module TestUtil (
66 module TestUtil ,
7- module Test.QuickCheck ,
7+ module Test.Tasty. QuickCheck ,
88 module Data.List ,
99 module Data.Maybe
1010 ) where
1111
12- import Test.QuickCheck hiding ((==>) )
12+ import Test.Tasty. QuickCheck hiding ((==>) )
1313import Data.ByteString.Short (ShortByteString )
1414import Data.List
1515import Data.Maybe
@@ -29,7 +29,6 @@ import System.OsString.Encoding.Internal
2929import GHC.IO.Encoding.UTF16 ( mkUTF16le )
3030import GHC.IO.Encoding.UTF8 ( mkUTF8 )
3131import GHC.IO.Encoding.Failure
32- import System.Environment
3332
3433
3534infixr 0 ==>
@@ -158,31 +157,3 @@ instance Arbitrary PosixChar where
158157 arbitrary = PW <$> arbitrary
159158#endif
160159
161- runTests :: [(String , Property )] -> IO ()
162- runTests tests = do
163- args <- getArgs
164- let count = case args of i: _ -> read i; _ -> 10000
165- let testNum = case args of
166- _: i: _
167- | let num = read i
168- , num < 0 -> drop (negate num) tests
169- | let num = read i
170- , num > 0 -> take num tests
171- | otherwise -> []
172- _ -> tests
173- putStrLn $ " Testing with " ++ show count ++ " repetitions"
174- let total' = length testNum
175- let showOutput x = show x{output= " " } ++ " \n " ++ output x
176- bad <- fmap catMaybes $ forM (zip @ Integer [1 .. ] testNum) $ \ (i,(msg,prop)) -> do
177- putStrLn $ " Test " ++ show i ++ " of " ++ show total' ++ " : " ++ msg
178- res <- quickCheckWithResult stdArgs{chatty= False , maxSuccess= count} prop
179- case res of
180- Success {} -> pure Nothing
181- bad -> do putStrLn $ showOutput bad; putStrLn " TEST FAILURE!" ; pure $ Just (msg,bad)
182- if null bad then
183- putStrLn $ " Success, " ++ show total' ++ " tests passed"
184- else do
185- putStrLn $ show (length bad) ++ " FAILURES\n "
186- forM_ (zip @ Integer [1 .. ] bad) $ \ (i,(a,b)) ->
187- putStrLn $ " FAILURE " ++ show i ++ " : " ++ a ++ " \n " ++ showOutput b ++ " \n "
188- fail $ " FAILURE, failed " ++ show (length bad) ++ " of " ++ show total' ++ " tests"
0 commit comments