Skip to content

Commit

Permalink
Added Pair tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Soares committed Apr 7, 2012
1 parent 49de3bd commit 4141467
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/Test/Data/Pair.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
module Properties.Pair where
import Pair
{-# LANGUAGE ScopedTypeVariables #-}
module Test.Data.Pair where
import Data.Pair
import Test.Framework
import Test.Framework.Providers.QuickCheck2
import Test.QuickCheck

propInversion :: (Eq (p a b), Pair p) => p a b -> Bool
propInversion p = p == fromTuple (toTuple p)
testPair :: forall p a b.
( Eq (p a b)
, Show (p a b)
, Arbitrary (p a b)
, Pair p) => p a b -> Test
testPair _ = testGroup "pair"
[ testProperty "indempotence" (\(p::p a b) -> fromTuple (toTuple p) == p)
, testProperty "rebuild" (\(p::p a b) -> build (left p) (right p) == p)
]
5 changes: 4 additions & 1 deletion src/Test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Test.Data.Enum
import Test.Data.Modable
import Test.Data.Naturals
import Test.Data.Normalize
import Test.Data.Pair
import Test.Data.Zeroed

import Data.DateTime.Gregorian
Expand All @@ -30,12 +31,14 @@ tests =
, testModable (undefined::YMD)
, testNormal (undefined::YMD)
, testProperty "no overflow" (\(a::YMD) -> fst (normalize a) == 0)
, testPair (undefined::YMD)
]
, testGroup "HMS"
[ testEnum (undefined::HMS)
, testCoded (undefined::HMS)
, testModable (undefined::HMS)
, testNormal (undefined::YMD)
, testNormal (undefined::HMS)
, testPair (undefined::HMS)
, testProperty "reconstructible" (\(a::HMS) ->
let (o, b) = normalize a
size = succ (maxBound - minBound :: HMS)
Expand Down

0 comments on commit 4141467

Please sign in to comment.