packages feed

cabal-test-compat (empty) → 0.1.0.0

raw patch · 4 files changed

+167/−0 lines, 4 filesdep +Cabaldep +QuickCheckdep +basesetup-changed

Dependencies added: Cabal, QuickCheck, base

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Kei HIBINO++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Kei HIBINO nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ cabal-test-compat.cabal view
@@ -0,0 +1,31 @@+name:                cabal-test-compat+version:             0.1.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+maintainer:          ex8k.hibino@gmail.com+copyright:           Copyright (c) 2015 Kei Hibino+category:            Testing+build-type:          Simple+cabal-version:       >=1.10++library+  exposed-modules:     Distribution.TestSuite.Compat+  other-extensions:    CPP+  build-depends:         base <5+                       , Cabal+                       , QuickCheck >=2+  hs-source-dirs:      src+  default-language:    Haskell2010++source-repository head+  type:       git+  location:   https://github.com/khibino/haskell-cabal-test-compat++source-repository head+  type:       mercurial+  location:   https://bitbucket.org/khibino/haskell-cabal-test-compat
+ src/Distribution/TestSuite/Compat.hs view
@@ -0,0 +1,104 @@+{-# LANGUAGE CPP #-}++-- |+-- Module      : Distribution.TestSuite.Compat+-- Copyright   : 2014 Kei Hibino+-- License     : BSD3+--+-- Maintainer  : ex8k.hibino@gmail.com+-- Stability   : experimental+-- Portability : unknown+--+-- This module provides subset of compatibility interface names+-- for Cabal older than 1.16.+module Distribution.TestSuite.Compat (prop, TestList, testList) where++import Test.QuickCheck (Testable, quickCheckResult, Result (Success))++import Control.Exception (try)+import Control.Applicative ((<$>))++#if MIN_VERSION_Cabal(1,16,0)++import Distribution.TestSuite+  (Test (Test), TestInstance (TestInstance), Result (Pass, Fail, Error), Progress (Finished))+++simpleInstance :: IO Progress -> String -> Test+simpleInstance p name = Test this  where+  this = TestInstance p name [] [] (\_ _ -> Right this)++suite :: IO (Either String ()) -> String -> Test+suite t = simpleInstance $ do+  er <- try t+  return . Finished $ case er of+    Right (Right ()) -> Pass+    Right (Left m)   -> Fail m+    Left e           -> Error $ show (e :: IOError)++-- | Interface to make 'Test'.+prop :: Testable prop => prop -> String -> Test+prop t = suite $ qcEither <$> quickCheckResult t++-- | Interface type of 'Test' list to export.+type TestList = IO [Test]++-- | Convert interface into 'Test' list to export.+testList :: [Test] -> TestList+testList =  return++#else++import Distribution.TestSuite+  (TestOptions (..), Options (..), ImpureTestable (..), impure,+   Test, Result (Pass, Fail, Error))+import qualified Distribution.TestSuite as TestSuite+++test114 :: IO (Either String ()) -> IO TestSuite.Result+test114 t = do+  er <- try t+  return $ case er of+    Right (Right ()) -> Pass+    Right (Left m)   -> Fail m+    Left e           -> Error $ show (e :: IOError)++prop114 :: Testable prop => prop -> IO TestSuite.Result+prop114 t = test114 $ qcEither <$> quickCheckResult t++data Suite114 t = Suite114 String t++instance TestOptions (Suite114 prop) where+  name (Suite114 n _) = n+  options = const []+  defaultOptions = const . return $ Options []+  check _ _ = []++-- instance ImpureTestable (Suite114 (IO (Either String ()))) where+--   runM (Suite114 _ t) _ = test114 t++instance Testable prop => ImpureTestable (Suite114 prop) where+  runM (Suite114 _ t) _ = prop114 t++-- -- | Interface to make 'Test'.+-- suite :: IO (Either String ()) -> String -> Test+-- suite t n = impure $ Suite114 n t++-- | Interface to make 'Test'.+prop :: Testable prop => prop -> String -> Test+prop t n = impure $ Suite114 n t+++-- | Interface type of 'Test' list to export.+type TestList = [Test]++-- | Convert interface into 'Test' list to export.+testList :: [Test] -> TestList+testList =  id++#endif++qcEither :: Test.QuickCheck.Result -> Either String ()+qcEither =  d  where+  d (Success {}) = Right ()+  d x            = Left $ show x