diff --git a/Utility/InodeCache.hs b/Utility/InodeCache.hs index 511127842d..5f7d788d70 100644 --- a/Utility/InodeCache.hs +++ b/Utility/InodeCache.hs @@ -269,16 +269,8 @@ instance Arbitrary MTime where arbitrary = frequency -- timestamp is not usually negative [ (50, MTimeLowRes <$> (abs . fromInteger <$> arbitrary)) - , (50, MTimeHighRes <$> (abs <$> arbposixtime)) + , (50, MTimeHighRes <$> arbitrary) ] - where - -- include fractional part, which the usual instance does not - arbposixtime = do - t <- arbitrary - f <- arbitrary - return $ if f == 0 - then t - else t + recip f #ifdef mingw32_HOST_OS instance Arbitrary FileID where diff --git a/Utility/QuickCheck.hs b/Utility/QuickCheck.hs index 6a0c1a965d..fb9932a227 100644 --- a/Utility/QuickCheck.hs +++ b/Utility/QuickCheck.hs @@ -15,17 +15,23 @@ module Utility.QuickCheck import Test.QuickCheck as X import Data.Time.Clock.POSIX +import Data.Ratio import System.Posix.Types -import Control.Applicative import Prelude -{- Times before the epoch are excluded, and no fraction is included. -} +{- Times before the epoch are excluded. Half with decimal and half without. -} instance Arbitrary POSIXTime where - arbitrary = fromInteger <$> nonNegative arbitrarySizedIntegral + arbitrary = do + n <- nonNegative arbitrarySizedBoundedIntegral :: Gen Int + d <- nonNegative arbitrarySizedIntegral + withd <- arbitrary + return $ if withd + then fromIntegral n + fromRational (1 % max d 1) + else fromIntegral n {- Pids are never negative, or 0. -} instance Arbitrary ProcessID where - arbitrary = arbitrarySizedBoundedIntegral `suchThat` (> 0) + arbitrary = positive arbitrarySizedBoundedIntegral {- Inodes are never negative. -} instance Arbitrary FileID where