cabal-test-compat 0.1.0.0 → 0.2.0.0
raw patch · 2 files changed
+35/−24 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Distribution.TestSuite.Compat: prop' :: Testable prop => String -> Maybe String -> prop -> Test
- Distribution.TestSuite.Compat: prop :: Testable prop => prop -> String -> Test
+ Distribution.TestSuite.Compat: prop :: Testable prop => String -> prop -> Test
Files
cabal-test-compat.cabal view
@@ -1,12 +1,12 @@ name: cabal-test-compat-version: 0.1.0.0+version: 0.2.0.0 synopsis: Compatibility interface of cabal test-suite. description: This package provides compatibility interface module of cabal test-suite. homepage: http://twitter.com/khibino/ license: BSD3 license-file: LICENSE-author: Kei HIBINO+author: Kei Hibino maintainer: ex8k.hibino@gmail.com copyright: Copyright (c) 2015 Kei Hibino category: Testing
src/Distribution/TestSuite/Compat.hs view
@@ -11,7 +11,7 @@ -- -- This module provides subset of compatibility interface names -- for Cabal older than 1.16.-module Distribution.TestSuite.Compat (prop, TestList, testList) where+module Distribution.TestSuite.Compat (prop', prop, TestList, testList) where import Test.QuickCheck (Testable, quickCheckResult, Result (Success)) @@ -24,21 +24,25 @@ (Test (Test), TestInstance (TestInstance), Result (Pass, Fail, Error), Progress (Finished)) -simpleInstance :: IO Progress -> String -> Test-simpleInstance p name = Test this where+simpleInstance :: String -> IO Progress -> Test+simpleInstance name p = Test this where this = TestInstance p name [] [] (\_ _ -> Right this) -suite :: IO (Either String ()) -> String -> Test-suite t = simpleInstance $ do+suite :: String -> Maybe String -> IO (Either String ()) -> Test+suite n mayEmsg t = simpleInstance n $ do er <- try t return . Finished $ case er of Right (Right ()) -> Pass- Right (Left m) -> Fail m- Left e -> Error $ show (e :: IOError)+ Right (Left m) -> Fail $ m `mayAppend` mayEmsg+ Left e -> Error $ show (e :: IOError) `mayAppend` mayEmsg +-- | Interface to make 'Test' with an error case message to append.+prop' :: Testable prop => String -> Maybe String -> prop -> Test+prop' n mayEmsg t = suite n mayEmsg $ qcEither <$> quickCheckResult t+ -- | Interface to make 'Test'.-prop :: Testable prop => prop -> String -> Test-prop t = suite $ qcEither <$> quickCheckResult t+prop :: Testable prop => String -> prop -> Test+prop n = prop' n Nothing -- | Interface type of 'Test' list to export. type TestList = IO [Test]@@ -55,21 +59,21 @@ import qualified Distribution.TestSuite as TestSuite -test114 :: IO (Either String ()) -> IO TestSuite.Result-test114 t = do+test114 :: Maybe String -> IO (Either String ()) -> IO TestSuite.Result+test114 mayEmsg t = do er <- try t return $ case er of Right (Right ()) -> Pass- Right (Left m) -> Fail m- Left e -> Error $ show (e :: IOError)+ Right (Left m) -> Fail $ m `mayAppend` mayEmsg+ Left e -> Error $ show (e :: IOError) `mayAppend` mayEmsg -prop114 :: Testable prop => prop -> IO TestSuite.Result-prop114 t = test114 $ qcEither <$> quickCheckResult t+prop114 :: Testable prop => Maybe String -> prop -> IO TestSuite.Result+prop114 mayEmsg t = test114 mayEmsg $ qcEither <$> quickCheckResult t -data Suite114 t = Suite114 String t+data Suite114 t = Suite114 String (Maybe String) t instance TestOptions (Suite114 prop) where- name (Suite114 n _) = n+ name (Suite114 n _ _) = n options = const [] defaultOptions = const . return $ Options [] check _ _ = []@@ -78,15 +82,19 @@ -- runM (Suite114 _ t) _ = test114 t instance Testable prop => ImpureTestable (Suite114 prop) where- runM (Suite114 _ t) _ = prop114 t+ runM (Suite114 _ me t) _ = prop114 me t -- -- | Interface to make 'Test'.--- suite :: IO (Either String ()) -> String -> Test--- suite t n = impure $ Suite114 n t+-- suite :: String -> IO (Either String ()) -> Test+-- suite n t = impure $ Suite114 n t +-- | Interface to make 'Test' with an error case message to append.+prop' :: Testable prop => String -> Maybe String -> prop -> Test+prop' n me t = impure $ Suite114 n me t+ -- | Interface to make 'Test'.-prop :: Testable prop => prop -> String -> Test-prop t n = impure $ Suite114 n t+prop :: Testable prop => String -> prop -> Test+prop n = prop' n Nothing -- | Interface type of 'Test' list to export.@@ -102,3 +110,6 @@ qcEither = d where d (Success {}) = Right () d x = Left $ show x++mayAppend :: String -> Maybe String -> String+mayAppend x mayEmsg = maybe x (\m -> x ++ ": " ++ m) mayEmsg