diff options
author | Andor Penzes <andor.penzes@gmail.com> | 2016-01-07 22:58:12 +0100 |
---|---|---|
committer | Andor Penzes <andor.penzes@gmail.com> | 2016-01-07 23:13:12 +0100 |
commit | d47618f72d7d9e84c7d531f07863918298681947 (patch) | |
tree | cb885e642aea720bea8e68c9ceaf2644a2ce0f5b /test | |
parent | 5207d3d9c90344f82947d592224a7e06e98211c6 (diff) |
add left and right monoid identity
Diffstat (limited to 'test')
-rw-r--r-- | test/UnitTests.hs | 14 |
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 | ||
13 | main = defaultMain $ testGroup "Compiler" | 13 | main = 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 | ||
38 | propMonoidIdentity :: (Eq m, Monoid m, Show m) => Gen m -> Property | 39 | propMonoidLeftIdentity :: (Eq m, Monoid m, Show m) => Gen m -> Property |
39 | propMonoidIdentity gen = forAll gen (\x -> x === x <> mempty) | 40 | propMonoidLeftIdentity gen = forAll gen (\x -> x === mempty <> x) |
41 | |||
42 | propMonoidRightIdentity :: (Eq m, Monoid m, Show m) => Gen m -> Property | ||
43 | propMonoidRightIdentity gen = forAll gen (\x -> x === x <> mempty) | ||
40 | 44 | ||
41 | propMonoidAssociativity :: (Arbitrary m, Eq m, Monoid m, Show m) => Gen m -> Property | 45 | propMonoidAssociativity :: (Arbitrary m, Eq m, Monoid m, Show m) => Gen m -> Property |
42 | propMonoidAssociativity gen = forAll gen (\x y z -> (x <> y) <> z == x <> (y <> z)) | 46 | propMonoidAssociativity gen = forAll gen (\x y z -> (x <> y) <> z === x <> (y <> z)) |