-
Notifications
You must be signed in to change notification settings - Fork 0
/
Testing.hs
64 lines (47 loc) · 1.24 KB
/
Testing.hs
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Testing where
import Test.QuickCheck
import Data.List
testOrdered :: OrderedList Int -> Bool
testOrdered _ = True
-- verboseCheck testNonEmpty
testNonEmpty :: NonEmptyList (Positive Int) -> Bool
testNonEmpty xs = length xs'' > 0
where
xs' = getNonEmpty xs
xs'' = map getPositive xs'
testNonZero :: NonZero Int -> Bool
testNonZero _ = True
testFixed :: Fixed Int -> Bool
testFixed (Fixed x) = True
{--
OrderedList
NonEmptyList
Positive
NonZero
NonNegative
Large
Small
Fixed
--}
-- Generator
newtype Set' a = Set' [a] deriving (Eq,Ord)
list2set' :: Ord a => [a] -> Set' a
list2set' xs = Set' (sort (nub xs))
instance (Ord a, Arbitrary a) => Arbitrary (Set' a) where
arbitrary = do
xs <- arbitrary
return (list2set' xs)
randomIntSetGenerator :: Gen (Set' Int)
randomIntSetGenerator = do
list <- listOf arbitrary
return (list2set' list)
randomIntSets :: IO (Set' Int)
randomIntSets = generate (randomIntSetGenerator::Gen (Set' Int))
qcFunc1 :: Set' Int -> Bool
qcFunc1 _ = True
-- Arbitrary type
newtype Vowel = Vowel String deriving (Eq,Ord,Show)
instance Arbitrary Vowel where
arbitrary = oneof (map (return.Vowel) ["a", "e", "i", "o", "u"])
testVowelList :: [Vowel] -> Bool
testVowelList vs = True