packages feed

hspec-multicheck (empty) → 0.1

raw patch · 8 files changed

+167/−0 lines, 8 filesdep +QuickCheckdep +basedep +hspecsetup-changed

Dependencies added: QuickCheck, base, hspec, hspec-multicheck, hspec-smallcheck, smallcheck

Files

+ CHANGELOG.md view
@@ -0,0 +1,7 @@+Changes+=======++Version 0.1+-----------++* Provide ability to test using QuickCheck and smallcheck using one property statement
+ LICENSE view
@@ -0,0 +1,24 @@+This is free and unencumbered software released into the public domain.++Anyone is free to copy, modify, publish, use, compile, sell, or+distribute this software, either in source code form or as a compiled+binary, for any purpose, commercial or non-commercial, and by any+means.++In jurisdictions that recognize copyright laws, the author or authors+of this software dedicate any and all copyright interest in the+software to the public domain. We make this dedication for the benefit+of the public at large and to the detriment of our heirs and+successors. We intend this dedication to be an overt act of+relinquishment in perpetuity of all present and future rights to this+software under copyright law.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.++For more information, please refer to <https://unlicense.org>
+ README.md view
@@ -0,0 +1,12 @@+# hspec-multicheck [![Build Status](https://travis-ci.org/marcellussiegburg/hspec-multicheck.svg?branch=master)](https://travis-ci.org/marcellussiegburg/hspec-multicheck)++A testing framework for [Haskell](https://www.haskell.org) using [Hspec](http://hspec.github.io).+Basically the framework is identical to Hspec.+However, this framework is designed to execute all test cases using both, QuickCheck and Smallcheck.+Thus, instances for Arbitrary and Series might be required for variables used in test cases.++If you want to test all your properties using QuickCheck and smallcheck you may use this library to reduce code duplication.++Have a look at [ListSpec.hs](https://github.com/marcellussiegburg/hspec-multicheck/blob/master/test/Data/ListSpec.hs) if you would like to see an example (e.g. for quickly getting started).++For further information you may have a look at the pages of [Hspec](http://hspec.github.io), [QuickCheck](http://www.cse.chalmers.se/~rjmh/QuickCheck/) and [smallcheck](https://www.cs.york.ac.uk/fp/smallcheck/).
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hspec-multicheck.cabal view
@@ -0,0 +1,41 @@+name:          hspec-multicheck+version:       0.1+license:       PublicDomain+license-file:  LICENSE+author:        Marcellus Siegburg+maintainer:    Marcellus Siegburg <msi@informatik.uni-kiel.de>+build-type:    Simple+cabal-version: >=1.10+category:      Testing+stability:     experimental+homepage:      https://github.com/marcellussiegburg/hspec-multicheck+bug-reports:   https://github.com/marcellussiegburg/hspec-multicheck/issues+synopsis:      A testing framework for Haskell using Hspec+description:   Hspec Multicheck is an extension to the framework Hspec for+               Haskell. It enables execution of all defined tests using multiple+               different testing libraries while avoiding code duplication.++extra-source-files: CHANGELOG.md, README.md++source-repository head+  type:     git+  location: https://github.com/marcellussiegburg/hspec-multicheck++library+  ghc-options:      -Wall+  hs-source-dirs:   src+  default-language: Haskell2010+  build-depends:    base < 5,+                    hspec, hspec-smallcheck, QuickCheck,+                    smallcheck >= 1.1.2+  exposed-modules:  Test.Hspec.Multicheck++test-suite test+  ghc-options:      -Wall+  type:             exitcode-stdio-1.0+  hs-source-dirs:   test+  main-is:          Spec.hs+  build-depends:    base, hspec,+                    hspec-multicheck+  other-modules:    Data.ListSpec+  default-language: Haskell2010
+ src/Test/Hspec/Multicheck.hs view
@@ -0,0 +1,69 @@+{-|+Module:      Test.Hspec.Multicheck+Description: A testing framework based on hspec.+Copyright:   (c) Marcellus Siegburg, 2017+License:     PublicDomain+Maintainer:  Marcellus Siegburg <msi@informatik.uni-kiel.de>+Stability:   Experimental++This module imports and reexports Hspec.+However, the functions 'it' and 'specify' are changed.+Thus, QuickCheck and smallcheck are executed for every test case that is+specified using this library.+-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FlexibleContexts #-}+module Test.Hspec.Multicheck (+  module Test.Hspec,+  (==>), it, property, specify+  ) where++import qualified Test.QuickCheck       as QC+import qualified Test.SmallCheck       as SC+import qualified Test.Hspec.SmallCheck as SC+import           Test.Hspec            hiding (it, specify)+import qualified Test.Hspec            as Hspec++import Prelude hiding (length)++{-|+Creates a spec item for SmallCheck and QuickCheck by calling Hspecs 'Hspec.it' for each+within the spec monad.+-}+it :: (QC.Testable prop, SC.Testable IO prop) => String -> prop -> Spec+it descr p = do+  Hspec.it (descr ++ " (SC)") $ SC.property p+  Hspec.it (descr ++ " (QC)") $ QC.property p++{-|+A synonym for 'it'.+-}+specify :: (QC.Testable prop, SC.Testable IO prop) => String -> prop -> Spec+specify = it++infixr 0 ==>++{-|+Implication for properties: Applied using Smallchecks 'SC.==>' and+QuickChecks 'QC.==>' and returned as tuple.+-}+(==>) :: (SC.Testable m prop, QC.Testable prop)+  => Bool -> prop -> (SC.Property m, QC.Property)+cond ==> p = (cond SC.==> p, cond QC.==> p)++{-|+Converts the given parameter to a tuple of properties.+I.e. a Smallcheck 'SC.Property' and a QuickCheck 'QC.Property'.+-}+property :: (SC.Testable IO prop, QC.Testable prop)+  => prop -> (SC.Property IO, QC.Property)+property p = (SC.property p, QC.property p)++instance QC.Testable (SC.Property m, QC.Property) where+  property (_, p) = QC.property p++instance (Monad m, m ~ n) => SC.Testable n (SC.Property m, QC.Property) where+  test (p, _) = SC.test p
+ test/Data/ListSpec.hs view
@@ -0,0 +1,11 @@+module Data.ListSpec where++import Prelude+import Test.Hspec.Multicheck++spec :: Spec+spec =+  describe "length" $+    it "is higher for longer lists" $ property $ \ xs ->+      not (null xs) ==> length xs > length (tail (xs :: [Int]))+
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}