1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
-- File created: 2008-10-10 16:28:53
module Tests.Utils (tests) where
import Data.Maybe
import Test.Framework
import Test.Framework.Providers.QuickCheck
import Test.QuickCheck
import System.FilePath.Glob.Utils
import Utils
tests = testGroup "Utils"
[ testProperty "overlapperLosesNoInfo" prop_overlapperLosesNoInfo
, testProperty "increasingSeq" prop_increasingSeq
, testProperty "addToRange" prop_addToRange
]
validateRange (a,b) = if b > a then (a,b) else (b,a)
prop_overlapperLosesNoInfo x1 x2 c =
let r1 = validateRange x1
r2 = validateRange x2
_ = c :: Float
in case overlap r1 r2 of
-- if the ranges don't overlap, nothing should be in both ranges
Nothing -> not (inRange r1 c && inRange r2 c)
-- if they do and something is in a range, it should be in the
-- overlapped one as well
Just o -> (inRange r1 c --> inRange o c) &&
(inRange r2 c --> inRange o c)
prop_increasingSeq a xs =
let s = fst . increasingSeq $ a:xs
in s == reverse [a :: Float .. head s]
prop_addToRange x c =
let r = validateRange x
r' = addToRange r c
in isJust r' ==> inRange (fromJust r') (c :: Float)
|