From: John Goerzen Date: Tue, 12 Aug 2008 07:51:08 +0000 (-0500) Subject: Improved random Char generation X-Git-Url: https://code.delx.au/offlineimap/commitdiff_plain/e76000bc1846d6a989bfab9e4db5319304562df2 Improved random Char generation --- diff --git a/testsrc/TestInfrastructure.hs b/testsrc/TestInfrastructure.hs index feb058e..ec22ba7 100644 --- a/testsrc/TestInfrastructure.hs +++ b/testsrc/TestInfrastructure.hs @@ -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