summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndor Penzes <andor.penzes@gmail.com>2016-01-07 22:58:12 +0100
committerAndor Penzes <andor.penzes@gmail.com>2016-01-07 23:13:12 +0100
commitd47618f72d7d9e84c7d531f07863918298681947 (patch)
treecb885e642aea720bea8e68c9ceaf2644a2ce0f5b /test
parent5207d3d9c90344f82947d592224a7e06e98211c6 (diff)
add left and right monoid identity
Diffstat (limited to 'test')
-rw-r--r--test/UnitTests.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/UnitTests.hs b/test/UnitTests.hs
index 59a95601..46bec55f 100644
--- a/test/UnitTests.hs
+++ b/test/UnitTests.hs
@@ -12,8 +12,9 @@ import Infer
12 12
13main = defaultMain $ testGroup "Compiler" 13main = defaultMain $ testGroup "Compiler"
14 [ testGroup "Infer" [ 14 [ testGroup "Infer" [
15 testProperty "SI Monoid Identity" (propMonoidIdentity (arbitrary :: Gen SI)) 15 testProperty "SI monoid left identity" (propMonoidLeftIdentity (arbitrary :: Gen SI))
16 , testProperty "SI Monoid Associativity" (propMonoidAssociativity (arbitrary :: Gen SI)) 16 , testProperty "SI monoid right identity" (propMonoidRightIdentity (arbitrary :: Gen SI))
17 , testProperty "SI monoid associativity" (propMonoidAssociativity (arbitrary :: Gen SI))
17 ] 18 ]
18 ] 19 ]
19 20
@@ -35,8 +36,11 @@ instance Arbitrary SI where
35 36
36-- * Monoid 37-- * Monoid
37 38
38propMonoidIdentity :: (Eq m, Monoid m, Show m) => Gen m -> Property 39propMonoidLeftIdentity :: (Eq m, Monoid m, Show m) => Gen m -> Property
39propMonoidIdentity gen = forAll gen (\x -> x === x <> mempty) 40propMonoidLeftIdentity gen = forAll gen (\x -> x === mempty <> x)
41
42propMonoidRightIdentity :: (Eq m, Monoid m, Show m) => Gen m -> Property
43propMonoidRightIdentity gen = forAll gen (\x -> x === x <> mempty)
40 44
41propMonoidAssociativity :: (Arbitrary m, Eq m, Monoid m, Show m) => Gen m -> Property 45propMonoidAssociativity :: (Arbitrary m, Eq m, Monoid m, Show m) => Gen m -> Property
42propMonoidAssociativity gen = forAll gen (\x y z -> (x <> y) <> z == x <> (y <> z)) 46propMonoidAssociativity gen = forAll gen (\x y z -> (x <> y) <> z === x <> (y <> z))