smallcheck-laws 0.1 → 0.2
raw patch · 9 files changed
+35/−301 lines, 9 filesdep −smallcheck-lawsdep −tastydep −tasty-smallcheckdep ~smallcheck
Dependencies removed: smallcheck-laws, tasty, tasty-smallcheck
Dependency ranges changed: smallcheck
Files
- CHANGELOG.md +11/−2
- README.md +15/−18
- Test/Tasty/SmallCheck/Laws/Applicative.hs +0/−49
- Test/Tasty/SmallCheck/Laws/Functor.hs +0/−29
- Test/Tasty/SmallCheck/Laws/Monad.hs +0/−36
- Test/Tasty/SmallCheck/Laws/Monoid.hs +0/−26
- smallcheck-laws.cabal +7/−40
- stack.yaml +2/−2
- tests/tasty.hs +0/−99
CHANGELOG.md view
@@ -4,8 +4,17 @@ CHANGELOG](http://keepachangelog.com/). This project adheres to [Semantic Versioning](http://semver.org/). -## [0.1]+## [0.2] - 2015-09-04+### Removed+- Move `Tasty` modules to a separate package+ [`tasty-laws`](https://hackage.haskell.org/package/tasty-laws).++## [0.1] - 2015-08-05 ### Added+- Functor laws.+- Applicative laws. - Monoid Laws.+- Monad laws. -[0.1]: https://github.com/jdnavarro/smallcheck-laws/compare/ROOT...v0.1+[0.2]: https://github.com/jdnavarro/smallcheck-laws/compare/v0.1...v0.2+[0.1]: https://github.com/jdnavarro/smallcheck-laws/compare/bf1caa...v0.1
README.md view
@@ -1,26 +1,23 @@ # SmallCheck Laws -[](https://hackage.haskell.org/package/smallcheck-laws) [](https://travis-ci.org/jdnavarro/smallcheck-laws)--Automatic `smallcheck` properties and `tasty` runners for:+[](https://hackage.haskell.org/package/smallcheck-laws)+[](https://travis-ci.org/jdnavarro/smallcheck-laws) - - Monoid laws.- - Functor laws.- - Applicative laws.- - Monad laws.+[`smallcheck`](https://hackage.haskell.org/package/smallcheck) properties for+the following laws: -## Installation+- Monoid+- Functor+- Applicative+- Monad -Make sure you have [`stack`](https://github.com/commercialhaskell/stack)-installed. Then type:+Use this package to create your own fine tuned `smallcheck` tests. For+preassembled test runners with minimal setup and sensible defaults, you can use+[`tasty-laws`](https://hackage.haskell.org/package/tasty-laws). -```sh-$ stack build-```-To run the test suite type:+## Contact -```sh-$ stack test-```+Contributions and bug reports are welcome! -<!-- TODO: Write minitutorial here about to use 'tasty' orphan instances -->+Please feel free to contact jdnavarro on the #haskell IRC channel on+irc.freenode.net.
− Test/Tasty/SmallCheck/Laws/Applicative.hs
@@ -1,49 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}-module Test.Tasty.SmallCheck.Laws.Applicative where--#if !MIN_VERSION_base(4,8,0)-import Control.Applicative (Applicative)-#endif-import Data.Functor.Identity (Identity)-import Data.Proxy (Proxy(..))-import Test.Tasty (TestTree, testGroup)-import Test.Tasty.SmallCheck (testProperty)-import Test.SmallCheck.Series (Series, Serial(series))--import qualified Test.SmallCheck.Laws.Applicative as Applicative-import Test.Tasty.SmallCheck.Laws.Functor---- | @tasty@ 'TestTree' for 'Applicative' laws. You need to provide the type--- wrapped in a `Proxy` and make sure 'a' is an instance of 'Serial'.-testApplicative- :: forall f a .- ( Applicative f- , Show a, Eq a- , Show (f a), Eq (f a), (Eq (f (f a)))- , Show (f (a -> a))- , Serial IO a- , Serial IO (f a)- , Serial IO (a -> a)- , Serial IO (f (a -> a))- , Serial Identity a, Serial Identity (f a)- )- => Proxy (f a) -> TestTree-testApplicative proxy = testGroup "Applicative"- [ testFunctor proxy- , testProperty "pure id <*> v ≡ v"- $ Applicative.identity (series :: Series IO (f a))- , testProperty "(.) <$> u <*> v <*> w ≡ u <*> (v <*> w)"- $ Applicative.composition- (series :: Series IO (f (a -> a)))- (series :: Series IO (f a))- (series :: Series IO (f (a -> a)))- , testProperty "pure f <*> pure x ≡ pure (f x)" $ Applicative.homomorphism- (Proxy :: Proxy f)- (series :: Series IO a)- (series :: Series IO (a -> a))- , testProperty "u <*> pure y ≡ pure ($ y) <*> u" $ Applicative.interchange- (series :: Series IO a)- (series :: Series IO (f (a -> a)))- ]
− Test/Tasty/SmallCheck/Laws/Functor.hs
@@ -1,29 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}-module Test.Tasty.SmallCheck.Laws.Functor where--import Data.Proxy (Proxy)-import Data.Functor.Identity (Identity)-import Test.Tasty (TestTree, testGroup)-import Test.Tasty.SmallCheck (testProperty)-import Test.SmallCheck.Series (Serial(series), Series)--import qualified Test.SmallCheck.Laws.Functor as Functor---- | @tasty@ 'TestTree' for 'Functor' laws. You need to provide the type--- wrapped in a `Proxy` and make sure 'a' is an instance of 'Serial'.-testFunctor- :: forall f a .- ( Eq (f a), Eq (f (f a)), Functor f, Show a, Show (f a)- , Serial IO (f a)- , Serial IO (a -> a)- , Serial Identity a, Serial Identity (f a)- )- => Proxy (f a) -> TestTree-testFunctor _ = testGroup "Functor laws"- [ testProperty "fmap id ≡ id" $ Functor.identity (series :: Series IO (f a))- , testProperty "fmap (f . g) ≡ fmap f . fmap g" $ Functor.composition- (series :: Series IO (f a))- (series :: Series IO (a -> a))- (series :: Series IO (a -> a))- ]
− Test/Tasty/SmallCheck/Laws/Monad.hs
@@ -1,36 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}-module Test.Tasty.SmallCheck.Laws.Monad where--#if !MIN_VERSION_base(4,8,0)-import Control.Applicative (Applicative)-#endif-import Data.Functor.Identity (Identity)-import Data.Proxy (Proxy(..))-import Test.SmallCheck.Series (Series, Serial(series))-import Test.Tasty (TestTree, testGroup)-import Test.Tasty.SmallCheck (testProperty)--import Test.Tasty.SmallCheck.Laws.Applicative-import qualified Test.SmallCheck.Laws.Monad as Monad---- | @tasty@ 'TestTree' for 'Monad' laws. You need to provide the type--- wrapped in a `Proxy` and make sure 'a' is an instance of 'Serial'.-testMonad- :: forall f a .- ( Applicative f, Monad f- , Show a, Show (f a), Show (f (a -> a))- , Eq a, Eq (f a), Eq (f (f a))- , Serial IO a, Serial IO (a -> a)- , Serial IO (f a) ,Serial IO (f (a -> a)), Serial IO (a -> f a)- , Serial Identity a, Serial Identity (f a)- )- => Proxy (f a) -> TestTree-testMonad proxy = testGroup "Monad laws"- [ testApplicative proxy- , testProperty "(m >>= f) >>= g ≡ m (f >=> g)"- $ Monad.associativity (series :: Series IO (f a))- (series :: Series IO (a -> f a))- (series :: Series IO (a -> f a))- ]
− Test/Tasty/SmallCheck/Laws/Monoid.hs
@@ -1,26 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}-module Test.Tasty.SmallCheck.Laws.Monoid where--#if !MIN_VERSION_base(4,8,0)-import Data.Monoid (Monoid)-#endif-import Data.Proxy (Proxy)-import Test.SmallCheck.Series (Series, Serial(series))-import Test.Tasty (TestTree, testGroup)-import Test.Tasty.SmallCheck (testProperty)--import qualified Test.SmallCheck.Laws.Monoid as Monoid---- | @tasty@ 'TestTree' for 'Applicative' laws. You need to provide the type--- wrapped in a `Proxy` and make sure 'a' is an instance of 'Serial'.-testMonoid :: forall a . (Show a, Eq a, Monoid a, Serial IO a) => Proxy a -> TestTree-testMonoid _ = testGroup "Monoid laws"- [ testProperty "mempty <> x ≡ x" $ Monoid.leftIdentity (series :: Series IO a)- , testProperty "x <> mempty ≡ x" $ Monoid.rightIdentity (series :: Series IO a)- , testProperty "x <> (y <> z) ≡ (x <> y) <> z"- $ Monoid.associativity (series :: Series IO a) series series- , testProperty "mconcat ≡ foldr mappend mempty"- $ Monoid.mconcat (series :: Series IO a)- ]
smallcheck-laws.cabal view
@@ -1,21 +1,9 @@ name: smallcheck-laws-version: 0.1-synopsis: SmallCheck properties for standard type classes+version: 0.2+synopsis: SmallCheck properties for common laws description:- Automatic `smallcheck` properties and `tasty` runners for:- .- - Monoid laws.- - Functor laws.- - Applicative laws.- - Monad laws.- .- Use the @<https://hackage.haskell.org/package/tasty Tasty>@ modules for- preassembled tasty runners, your data types need to be instances of- @<https://hackage.haskell.org/package/smallcheck-1.1.1/docs/Test-SmallCheck-Series.html#t:Serial Serial>@.- For more granular control on how the- @<https://hackage.haskell.org/package/smallcheck SmallCheck>@- @<https://hackage.haskell.org/package/smallcheck-1.1.1/docs/Test-SmallCheck-Series.html#t:Series Series>@- are created use the modules under @Test.SmallCheck.Laws@.+ 'smallcheck' properties for 'Monoid', 'Functor', 'Applicative' and 'Monad'+ laws. license: BSD3 license-file: LICENSE author: Danny Navarro@@ -23,8 +11,7 @@ category: Testing build-type: Simple cabal-version: >=1.10-extra-source-files: README.md CHANGELOG.md- stack.yaml+extra-source-files: README.md CHANGELOG.md stack.yaml source-repository head type: git@@ -36,32 +23,12 @@ exposed-modules: Test.SmallCheck.Laws.Applicative, Test.SmallCheck.Laws.Functor, Test.SmallCheck.Laws.Monad,- Test.SmallCheck.Laws.Monoid,- Test.Tasty.SmallCheck.Laws.Applicative,- Test.Tasty.SmallCheck.Laws.Functor,- Test.Tasty.SmallCheck.Laws.Monad,- Test.Tasty.SmallCheck.Laws.Monoid+ Test.SmallCheck.Laws.Monoid build-depends: base >=4.6 && <4.9, smallcheck >=1.1.1,- smallcheck-series >=0.3,- tasty >=0.10,- tasty-smallcheck >=0.8+ smallcheck-series >=0.3 if impl(ghc < 7.10) build-depends: transformers >=0.3.0.0-- if impl(ghc < 7.8)- build-depends: tagged >=0.7.2--test-suite tasty- default-language: Haskell2010- type: exitcode-stdio-1.0- hs-source-dirs: tests- main-is: tasty.hs- ghc-options: -Wall -threaded- build-depends: base >=4.6 && <4.9,- smallcheck >=1.1,- tasty >=0.10,- smallcheck-laws if impl(ghc < 7.8) build-depends: tagged >=0.7.2
stack.yaml view
@@ -2,5 +2,5 @@ packages: - '.' extra-deps:-- smallcheck-series-0.3-resolver: lts-2.21+- smallcheck-series-0.5.1+resolver: lts-3.3
− tests/tasty.hs
@@ -1,99 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE FlexibleInstances #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}-module Main where--#if !MIN_VERSION_base(4,8,0)-import Control.Applicative ((<$>))-#endif-import Data.Monoid (Sum(..), Product(..))-import Data.Proxy (Proxy(..))--import Test.SmallCheck.Series (Serial(series))-import Test.Tasty (TestTree, defaultMain, testGroup)--import Test.Tasty.SmallCheck.Laws.Applicative-import Test.Tasty.SmallCheck.Laws.Functor-import Test.Tasty.SmallCheck.Laws.Monad-import Test.Tasty.SmallCheck.Laws.Monoid--main :: IO ()-main = defaultMain $ testGroup "Laws"- [ monoidTests- , functorTests- , applicativeTests- , monadTests- ]--monoidTests :: TestTree-monoidTests = testGroup "Monoid"- [ testGroup "Sum"- [ testGroup "Int"- [ testMonoid (Proxy :: Proxy (Sum Int)) ]- , testGroup "Integer"- [ testMonoid (Proxy :: Proxy (Sum Integer)) ]- , testGroup "Float"- [ testMonoid (Proxy :: Proxy (Sum Float)) ]- ]- , testGroup "Product"- [ testGroup "Int"- [ testMonoid (Proxy :: Proxy (Product Int)) ]- , testGroup "Integer"- [ testMonoid (Proxy :: Proxy (Product Integer)) ]- , testGroup "Float"- [ testMonoid (Proxy :: Proxy (Product Float)) ]- ]- ]--functorTests :: TestTree-functorTests = testGroup "Functor"- [ testGroup "Maybe"- [ testGroup "Int"- [ testFunctor (Proxy :: Proxy (Maybe Int)) ]- , testGroup "Char"- [ testFunctor (Proxy :: Proxy (Maybe Char)) ]- ]- , testGroup "[]"- [ testGroup "Bool"- [ testFunctor (Proxy :: Proxy [Bool]) ]- , testGroup "Int"- [ testFunctor (Proxy :: Proxy [Int]) ]- ]- ]--applicativeTests :: TestTree-applicativeTests = testGroup "Applicative"- [ testGroup "Maybe"- [ testGroup "Int"- [ testApplicative (Proxy :: Proxy (Maybe Int)) ]- , testGroup "Float"- [ testApplicative (Proxy :: Proxy (Maybe Float)) ]- ]- , testGroup "[]"- [ testGroup "Bool"- [ testApplicative (Proxy :: Proxy [Bool]) ]- , testGroup "Char"- [ testApplicative (Proxy :: Proxy [Char]) ]- ]- ]--monadTests :: TestTree-monadTests = testGroup "Monad"- [ testGroup "Maybe"- [ testGroup "()"- [ testMonad (Proxy :: Proxy (Maybe ())) ]- , testGroup "Int"- [ testMonad (Proxy :: Proxy (Maybe Int)) ]- ]- , testGroup "[]"- [ testGroup "()"- [ testMonad (Proxy :: Proxy [()]) ]- ]- ]--instance (Monad m, Serial m a) => Serial m (Sum a) where- series = Sum <$> series--instance (Monad m, Serial m a) => Serial m (Product a) where- series = Product <$> series