summaryrefslogtreecommitdiff
path: root/test/Spec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Spec.hs')
-rw-r--r--test/Spec.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Spec.hs b/test/Spec.hs
new file mode 100644
index 0000000..42d4ed1
--- /dev/null
+++ b/test/Spec.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE PartialTypeSignatures #-}
+
+module Main (main) where
+
+import Prelude hiding (filter)
+import Control.Applicative
+import Data.Foldable
+import Data.Filtrable
+import qualified Data.List as List
+import Test.SmallCheck
+import Test.Tasty
+import Test.Tasty.SmallCheck
+
+main :: IO ()
+main = defaultMain $ testGroup ""
+ [ testGroup "Filtrable"
+ [ testProperty "filter" (prop_filter :: _ -> [Maybe Bool] -> _)
+ ]
+ , testGroup "nub"
+ [ testProperty "nub" (prop_nub :: [Int] -> _)
+ , testProperty "nubOrd" (prop_nubOrd :: [Int] -> _)
+ ]
+ ]
+
+prop_filter :: (Filtrable f, Foldable f) => (a -> Bool) -> f a -> Bool
+prop_filter = liftA2 (.) all filter
+
+prop_nub :: (Filtrable f, Traversable f, Eq a) => f a -> Bool
+prop_nub = (==) <$> List.nub . toList <*> toList . nub
+
+prop_nubOrd :: (Filtrable f, Traversable f, Ord a) => f a -> Bool
+prop_nubOrd = (==) <$> List.nub . toList <*> toList . nubOrd