Aleksey Khudyakov avatar Aleksey Khudyakov committed c694932

Set of generic properties

Comments (0)

Files changed (1)

Test/QuickCheck/Property/Generic.hs

+-- | Generic properties of functions
+module Test.QuickCheck.Property.Generic (
+    -- * General
+    prop_Reflexive
+    -- * Monoids & co
+  , prop_Associative
+  , prop_LeftIdentity
+  , prop_RightIdentity
+  ) where
+
+import Test.QuickCheck.Property.Utils
+
+-- | Test that relation is reflective. 
+--
+-- > f x x = True
+prop_Reflexive :: (a -> a -> Bool) -> T a -> a -> Bool
+prop_Reflexive f T x = f x x
+
+-- | Test that function is associative
+prop_Associative :: (a -> a -> a) -> T a -> a -> a -> a -> Equal a
+prop_Associative (<>) T a b c = ((a <> b) <> c) `Equal` (a <> (b <> c))
+
+-- | Test that value is a left identity
+prop_LeftIdentity :: a             -- ^ Left identity
+                  -> (a -> a -> a) -- ^ Function
+                  -> T a
+                  -> a -> Equal a
+prop_LeftIdentity e (<>) T x = (e <> x) `Equal` x
+
+-- | Test that value is a left identity
+prop_RightIdentity :: a             -- ^ Right identity
+                   -> (a -> a -> a) -- ^ Function
+                   -> T a
+                   -> a -> Equal a
+prop_RightIdentity e (<>) T x = (e <> x) `Equal` x
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.