summaryrefslogtreecommitdiff
path: root/test/Spec.hs
blob: 42d4ed1918ab590c68cae8b2ac98b7bf93ef6093 (plain)
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
{-# 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