speculate 0.3.1 → 0.3.2
raw patch · 6 files changed
+12/−50 lines, 6 filesdep ~leancheckPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: leancheck
API changes (from Hackage documentation)
- Test.Speculate.Utils: discardLaterT :: (a -> a -> Bool) -> [[a]] -> [[a]]
- Test.Speculate.Utils: discardT :: (a -> Bool) -> [[a]] -> [[a]]
- Test.Speculate.Utils: partitionT :: (a -> Bool) -> [[a]] -> ([[a]], [[a]])
+ Test.Speculate.Utils: countsOn :: Eq b => (a -> b) -> [a] -> [(b, Int)]
- Test.Speculate.Utils: countsBy :: Eq b => (a -> b) -> [a] -> [(b, Int)]
+ Test.Speculate.Utils: countsBy :: (a -> a -> Bool) -> [a] -> [(a, Int)]
Files
- speculate.cabal +4/−4
- src/Test/Speculate/CondReason.hs +2/−0
- src/Test/Speculate/Utils/List.hs +2/−8
- src/Test/Speculate/Utils/Misc.hs +3/−23
- src/Test/Speculate/Utils/Tiers.hs +1/−12
- tests/test-utils.hs +0/−3
speculate.cabal view
@@ -1,5 +1,5 @@ name: speculate-version: 0.3.1+version: 0.3.2 synopsis: discovery of properties about Haskell functions description: Speculate automatically discovers laws about Haskell functions.@@ -22,7 +22,7 @@ extra-doc-files: README.md , TODO.md-tested-with: GHC==8.0, GHC==7.10, GHC==7.8, GHC==7.6, GHC==7.4+tested-with: GHC==8.2, GHC==8.0, GHC==7.10, GHC==7.8, GHC==7.6, GHC==7.4 source-repository head type: git@@ -31,7 +31,7 @@ source-repository this type: git location: https://github.com/rudymatela/speculate- tag: v0.3.1+ tag: v0.3.2 library@@ -67,7 +67,7 @@ , Test.Speculate.Utils.Timeout , Test.Speculate.Utils.Tuple , Test.Speculate.Utils.Typeable- build-depends: base >= 4 && < 5, leancheck >= 0.6.3, cmdargs, containers+ build-depends: base >= 4 && < 5, leancheck >= 0.7, cmdargs, containers hs-source-dirs: src default-language: Haskell2010
src/Test/Speculate/CondReason.hs view
@@ -76,6 +76,8 @@ (e':_) -> n $ normalize thy e' -- TODO: fix silly code structure in cnormalize! +-- Checks if two expressions are equivalent under a condition+-- using the conditional theory. cequivalent :: Chy -> Expr -> Expr -> Expr -> Bool cequivalent chy ce e1 e2 = equivalent (unThy chy) (cnormalize chy ce e1) (cnormalize chy ce e2)
src/Test/Speculate/Utils/List.hs view
@@ -10,7 +10,7 @@ -- Utilities for manipulating lists. module Test.Speculate.Utils.List ( pairsThat- , count, counts, countsBy+ , count, counts, countsOn, countsBy , firsts , nubSort, nubSortBy , (+++), nubMerge, nubMergeBy, nubMergeOn, nubMerges, nubMergesBy, nubMergeMap@@ -37,19 +37,13 @@ import Data.List import Data.Function (on)+import Test.LeanCheck.Stats pairsThat :: (a -> a -> Bool) -> [a] -> [(a,a)] pairsThat p xs = [(x,y) | x <- xs, y <- xs, p x y] count :: Eq a => a -> [a] -> Int count x = length . filter (==x)--counts :: Eq a => [a] -> [(a,Int)]-counts [] = []-counts (x:xs) = (x,1+count x xs) : counts (filter (/= x) xs)--countsBy :: Eq b => (a -> b) -> [a] -> [(b,Int)]-countsBy f = counts . map f firsts :: Eq a => [a] -> [a] firsts [] = []
src/Test/Speculate/Utils/Misc.hs view
@@ -18,6 +18,7 @@ import Data.Tuple import Test.Speculate.Utils.String import Test.Speculate.Utils.List+import Test.LeanCheck.Stats -- easy debug: undefined1 :: a@@ -43,31 +44,10 @@ thn o _ = o infixr 8 `thn` --- TODO: Add a function like this on LeanCheck? Not working exactly like--- this, but something like:------ > > classifyBy somefoo--- > Int: 9988 99%--- > Bool: 10 0%--- > Char: 2 0%--- > total: 10000 100%------ > > preconditionInfo [precond_1, precond_2, precond_3]--- > precond_1: 3 0%--- > precond_2: 100 1%--- > precond_3: 2345 23%------ > > preconditionInfoT [...]--- > tier cond1 cond2 cond3--- > 0 9 100 1% 303 2% 3821 4%--- > 1 56 100 1% 303 2% 3821 4%--- > 2 102 100 1% 303 2% 3821 4%--- > 3 400 100 1% 303 2% 3821 4%--- > 4 713 100 1% 303 2% 3821 4%--- > all 1232 100 1% 303 2% 3821 4%+-- TODO: Remove this function in favour of LeanCheck's classStats reportCountsBy :: (Eq b, Show b) => (a -> b) -> [a] -> IO () reportCountsBy f xs = putStrLn . unlines- . map showCount $ countsBy f xs+ . map showCount $ countsOn f xs where len = length xs showCount (x,n) = unquote (show x) ++ ": "
src/Test/Speculate/Utils/Tiers.hs view
@@ -10,9 +10,6 @@ module Test.Speculate.Utils.Tiers ( productsList , mapTMaybe- , discardT- , discardLaterT- , partitionT , uptoT , filterTS , discardTS@@ -20,6 +17,7 @@ where import Test.LeanCheck+import Test.LeanCheck.Tiers import Data.Maybe (mapMaybe) productsList :: [[a]] -> [[a]]@@ -28,9 +26,6 @@ mapTMaybe :: (a -> Maybe b) -> [[a]] -> [[b]] mapTMaybe f = map (mapMaybe f) -discardT :: (a -> Bool) -> [[a]] -> [[a]]-discardT p = filterT (not . p)- partitionT :: (a -> Bool) -> [[a]] -> ([[a]],[[a]]) partitionT p xss = (filterT p xss, discardT p xss) @@ -46,9 +41,3 @@ discardTS :: (Int -> a -> Bool) -> [[a]] -> [[a]] discardTS p = filterTS ((not .) . p)--discardLaterT :: (a -> a -> Bool) -> [[a]] -> [[a]]-discardLaterT d [] = []-discardLaterT d ([]:xss) = [] : discardLaterT d xss-discardLaterT d ((x:xs):xss) = [[x]]- \/ discardLaterT d (discardT (`d` x) (xs:xss))
tests/test-utils.hs view
@@ -26,9 +26,6 @@ ==> strictlyOrdered (nubMerge xs (ys::[Int])) , and [ nubMerge xs xs == xs | n <- [0..10], let xs = [0..n] ] - , holds 100 $ \xss -> ordered . concat $ discardLaterT (<=) (xss::[[Int]])- , (length . concat $ discardLaterT (<=) [[1..100]]) == 100- , collectOn snd [(1,2),(2,2),(2,3),(3,3)] == [[(1,2),(2,2)],[(2,3),(3,3)]] , collectOn fst [(1,2),(2,2),(2,3),(3,3)] == [[(1,2)],[(2,2),(2,3)],[(3,3)]] , collectOn (uncurry (+)) [(1,2),(2,2),(2,3),(3,3)] == [[(1,2)],[(2,2)],[(2,3)],[(3,3)]]