-
Notifications
You must be signed in to change notification settings - Fork 0
/
alga.hs
49 lines (43 loc) · 1.05 KB
/
alga.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
{-# LANGUAGE TemplateHaskell #-}
import Test.FitSpec
import Test.LeanCheck.Tiers
import Algebra.Graph
instance (Listable a, Ord a) => Listable (Graph a) where
tiers = nubT
$ cons0 Empty
\/ cons1 Vertex
\/ cons2 Overlay
\/ cons2 Connect
deriveMutableE [''Ord] ''Graph
instance Ord a => Ord (Graph a) where
(<=) = isSubgraphOf
type A = Int
properties :: ( Graph A -> Graph A -> Graph A
, Graph A -> Graph A -> Graph A )
-> [Property]
properties (plus,times) =
[ property $ \x y -> x + y == y + x
, property $ \x y z -> x + (y + z) == (x + y) + z
, property $ \x y z -> x * (y * z) == (x * y) * z
, property $ \x y z -> x * (y * z) == (x * y) + (x * z) + (y * z)
]
where
(+) = plus
(*) = times
infixl 6 +
infixl 7 *
main :: IO ()
main = do
args <- getArgsWith
args { names = ["x + y", "x * y"]
, nMutants = 1000
, nTests = 1000
, timeout = 0
}
reportWithExtra
[ ((*),(+))
, ((*),(*))
, ((+),(+)) ]
args
((+),(*))
properties