Skip to content

Commit

Permalink
Fix the tests
Browse files Browse the repository at this point in the history
Fixes #26
  • Loading branch information
UnkindPartition committed Feb 9, 2014
1 parent a47f4a6 commit 20ed695
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/test.hs
Expand Up @@ -97,9 +97,12 @@ propertyTests =
, testGroup "'changeDepth' tests" changeDepthTests
]

propTrue = PropertyTrue Nothing
propFalse = PropertyFalse Nothing

simplePropertyTests =
[ testCase "Forall/no" $ check (\x -> (x^2 :: Integer) >= 2)
@?= Just (CounterExample ["0"] PropertyFalse)
@?= Just (CounterExample ["0"] propFalse)

, testCase "Forall/yes" $ check (\x -> (x^2 :: Integer) >= 0)
@?= Nothing
Expand All @@ -114,15 +117,15 @@ simplePropertyTests =
@?= Just NotExist

, testCase "ExistsUnique/isn't unique" $ check (existsUnique $ \x -> (x^2 :: Integer) > 0)
@?= Just (AtLeastTwo ["1"] PropertyTrue ["-1"] PropertyTrue)
@?= Just (AtLeastTwo ["1"] propTrue ["-1"] propTrue)

, testCase "ExistsUnique/yes" $ check (existsUnique $ \x -> (x^2 :: Integer) < 0)
@?= Just NotExist
]

combinedPropertyTests =
[ testCase "Forall+Forall/no" $ check (\x y -> x /= (y+2 :: Integer))
@?= Just (CounterExample ["0","-2"] PropertyFalse)
@?= Just (CounterExample ["0","-2"] propFalse)

, testCase "Forall+Exists/no" $ check (\x -> x > 0 ==> exists $ \y -> x == (y^2 :: Integer))
@?= Just (CounterExample ["2"] NotExist)
Expand All @@ -146,7 +149,7 @@ combinedPropertyTests =
@?= Just NotExist

, testCase "ExistsUnique (two vars)/isn't unique" $ check (existsUnique $ \x y -> abs x == (abs y :: Integer))
@?= Just (AtLeastTwo ["0","0"] PropertyTrue ["1","1"] PropertyTrue)
@?= Just (AtLeastTwo ["0","0"] propTrue ["1","1"] propTrue)

, testCase "ExistsUnique+ExistsUnique/yes" $
check (existsUnique $ \x -> existsUnique $ \y -> abs x == (abs y :: Integer))
Expand All @@ -155,7 +158,7 @@ combinedPropertyTests =

freshContexts =
[ testCase "==>" $ check (existsUnique $ \x -> (\y -> x * y >= 0) ==> (\y -> x * y == (0 :: Integer)))
@?= Just (AtLeastTwo ["0"] PropertyTrue ["1"] (Vacuously (CounterExample ["-1"] PropertyFalse)))
@?= Just (AtLeastTwo ["0"] propTrue ["1"] (Vacuously (CounterExample ["-1"] propFalse)))
, testCase "test" $ check (exists $ \x -> test $ \y -> x == (y :: Bool))
@?= Nothing
, testCase "monadic" $ check (exists $ \x -> monadic . return $ \y -> x == (y :: Bool))
Expand All @@ -166,15 +169,15 @@ overTests =
[ testCase "over+Forall/yes" $ check (over odds odd)
@?= Nothing
, testCase "over+Forall/no" $ check (over odds (<3))
@?= Just (CounterExample ["3"] PropertyFalse)
@?= Just (CounterExample ["3"] propFalse)
, testCase "over+Exists/yes" $ check (exists $ over odds (>3))
@?= Nothing
, testCase "over+Exists/no" $ check (exists $ over odds even)
@?= Just NotExist
, testCase "over+Exists/no" $ check (exists $ over odds even)
@?= Just NotExist
, testCase "ExistsUnique+ExistsUnique/isn't unique" $ check (existsUnique $ over series $ \x -> over series $ \y -> abs x == (abs y :: Integer))
@?= Just (AtLeastTwo ["0","0"] PropertyTrue ["1","1"] PropertyTrue)
@?= Just (AtLeastTwo ["0","0"] propTrue ["1","1"] propTrue)
]
where
odds :: Monad m => Series m Integer
Expand Down

0 comments on commit 20ed695

Please sign in to comment.