hspec-leancheck 0.0.2 → 0.0.3
raw patch · 12 files changed
+156/−89 lines, 12 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Test.Hspec.LeanCheck: data Property
+ Test.Hspec.LeanCheck: prop :: Testable a => String -> a -> Spec
Files
- .gitignore +2/−2
- Makefile +6/−6
- changelog.md +25/−0
- hspec-leancheck.cabal +6/−5
- mk/depend.mk +8/−8
- src/Test/Hspec/LeanCheck.hs +28/−0
- test/sdist +28/−0
- test/should.hs +20/−0
- test/test.hs +33/−0
- tests/should.hs +0/−20
- tests/test-sdist +0/−28
- tests/test.hs +0/−20
.gitignore view
@@ -13,8 +13,8 @@ *.hi *.dyn_hi *.dyn_o-tests/test-tests/should+test/test+test/should doc/*.html doc/*.css doc/*.js
Makefile view
@@ -4,8 +4,8 @@ # License: 3-Clause BSD (see the file LICENSE) # Maintainer: Rudy Matela <rudy@matela.com.br> TESTS = \- tests/should \- tests/test+ test/should \+ test/test EGS = \ eg/minimal \ eg/should@@ -19,9 +19,9 @@ all-all: mk/All.o $(TESTS) $(EGS) -test: $(patsubst %,%.test,$(TESTS))+test: $(patsubst %,%.run,$(TESTS)) test-sdist -%.test: %+%.run: % ./$< eg: $(EGS)@@ -35,7 +35,7 @@ @echo "use \`cabal install' instead" test-sdist:- ./tests/test-sdist+ ./test/sdist test-via-cabal: cabal test@@ -76,7 +76,7 @@ # NOTE: (very hacky!) the following target allows parallel compilation (-jN) of # eg and tests programs so long as they don't share dependencies _not_ stored-# in src/ and tests/. Runnable binaries should depend on mk/toplibs instead of+# in src/ and test/. Runnable binaries should depend on mk/toplibs instead of # actual Haskell source files mk/toplibs: mk/Toplibs.o touch mk/toplibs
+ changelog.md view
@@ -0,0 +1,25 @@+Changelog for hspec-leancheck+=============================+++0.0.3+-----++* export the `prop` function;+* export the `Property` type;+* improvements in Haddock documentation;+* improve tests of `hspec-leancheck` itself;+* add this changelog.+++0.0.2+-----++* `propertyWith` -> `propertyFor`;+* improvements in documentation.+++0.0.1+-----++1st release on Hackage
hspec-leancheck.cabal view
@@ -1,6 +1,6 @@ -- Cabal file for hspec-leancheck name: hspec-leancheck-version: 0.0.2+version: 0.0.3 synopsis: LeanCheck support for the Hspec test framework. description: LeanCheck support for the Hspec test framework.@@ -21,6 +21,7 @@ extra-doc-files: README.md , TODO.md+ , changelog.md extra-source-files: .gitignore , eg/minimal.hs , eg/should.hs@@ -33,7 +34,7 @@ , mk/Toplibs.hs , stack.yaml , stack-lts-11.yaml- , tests/test-sdist+ , test/sdist , .travis.yml tested-with: GHC==8.4 , GHC==8.2@@ -48,7 +49,7 @@ source-repository this type: git location: https://github.com/rudymatela/hspec-leancheck- tag: v0.0.2+ tag: v0.0.3 library exposed-modules: Test.Hspec.LeanCheck@@ -59,13 +60,13 @@ test-suite test type: exitcode-stdio-1.0 main-is: test.hs- hs-source-dirs: tests+ hs-source-dirs: test build-depends: base >= 4 && < 5, hspec, leancheck, hspec-leancheck default-language: Haskell2010 test-suite should type: exitcode-stdio-1.0 main-is: should.hs- hs-source-dirs: tests+ hs-source-dirs: test build-depends: base >= 4 && < 5, hspec, leancheck, hspec-leancheck default-language: Haskell2010
mk/depend.mk view
@@ -25,15 +25,15 @@ mk/toplibs src/Test/Hspec/LeanCheck.o: \ src/Test/Hspec/LeanCheck.hs-tests/should.o: \- tests/should.hs \+test/should.o: \+ test/should.hs \ src/Test/Hspec/LeanCheck.hs-tests/should: \- tests/should.hs \+test/should: \+ test/should.hs \ mk/toplibs-tests/test.o: \- tests/test.hs \+test/test.o: \+ test/test.hs \ src/Test/Hspec/LeanCheck.hs-tests/test: \- tests/test.hs \+test/test: \+ test/test.hs \ mk/toplibs
src/Test/Hspec/LeanCheck.hs view
@@ -48,6 +48,8 @@ module Test.Hspec.LeanCheck ( property , propertyFor+ , prop+ , Property , module Test.LeanCheck ) where@@ -60,10 +62,19 @@ import qualified Test.HUnit.Lang as HUnit import Data.Maybe (fromMaybe) +-- | A LeanCheck property. See 'property', 'propertyFor' and 'prop'. data Property = Ok | Failed String -- | Like 'property' but allows setting the maximum number of tests.+--+-- > spec :: Spec+-- > spec = do+-- > describe "thing" $ do+-- > it "is so and so" $ propertyFor 100 $ \... -> ...+-- > it "is like this" $ propertyFor 200 $ \... -> ...+-- > it "does a thing" $ propertyFor 300 $ \... -> ...+-- > ... propertyFor :: Testable a => Int -> a -> Property propertyFor m p = case counterExample m p of Nothing -> Ok@@ -81,6 +92,23 @@ -- > ... property :: Testable a => a -> Property property = propertyFor 200++-- | Allows a named LeanCheck 'Testable' property to appear in a Spec.+--+-- > prop "does so and so" $ ...+--+-- is a shortcut for+--+-- > it "does so an so" $ property $ ...+--+-- > spec :: Spec+-- > spec = do+-- > describe "thing" $ do+-- > prop "is so and so" $ \x... -> ...+-- > prop "is like this" $ \y... -> ...+-- > ...+prop :: Testable a => String -> a -> Spec+prop s = it s . property instance Example Property where evaluateExample p _ _ _ = return . Result ""
+ test/sdist view
@@ -0,0 +1,28 @@+#!/bin/bash+#+# test/sdist: tests the package generated by "cabal sdist".+#+# Copyright (c) 2015-2018 Rudy Matela.+# Distributed under the 3-Clause BSD licence.+pkgver=` cat *.cabal | grep "^version:" | sed -e "s/version: *//"`+pkgname=`cat *.cabal | grep "^name:" | sed -e "s/name: *//"`+pkg=$pkgname-$pkgver+set -x+cabal sdist &&+cd dist &&+if [ -d ../.git ]+then+ # on git repo, test if files are the same+ git -C .. ls-files | sort > ls-git &&+ tar -tf $pkg.tar.gz | grep -v "/$" | sed -e "s,$pkg/,," | sort > ls-cabal &&+ diff -rud ls-git ls-cabal &&+ rm -f ls-git ls-cabal+else+ # outside of git repo, test build+ rm -rf $pkg/ &&+ tar -xzf $pkg.tar.gz &&+ cd $pkg/ &&+ cabal configure --enable-tests --enable-benchmarks &&+ cabal build &&+ cabal test+fi
+ test/should.hs view
@@ -0,0 +1,20 @@+-- Copyright (c) 2018 Rudy Matela.+-- Distributed under the 3-Clause BSD licence (see the file LICENSE).+{-# LANGUAGE CPP #-}+import Test.Hspec+import Test.Hspec.LeanCheck as LC++import Data.List (sort)++main :: IO ()+main = hspec spec++spec :: Spec+spec = do+ describe "sort" $ do+ it "is idempotent" $+ LC.property $ \xs -> sort (sort xs :: [Int]) `shouldBe` sort xs+ it "preserves length" $+ LC.property $ \xs -> length (sort xs :: [Int]) `shouldBe` length xs+ it "preserves membership" $+ LC.property $ \x xs -> (x `elem` (sort xs :: [Int])) `shouldBe` (x `elem` xs)
+ test/test.hs view
@@ -0,0 +1,33 @@+-- Copyright (c) 2018 Rudy Matela.+-- Distributed under the 3-Clause BSD licence (see the file LICENSE).+{-# LANGUAGE CPP #-}+import Test.Hspec+import Test.Hspec.LeanCheck as LC++import Data.List (sort)++main :: IO ()+main = hspec spec++spec :: Spec+spec = do+ describe "sort" $ do+ it "is idempotent" $+ LC.property $ \xs -> sort (sort xs :: [Int]) == sort xs+ it "preserves length" $+ LC.property $ \xs -> length (sort xs :: [Int]) == length xs+ it "preserves membership" $+ LC.property $ \x xs -> (x `elem` (sort xs :: [Int])) == (x `elem` xs)++ describe "sort (tested by propertyFor)" $ do+ it "is idempotent" $+ LC.propertyFor 2000 $ \xs -> sort (sort xs :: [Int]) == sort xs+ it "preserves length" $+ LC.propertyFor 2000 $ \xs -> length (sort xs :: [Int]) == length xs+ it "preserves membership" $+ LC.propertyFor 2000 $ \x xs -> (x `elem` (sort xs :: [Int])) == (x `elem` xs)++ describe "sort (tested by prop)" $ do+ prop "idempotent" $ \xs -> sort (sort xs :: [Int]) == sort xs+ prop "== length" $ \xs -> length (sort xs :: [Int]) == length xs+ prop "== `elem`" $ \x xs -> (x `elem` (sort xs :: [Int])) == (x `elem` xs)
− tests/should.hs
@@ -1,20 +0,0 @@--- Copyright (c) 2018 Rudy Matela.--- Distributed under the 3-Clause BSD licence (see the file LICENSE).-{-# LANGUAGE CPP #-}-import Test.Hspec-import Test.Hspec.LeanCheck as LC--import Data.List (sort)--main :: IO ()-main = hspec spec--spec :: Spec-spec = do- describe "sort" $ do- it "is idempotent" $- LC.property $ \xs -> sort (sort xs :: [Int]) `shouldBe` sort xs- it "preserves length" $- LC.property $ \xs -> length (sort xs :: [Int]) `shouldBe` length xs- it "preserves membership" $- LC.property $ \x xs -> (x `elem` (sort xs :: [Int])) `shouldBe` (x `elem` xs)
− tests/test-sdist
@@ -1,28 +0,0 @@-#!/bin/bash-#-# test-sdist: tests the package generated by "cabal sdist".-#-# Copyright (c) 2015-2018 Rudy Matela.-# Distributed under the 3-Clause BSD licence.-pkgver=` cat *.cabal | grep "^version:" | sed -e "s/version: *//"`-pkgname=`cat *.cabal | grep "^name:" | sed -e "s/name: *//"`-pkg=$pkgname-$pkgver-set -x-cabal sdist &&-cd dist &&-if [ -d ../.git ]-then- # on git repo, test if files are the same- git -C .. ls-files | sort > ls-git &&- tar -tf $pkg.tar.gz | grep -v "/$" | sed -e "s,$pkg/,," | sort > ls-cabal &&- diff -rud ls-git ls-cabal &&- rm -f ls-git ls-cabal-else- # outside of git repo, test build- rm -rf $pkg/ &&- tar -xzf $pkg.tar.gz &&- cd $pkg/ &&- cabal configure --enable-tests --enable-benchmarks &&- cabal build &&- cabal test-fi
− tests/test.hs
@@ -1,20 +0,0 @@--- Copyright (c) 2018 Rudy Matela.--- Distributed under the 3-Clause BSD licence (see the file LICENSE).-{-# LANGUAGE CPP #-}-import Test.Hspec-import Test.Hspec.LeanCheck as LC--import Data.List (sort)--main :: IO ()-main = hspec spec--spec :: Spec-spec = do- describe "sort" $ do- it "is idempotent" $- LC.property $ \xs -> sort (sort xs :: [Int]) == sort xs- it "preserves length" $- LC.property $ \xs -> length (sort xs :: [Int]) == length xs- it "preserves membership" $- LC.property $ \x xs -> (x `elem` (sort xs :: [Int])) == (x `elem` xs)