fitspec 0.4.1 → 0.4.2
raw patch · 6 files changed
+25/−98 lines, 6 files
Files
- README.md +9/−7
- bench/sets.hs +5/−5
- bench/setsofsets.hs +7/−7
- fitspec.cabal +3/−3
- tests/test-derive.hs +1/−1
- tests/test-mutate.hs +0/−75
README.md view
@@ -5,9 +5,9 @@ [![FitSpec on Hackage][hackage-version]][fitspec-on-hackage] FitSpec provides automated assistance in the task of refining test properties-for Haskell functions. FitSpec tests mutant variations of functions under test-against a given property set, recording any surviving mutants that pass all-tests. FitSpec then reports:+for [Haskell] functions. FitSpec tests mutant variations of functions under+test against a given property set, recording any surviving mutants that pass+all tests. FitSpec then reports: * *surviving mutants:* indicating incompleteness of properties,@@ -19,7 +19,7 @@ Installing FitSpec ------------------ -To install the latest FitSpec version from Hackage, just:+To install the [latest FitSpec version from Hackage], just: $ cabal install fitspec @@ -150,10 +150,12 @@ [cmdargs]: https://hackage.haskell.org/package/cmdargs [pretty]: https://hackage.haskell.org/package/pretty -[TH]: https://wiki.haskell.org/Template_Haskell-[Cabal]: https://www.haskell.org/cabal+[TH]: https://wiki.haskell.org/Template_Haskell+[Cabal]: https://www.haskell.org/cabal+[Haskell]: https://www.haskell.org/ [build-status]: https://travis-ci.org/rudymatela/fitspec.svg?branch=master [build-log]: https://travis-ci.org/rudymatela/fitspec [hackage-version]: https://img.shields.io/hackage/v/fitspec.svg-[fitspec-on-hackage]: https://hackage.haskell.org/package/fitspec+[fitspec-on-hackage]: https://hackage.haskell.org/package/fitspec+[latest FitSpec version from Hackage]: https://hackage.haskell.org/package/fitspec
bench/sets.hs view
@@ -1,14 +1,14 @@-import Set-import Test.FitSpec hiding ((\/))+import Set as S+import Test.FitSpec hiding ((\/),Set) -instance (Ord a, Listable a) => Listable (Set a) where+instance (Ord a, Listable a) => Listable (S.Set a) where tiers = setCons set -instance (Ord a, Listable a) => Mutable (Set a) where+instance (Ord a, Listable a) => Mutable (S.Set a) where mutiers = mutiersEq -instance (Ord a, Show a, Listable a) => ShowMutable (Set a) where+instance (Ord a, Show a, Listable a) => ShowMutable (S.Set a) where mutantS = mutantSEq
bench/setsofsets.hs view
@@ -1,14 +1,14 @@-import Set-import Test.FitSpec hiding ((\/))+import Set as S+import Test.FitSpec hiding ((\/),Set) -instance (Ord a, Listable a) => Listable (Set a) where+instance (Ord a, Listable a) => Listable (S.Set a) where tiers = setCons set -instance (Ord a, Listable a) => Mutable (Set a) where+instance (Ord a, Listable a) => Mutable (S.Set a) where mutiers = mutiersEq -instance (Ord a, Show a, Listable a) => ShowMutable (Set a) where+instance (Ord a, Show a, Listable a) => ShowMutable (S.Set a) where mutantS = mutantSEq -- The Mutable and ShowMutable instances could be alternatively derived by:@@ -16,8 +16,8 @@ -- Type of functions under test-type PowerS a = Set a -> Set (Set a)-type PartitionsS a = Set a -> Set (Set (Set a))+type PowerS a = S.Set a -> S.Set (S.Set a)+type PartitionsS a = S.Set a -> S.Set (S.Set (S.Set a)) type Ty a = (PowerS a, PartitionsS a)
fitspec.cabal view
@@ -1,5 +1,5 @@ name: fitspec-version: 0.4.1+version: 0.4.2 synopsis: refining property sets for testing Haskell programs description: FitSpec provides automated assistance in the task of refining test properties@@ -22,7 +22,7 @@ maintainer: Rudy Matela <rudy@matela.com.br> category: Testing build-type: Simple-cabal-version: >=1.10+cabal-version: >=1.18 extra-doc-files: README.md , CREDITS.md@@ -38,7 +38,7 @@ source-repository this type: git location: https://github.com/rudymatela/fitspec- tag: v0.4.1+ tag: v0.4.2 library
tests/test-derive.hs view
@@ -4,7 +4,7 @@ import System.Exit (exitFailure) import Data.List (elemIndices,sort) -import Test.FitSpec+import Test.FitSpec hiding (Set) data D0 = D0 deriving (Show,Eq,Ord) data D1 a = D1 a deriving (Show,Eq,Ord)
tests/test-mutate.hs view
@@ -7,7 +7,6 @@ import Test.FitSpec import Test.FitSpec.Utils (contained) import Test.LeanCheck.Error (errorToNothing, errorToFalse)-import Test.LeanCheck.Function.ListsOfPairs (functionPairs, defaultFunPairsToFunction) import Data.Monoid ((<>)) import Data.Word (Word) -- for GHC <= 7.10@@ -25,47 +24,12 @@ tests = map errorToFalse [ True - , mutiersEqOld (sort :: [Int] -> [Int]) 5- , mutiersEqOld (sort :: [Bool] -> [Bool]) 3 -- was 5- , mutiersEqOld (sort :: [Char] -> [Char]) 5- , mutiersEqOld (sort :: [()] -> [()]) 10-- , mutiersEqOld (head :: [Int] -> Int) 6- , mutiersEqOld (head :: [Bool] -> Bool) 6- , mutiersEqOld (tail :: [Int] -> [Int]) 6- , mutiersEqOld (tail :: [Bool] -> [Bool]) 4 -- was 6-- , mutiersEqOld (uncurry (++) :: ([Int],[Int]) -> [Int]) 4- , mutiersEqOld (uncurry (++) :: ([Bool],[Bool]) -> [Bool]) 4- , mutiersEqOld (uncurry (++) :: ([Char],[Char]) -> [Char]) 4-- , mutiersEqOld not 10 - , mutiersEqOld (uncurry (&&)) 10- , mutiersEqOld (uncurry (||)) 10-- , mutiersEqOld (uncurry (+) :: (Int,Int) -> Int) 6- , mutiersEqOld (uncurry (+) :: (Nat,Nat) -> Nat) 6- , mutiersEqOld (uncurry (*) :: (Int,Int) -> Int) 6- , mutiersEqOld (uncurry (*) :: (Nat,Nat) -> Nat) 6-- -- These actually do not hold for later values in the enumeration- -- The actual way in which values are enumerated makes the enumerations- -- inherently different.- , mutiers2EqOld ((++) :: [Int] -> [Int] -> [Int]) 4- , mutiers2EqOld ((++) :: [Bool] -> [Bool] -> [Bool]) 3- , mutiers2EqOld ((++) :: [Char] -> [Char] -> [Char]) 4-- , allUnique $ concat $ showOldMutants1 (sort :: [Int] -> [Int]) 7 , allUnique $ concat $ showNewMutants1 (sort :: [Int] -> [Int]) 7- , allUnique $ concat $ showOldMutants2 ((++) :: [Int] -> [Int] -> [Int]) 7 , allUnique $ concat $ showNewMutants2 ((++) :: [Int] -> [Int] -> [Int]) 7 - , allUnique $ concat $ showOldMutants1 (swap :: (Int,Int) -> (Int,Int)) 7 , allUnique $ concat $ showNewMutants1 (swap :: (Int,Int) -> (Int,Int)) 7- , allUnique $ concat $ showOldMutants1 (swap :: (Bool,Bool) -> (Bool,Bool)) 7 , allUnique $ concat $ showNewMutants1 (swap :: (Bool,Bool) -> (Bool,Bool)) 7 - , allUnique $ concat $ showOldMutants2 ((,) :: Int -> Bool -> (Int,Bool)) 7 , allUnique $ concat $ showNewMutants2 ((,) :: Int -> Bool -> (Int,Bool)) 7 , allUnique $ concat $ showNewMutants2 ((,) :: Bool -> Int -> (Bool,Int)) 7 @@ -127,47 +91,13 @@ bindingsOfLength :: Int -> [([String],String)] -> Bool bindingsOfLength n = all ((== n) . length . fst) --- NOTE:--- mutiersEqOld only *actually* hold for functions returning--- lists when using mutiersEq as the implementation of mutiers for [a]-mutiersEqOld :: ( Show a, Show b- , Eq a, Eq b- , Listable a, Listable b- , Mutable b, ShowMutable b )- => (a -> b) -> Int -> Bool-mutiersEqOld f n = showOldMutants1 f n == showNewMutants1 f n --mutiers2EqOld :: ( Eq a, Eq b, Eq c- , Show a, Show b, Show c- , Listable a, Listable b, Listable c- , Mutable c, ShowMutable b, ShowMutable c )- => (a -> b -> c) -> Int -> Bool-mutiers2EqOld f n = showOldMutants2 f n == showNewMutants2 f n---showOldMutants1 :: ( Eq a, Eq b- , Show a, Show b- , Listable a, Listable b- , ShowMutable b )- => (a -> b) -> Int -> [[String]]-showOldMutants1 f n = mapT (showMutantAsTuple [] f)- $ take n- $ mutiersOld f- showNewMutants1 :: (ShowMutable a, Mutable a) => a -> Int -> [[String]] showNewMutants1 f n = mapT (showMutantAsTuple [] f) $ take n $ mutiers f -showOldMutants2 :: ( Eq a, Eq b, Eq c- , Show a, Show b, Show c- , Listable a, Listable b, Listable c- , ShowMutable c )- => (a -> b -> c) -> Int -> [[String]]-showOldMutants2 f = showOldMutants1 (uncurry f)- showNewMutants2 :: ( Eq a, Eq b, Eq c , Show a, Show b, Show c , Listable a, Listable b, Mutable c@@ -177,11 +107,6 @@ $ take n $ mutiers f where uf = uncurry f--mutiersOld :: (Eq a, Eq b, Listable a, Listable b)- => (a -> b) -> [[a -> b]]-mutiersOld f = mapT (defaultFunPairsToFunction f)- $ functionPairs tiers tiers `suchThat` canonicalMutation f canonicalMutation :: Eq b => (a -> b) -> [(a, b)] -> Bool -- This simple version on the line below