Commits

Sergey Astanin committed 4d98e36

integrate quickcheck tests with .cabal build: use configure --enable-tests

Comments (0)

Files changed (3)

Codec/Binary/Gray_props.hs

   let i = (arbitrary :: Gen Int)
   in  forAll i succ_test
 
-succ_test :: (Bits a) => a -> Bool
+succ_test :: (Bits a, Num a) => a -> Bool
 succ_test = \i ->
       let n2g = L.gray . L.toList
           g1 = n2g i
 prop_bits_gray_succ_Int = label "hamming x (x+1) == 1 [Int]" $
   forAll (arbitrary :: Gen Int) $ \i ->
       (hammingBits `on` B.gray) i (i+1) == 1
-     
+
 prop_bits_gray_succ_Integer = label "hamming x (x+1) == 1 [Integer]" $
   forAll (arbitrary :: Gen (NonNegative Integer)) $ \(NonNegative i) ->
       (hammingBits `on` B.gray) i (i+1) == 1
-     
-hammingBits :: (Bits a) => a -> a -> Int
+
+hammingBits :: (Bits a, Num a) => a -> a -> Int
 hammingBits = hamming `on` L.toList
 
 ---
 
   -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
   -- Build-tools:
+
+Test-Suite test-qc
+    type:       exitcode-stdio-1.0
+    main-is:    test.hs
+    build-depends: base, QuickCheck >= 2
+module Main where
+
+import Control.Monad (unless)
+import Test.QuickCheck.Test (verboseCheckResult, quickCheckResult, isSuccess)
+import System.Exit (exitFailure)
+import System.Environment (getArgs)
+
+import Codec.Binary.Gray_props
+
+main = do
+  args <- getArgs
+  let testsResult = if (("-v" `elem` args) || ("--verbose" `elem` args))
+                    then verboseCheckResult
+                    else quickCheckResult
+  result <- testsResult all_props
+  unless (isSuccess result) $ do
+         print result
+         exitFailure
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.