-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.hs
71 lines (60 loc) · 1.72 KB
/
list.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
65
66
67
68
69
70
import Test.FitSpec
import Data.List
type Cons a = a -> [a] -> [a]
type Head a = [a] -> a
type Tail a = [a] -> [a]
type Append a = [a] -> [a] -> [a]
type Ty a = ( Cons a
, Head a
, Tail a
, Append a
)
-- The property map
properties :: (Eq a, Show a, Listable a)
=> Cons a
-> Head a
-> Tail a
-> Append a
-> [Property]
properties (-:) head tail (++) =
[ property $ \xs -> [] ++ xs == xs && xs == xs ++ []
, property $ \x xs -> head (x-:xs) == x
, property $ \x xs -> tail (x-:xs) == xs
, property $ \xs -> null (xs ++ xs) == null xs
, property $ \xs ys zs -> (xs ++ ys) ++ zs == xs ++ (ys ++ zs)
, property $ \x xs ys -> x-:(xs ++ ys) == (x-:xs) ++ ys
]
fns :: Ty a
fns = ((:),head,tail,(++))
sargs :: Args
sargs = args
{ names = ["(:) x xs","head xs","tail xs","(++) xs ys"]
, nMutants = 1000
, nTests = 1000
, timeout = 0
}
--, extraMutants = takeWhile (const False)
-- [ ((:),head,tail,(++-))
-- , ((:),head,tail,(++--))
-- ]
main :: IO ()
main = do
as <- getArgsWith sargs
let run f = reportWith as f (uncurry4 properties)
case concat (extra as) of
"bool" -> run (fns :: Ty Bool)
"bools" -> run (fns :: Ty [Bool])
"int" -> run (fns :: Ty Int)
"int2" -> run (fns :: Ty UInt2)
"int3" -> run (fns :: Ty UInt3)
"unit" -> run (fns :: Ty ())
"" -> run (fns :: Ty UInt2)
-- Some manual mutants
(++-) :: [a] -> [a] -> [a]
xs ++- ys = []
(++--) :: [a] -> [a] -> [a]
xs ++-- ys = if length xs > length ys
then xs
else ys
uncurry4 :: (a -> b -> c -> d -> e) -> (a,b,c,d) -> e
uncurry4 f (x,y,z,w) = f x y z w