tasty-hspec-1.1.2/0000755000000000000000000000000012566436550012161 5ustar0000000000000000tasty-hspec-1.1.2/LICENSE0000644000000000000000000000276612566436550013201 0ustar0000000000000000Copyright (c) 2013, Mitchell Rosen 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 Mitchell Rosen 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. tasty-hspec-1.1.2/Setup.hs0000644000000000000000000000005612566436550013616 0ustar0000000000000000import Distribution.Simple main = defaultMain tasty-hspec-1.1.2/tasty-hspec.cabal0000644000000000000000000000217112566436550015412 0ustar0000000000000000name: tasty-hspec version: 1.1.2 synopsis: Hspec support for the Tasty test framework. description: Hspec support for the Tasty test framework. homepage: https://github.com/mitchellwrosen/tasty-hspec license: BSD3 license-file: LICENSE author: Mitchell Rosen maintainer: mitchellwrosen@gmail.com category: Testing build-type: Simple cabal-version: >=1.10 source-repository head type: git location: https://github.com/mitchellwrosen/tasty-hspec.git library exposed-modules: Test.Tasty.Hspec other-extensions: DeriveDataTypeable build-depends: base ==4.* , hspec >=2 && <2.3 , hspec-core >=2 && <3 , QuickCheck >=2.7 , tagged >=0.7 , tasty >=0.8 , tasty-smallcheck >=0.1 , tasty-quickcheck >=0.3 , random default-language: Haskell2010 ghc-options: -Wall tasty-hspec-1.1.2/Test/0000755000000000000000000000000012566436550013100 5ustar0000000000000000tasty-hspec-1.1.2/Test/Tasty/0000755000000000000000000000000012566436550014204 5ustar0000000000000000tasty-hspec-1.1.2/Test/Tasty/Hspec.hs0000644000000000000000000000777112566436550015616 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} module Test.Tasty.Hspec ( -- * Test testSpec -- * Options -- | === Re-exported from , SmallCheckDepth(..) -- | === Re-exported from , QuickCheckMaxRatio(..) , QuickCheckMaxSize(..) , QuickCheckReplay(..) , QuickCheckTests(..) -- * Hspec re-export , module Test.Hspec ) where import Control.Applicative ((<$>)) import Data.Proxy import Data.Typeable (Typeable) import qualified Test.Hspec as H import qualified Test.Hspec.Core.Spec as H import qualified Test.QuickCheck as QC import qualified Test.Tasty as T import qualified Test.Tasty.SmallCheck as TSC import qualified Test.Tasty.Options as T import qualified Test.Tasty.Providers as T import qualified Test.Tasty.QuickCheck as TQC import qualified Test.Tasty.Runners as T -- For re-export. import Test.Hspec import Test.Tasty.SmallCheck (SmallCheckDepth(..)) import Test.Tasty.QuickCheck (QuickCheckMaxRatio(..), QuickCheckMaxSize(..) , QuickCheckReplay(..), QuickCheckTests(..)) -- | Create a 'T.TestTree' from an -- 'H.Spec'. testSpec :: T.TestName -> H.Spec -> IO T.TestTree testSpec name spec = T.testGroup name . map specTreeToTestTree <$> H.runSpecM spec specTreeToTestTree :: H.SpecTree () -> T.TestTree specTreeToTestTree (H.Node name spec_trees) = T.testGroup name (map specTreeToTestTree spec_trees) specTreeToTestTree (H.NodeWithCleanup cleanup spec_trees) = let test_tree = specTreeToTestTree (H.Node "(unnamed)" spec_trees) in T.WithResource (T.ResourceSpec (return ()) cleanup) (const test_tree) specTreeToTestTree (H.Leaf item) = T.singleTest (H.itemRequirement item) (Item item) hspecResultToTastyResult :: H.Result -> T.Result hspecResultToTastyResult H.Success = T.testPassed "" hspecResultToTastyResult (H.Pending mstr) = T.testFailed ("test pending" ++ maybe "" (": " ++) mstr) #if MIN_VERSION_hspec(2,2,0) hspecResultToTastyResult (H.Fail _ str) = T.testFailed str #else hspecResultToTastyResult (H.Fail str) = T.testFailed str #endif newtype Item = Item (H.Item ()) deriving Typeable instance T.IsTest Item where run opts (Item (H.Item _ _ _ ex)) progress = hspecResultToTastyResult <$> ex params ($ ()) hprogress where params :: H.Params params = H.Params { H.paramsQuickCheckArgs = qc_args , H.paramsSmallCheckDepth = sc_depth } where qc_args :: QC.Args qc_args = let TQC.QuickCheckTests num_tests = T.lookupOption opts TQC.QuickCheckReplay replay = T.lookupOption opts TQC.QuickCheckMaxSize max_size = T.lookupOption opts TQC.QuickCheckMaxRatio max_ratio = T.lookupOption opts in QC.stdArgs { QC.chatty = False , QC.maxDiscardRatio = max_ratio , QC.maxSize = max_size , QC.maxSuccess = num_tests , QC.replay = replay } sc_depth :: Int sc_depth = let TSC.SmallCheckDepth depth = T.lookupOption opts in depth hprogress :: H.Progress -> IO () hprogress (x,y) = progress $ T.Progress { T.progressText = "" , T.progressPercent = fromIntegral x / fromIntegral y } testOptions = return [ T.Option (Proxy :: Proxy TQC.QuickCheckTests) , T.Option (Proxy :: Proxy TQC.QuickCheckReplay) , T.Option (Proxy :: Proxy TQC.QuickCheckMaxSize) , T.Option (Proxy :: Proxy TQC.QuickCheckMaxRatio) , T.Option (Proxy :: Proxy TSC.SmallCheckDepth) ]