]> code.delx.au - offlineimap/blobdiff - testsrc/TestInfrastructure.hs
Write to stdout instead of stderr to resolve display issues
[offlineimap] / testsrc / TestInfrastructure.hs
index b2f5b841cfbbc8bacd1b81731898f6f2c8098db2..0b05e0fcd3fcc3c5855fdfe1eb3d972aa0b5beb9 100644 (file)
@@ -57,6 +57,11 @@ instance Random Word8 where
                        randomR (toInteger a, toInteger b) g
     random g = randomR (minBound, maxBound) g
 
+instance Arbitrary Char where
+    arbitrary = sized $ \n -> choose (toEnum 0, min (toEnum n) maxBound)
+    coarbitrary n = variant (if (fromEnum n) >= 0 then toEnum (2 * x) else toEnum (2 * x + 1))
+                where x = (abs . fromEnum $ n)::Int
+
 -- Modified from HUnit
 runVerbTestText :: HU.PutText st -> HU.Test -> IO (HU.Counts, st)
 runVerbTestText (HU.PutText put us) t = do
@@ -64,7 +69,7 @@ runVerbTestText (HU.PutText put us) t = do
   us'' <- put (HU.showCounts counts) True us'
   return (counts, us'')
  where
-  reportStart ss us = do hPrintf stderr "\rTesting %-68s\n" (HU.showPath (HU.path ss))
+  reportStart ss us = do hPrintf stdout "\rTesting %-68s\n" (HU.showPath (HU.path ss))
                          put (HU.showCounts (HU.counts ss)) False us
   reportError   = reportProblem "Error:"   "Error in:   "
   reportFailure = reportProblem "Failure:" "Failure in: "