packages feed

coverage 0.1.0.3 → 0.1.0.4

raw patch · 9 files changed

+23/−17 lines, 9 filesdep ~HUnitdep ~hspec

Dependency ranges changed: HUnit, hspec

Files

README.md view
@@ -1,4 +1,4 @@-## Coverage+## coverage  ### An exhaustivity checking library @@ -14,6 +14,10 @@  #### Tests -For running tests (in the `tests` directory):+For running tests just execute:++    cabal test++or, if you have `hspec-discover` (inside the `tests` directory run):      runhaskell Spec.hs
coverage.cabal view
@@ -1,5 +1,5 @@ name:                coverage-version:             0.1.0.3+version:             0.1.0.4 synopsis:            Exhaustivity Checking Library homepage:            https://github.com/nicodelpiano/coverage bug-reports:         https://github.com/nicodelpiano/coverage/issues@@ -32,13 +32,13 @@   hs-source-dirs:      src   default-language:    Haskell2010 -test-suite hspec+test-suite tests   type:       exitcode-stdio-1.0   ghc-options:       -Wall   hs-source-dirs:-      tests+      tests, .   main-is:       Spec.hs   other-modules:@@ -46,5 +46,5 @@       CoverageSupport       CoverageUnitSpec   build-depends:-      base >=4.7 && <4.8, coverage, QuickCheck >=2.7, HUnit -any, hspec -any+      base >=4.7 && <4.8, coverage, QuickCheck >=2.7, hspec   == 2.*, HUnit >= 1.3    default-language:    Haskell2010
examples/Nat.hs view
@@ -15,7 +15,7 @@  module Nat where -import Coverage+import Control.Coverage  import Control.Arrow (first, second) 
examples/Tree.hs view
@@ -15,7 +15,7 @@  module Tree where -import Coverage+import Control.Coverage  import Control.Arrow (first, second) 
src/Control/Coverage.hs view
@@ -35,8 +35,7 @@ check :: (Eq lit) => Environment -> [Alternative lit] -> Check lit check env cas = applyRedundant (fmap nub) . applyUncovered nub . foldl' step initial $ cas   where-  initial = makeCheck [uncovers] $ Redundant []-    where uncovers = if null cas then initialize $ length . fst . head $ cas else []+  initial = makeCheck [initialize $ length . fst . head $ cas] $ Redundant []    step :: (Eq lit) => Check lit -> Alternative lit -> Check lit   step ch ca =
src/Control/Coverage/Internal.hs view
@@ -57,8 +57,7 @@ -- Guard are abstract, and it is up to the language implementor to interpret -- guards abstractly. Guards can catch all cases, or represent some opaque -- expression which cannot be analysed.-data Guard = CatchAll-           | Opaque+data Guard = CatchAll | Opaque   deriving (Show, Eq)  -- | A case alternative consists of a collection of binders which match
tests/CoverageSpec.hs view
@@ -20,12 +20,14 @@ import CoverageSupport  import Test.Hspec+import Test.HUnit import Test.QuickCheck +import Control.Exception (evaluate)+ spec :: Spec spec = do   describe "Test suite" $ do-     describe "missingSingle" $ do       it "between any binder and `Var _` should be `[]`" $         property $ \b n -> fst (missingSingle defaultEnv (b :: Binder String) (Var n)) == []
tests/CoverageSupport.hs view
@@ -33,7 +33,7 @@ -- genRec :: (Eq a, Arbitrary a) => Int -> Gen [(Name, Binder a)] genRec 0 = return []-genRec n = liftM3 (\k b -> (:) (k, b)) arbitrary arbitrary (genRec (n-1))+genRec n = liftM3 (\n b -> (:) (n, b)) arbitrary arbitrary (genRec (n-1))  -- | -- Specific generators for each type of binder.
tests/CoverageUnitSpec.hs view
@@ -17,8 +17,11 @@  import Control.Coverage import Control.Coverage.Internal+import CoverageSupport  import Test.Hspec+import Test.HUnit+import Test.QuickCheck  import Control.Exception (evaluate) @@ -56,7 +59,6 @@ tagged_def6 :: [Alternative ()] tagged_def6 = [([wildcard, wildcard, wildcard], Nothing), ([z, z, z], Nothing)] -fromRedundant :: Redundant [a] -> [a] fromRedundant (Redundant bs) = bs fromRedundant _ = [] @@ -117,10 +119,10 @@      describe "Product" $ do       it "product_def1 is exhaustive" $ do-        (getUncovered $ check env product_def1) `shouldBe` []+        (getUncovered $ check env record_def1) `shouldBe` []        it "product_def2 is not exhaustive" $ do-        (getUncovered $ check env product_def2) `shouldBe` [[Product [Tagged "Succ" (Var Nothing),Var Nothing]],[Product [Var Nothing,Tagged "Succ" (Var Nothing)]]] +        (getUncovered $ check env record_def2) `shouldBe` [[Record [("bar", s wildcard), ("foo", s wildcard)]], [Record [("bar", wildcard), ("foo", s $ s wildcard)]]]  main :: IO () main = hspec spec