factory-0.1.0.0: src/Factory/Test/QuickCheck/Interval.hs
{-
Copyright (C) 2011 Dr. Alistair Ward
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-}
{- |
[@AUTHOR@] Dr. Alistair Ward
[@DESCRIPTION@] Defines /QuickCheck/-properties for "Data.Interval".
-}
module Factory.Test.QuickCheck.Interval(
-- * Functions
quickChecks
) where
import qualified Data.Ratio
import qualified Factory.Data.Interval as Data.Interval
import qualified Test.QuickCheck
-- | Defines invariant properties.
quickChecks :: IO ()
quickChecks = Test.QuickCheck.quickCheckWith Test.QuickCheck.stdArgs {Test.QuickCheck.maxSuccess = 1000} prop_product where
prop_product :: Data.Ratio.Ratio Integer -> Integer -> Data.Interval.Interval Integer -> Test.QuickCheck.Property
prop_product ratio minLength interval = Test.QuickCheck.label "prop_product" $ Data.Interval.product' ratio' minLength' interval' == product (Data.Interval.toList interval') where
interval' = Data.Interval.normalise interval
minLength' = 1 + minLength `mod` 1000
ratio' = if r > 1
then recip r
else r
where
r = abs ratio