qc-oi-testgenerator 1.2.0.2 → 1.2.0.3
raw patch · 3 files changed
+25/−16 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Test/OITestGenerator.hs +17/−10
- Test/OITestGenerator/Axiom.hs +1/−1
- qc-oi-testgenerator.cabal +7/−5
Test/OITestGenerator.hs view
@@ -9,8 +9,15 @@ Stability : provisional Portability : non-portable (Template-Haskell) -("QuickCheck"-)tests for data types are often formulated as equations, i.e.+This library is based on the following paper: +* /Automatic Testing of Operation Invariance/, presented at WFLP'14.+ <http://www.iai.uni-bonn.de/~jv/GV14.html>++A high-level explanation follows:++("QuickCheck"-)tests for data types are often formulated as equations, e.g.+ >rev_test :: Property >rev_test = property $ \xs ys -> reverse ys ++ reverse xs == reverse (xs ++ ys) @@ -24,10 +31,10 @@ 3. if @x == y@ and @y == z@ are 'True', @x == z@ should also be 'True' (transitivity). - 4. if @x == y@ is true, @f x == f y@ should also be 'True' (congruence or+ 4. if @x == y@ is 'True', @f x == f y@ should also be 'True' (congruence or operation invariance). -It is unlikely to accidentally write an 'Eq' instance that does not satisfy 1-3.+It is unlikely to accidentally write an 'Eq' instance that does not satisfy 1.-3. Operation invariance however is fickle, as it also implies sane behaviour of all functions on the data type. @@ -48,7 +55,7 @@ >property $ \x q -> not (isEmpty q) ==> dequeue (enqueue x q) == enqueue x (dequeue q) -while this would be formulated as an axiom as follows:+while this would be formulated as an axiom for use with this package as follows: >q6 x q = not (isEmpty q) ===> dequeue (enqueue x q) =!= enqueue x (dequeue q) @@ -68,7 +75,7 @@ The single quotes preceding @q1@ to @q6@ quote each following name as a Template Haskell 'Language.Haskell.TH.Syntax.Name'. Note that @$(...)@ is a Template Haskell splice and will be evaluated during compile time. Because of-this, you might not refer to declarations of the same module except by name+this, you may not refer to declarations of the same module except by name (this is called the stage restriction), which is the motivation for the @let ... in ...@ construct. @@ -90,17 +97,17 @@ > in generate_oi_tests axs ops) For every operation @f@ and every axiom @lhs =!= rhs@, a test @f lhs == f rhs@-will be generated if it is typecorrect. Note that polymorphic types aren't-supported yet, but you can simply rename and specialize them, i.e.+will be generated if it is type correct. Note that polymorphic types aren't+supported yet, but you can simply rename and specialize them, e.g. >reverse_ints :: [Int] -> [Int] >reverse_ints = reverse -and test the renamed function. Besides typechecking, 'generate_oi_tests' takes+and test the renamed function. Besides type checking, 'generate_oi_tests' takes care of * passing axiom arguments, e.g. @f@ and @ax x = lhs x =!= rhs x@ will get- translated to @\x -> f (lhs x) == f (rhs x)@.+ translated to @\\x -> f (lhs x) == f (rhs x)@. * multiple operation arguments, e.g. for an @f :: A -> A -> B -> C@ and an axiom with result @A@, both tests @f lhs y z == f rhs y z@ and @f x lhs z ==@@ -144,7 +151,7 @@ generate_basic_tests :: [Axiom] -> ExpQ generate_basic_tests = liftM ListE . mapM gen_basic_test --- | Generate all operation invariance tests that typecheck. For example, given+-- | Generate all operation invariance tests that type check. For example, given -- an operation -- -- >f :: A -> A -> B -> C
Test/OITestGenerator/Axiom.hs view
@@ -34,7 +34,7 @@ infixr 0 ===> -- | Adds a condition to an axiom. If the 'Bool' argument is 'False', the axiom -- won't be evaluated. The test will neither count as a failed test, nor as--- a successful test. It translates to QuickChecks '==>' operator.+-- a successful test. It translates to the QuickCheck operator '==>'. -- -- Example usage: --
qc-oi-testgenerator.cabal view
@@ -1,10 +1,12 @@--- Initial qc-oi-testgenerator.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/- name: qc-oi-testgenerator-version: 1.2.0.2+version: 1.2.0.3 synopsis: Compile time generation of operation invariance tests for QuickCheck--- description:+description:+ This package generates operation invariance tests for QuickCheck from+ equation-based, QuickCheck-like properties at compile time. It+ implements the approach from the paper \"Automatic Testing of Operation+ Invariance\" presented at WFLP'14. The paper can be downloaded at+ <http://www.iai.uni-bonn.de/~jv/GV14.html>. --homepage: http://tobias.goedderz.info/haskell/qc-oi-testgenerator/ homepage: http://www.iai.uni-bonn.de/~jv/GV14.html license: BSD3