]> code.delx.au - offlineimap/commitdiff
Improved random Char generation
authorJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 07:51:08 +0000 (02:51 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Tue, 12 Aug 2008 07:51:08 +0000 (02:51 -0500)
testsrc/TestInfrastructure.hs

index feb058e186473f2cf4fb34d7a594f48994b9abe6..ec22ba7e963bafa50552d59e489284c977992585 100644 (file)
@@ -60,8 +60,8 @@ instance Random Word8 where
     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))
+    arbitrary = sized $ \n -> choose (toEnum 0, min (toEnum (n * 0x50)) maxBound)
+    coarbitrary n = variant (toEnum (2 * x + 1))
                 where x = (abs . fromEnum $ n)::Int
 
 -- Modified from HUnit