packages feed

sandwich-quickcheck 0.1.0.4 → 0.1.0.5

raw patch · 3 files changed

+17/−55 lines, 3 filesdep +brickdep +textPVP ok

version bump matches the API change (PVP)

Dependencies added: brick, text

API changes (from Hackage documentation)

Files

− app/Main.hs
@@ -1,22 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}--module Main where--import Data.Time.Clock-import Test.Sandwich-import Test.Sandwich.QuickCheck--quickcheckDemo :: TopSpec-quickcheckDemo = introduceQuickCheck $ do-  prop "List reversal" $ \(xs :: [Int]) -> reverse (reverse xs) == xs--  prop "Failing list reversal" $ \(xs :: [Int]) -> (reverse xs) == xs---testOptions = defaultOptions {-  optionsTestArtifactsDirectory = TestArtifactsGeneratedDirectory "test_runs" (show <$> getCurrentTime)-  }--main :: IO ()-main = runSandwichWithCommandLineArgs testOptions quickcheckDemo
sandwich-quickcheck.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 572a016d330aa814e9cf2e6518553d3299e91380d98c4d1b0a6036abec5e2eb0+-- hash: 67356bf7a3c5379b23a3aa5424a5642190d8cb9ea816333b653d3e43f689a83f  name:           sandwich-quickcheck-version:        0.1.0.4+version:        0.1.0.5 synopsis:       Sandwich integration with QuickCheck description:    Please see the <https://codedownio.github.io/sandwich/docs/extensions/sandwich-quickcheck documentation>. category:       Testing@@ -37,31 +37,13 @@   build-depends:       QuickCheck     , base <4.15+    , brick     , free     , monad-control     , safe-exceptions     , sandwich >=0.1.0.4     , string-interpolate-    , time-  default-language: Haskell2010--executable sandwich-quickcheck-exe-  main-is: Main.hs-  other-modules:-      Paths_sandwich_quickcheck-  hs-source-dirs:-      app-  default-extensions: OverloadedStrings QuasiQuotes NamedFieldPuns RecordWildCards ScopedTypeVariables FlexibleContexts FlexibleInstances LambdaCase-  ghc-options: -threaded -rtsopts -with-rtsopts=-N-  build-depends:-      QuickCheck-    , base <4.15-    , free-    , monad-control-    , safe-exceptions-    , sandwich >=0.1.0.4-    , sandwich-quickcheck-    , string-interpolate+    , text     , time   default-language: Haskell2010 @@ -77,11 +59,13 @@   build-depends:       QuickCheck     , base <4.15+    , brick     , free     , monad-control     , safe-exceptions     , sandwich >=0.1.0.4     , sandwich-quickcheck     , string-interpolate+    , text     , time   default-language: Haskell2010
src/Test/Sandwich/QuickCheck.hs view
@@ -1,5 +1,7 @@  -- | Functions for introducing QuickCheck tests into a Sandwich test tree. Modelled after Hspec's version.+--+-- Documentation can be found <https://codedownio.github.io/sandwich/docs/extensions/sandwich-quickcheck here>.  {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeOperators #-}@@ -27,7 +29,7 @@ import Control.Monad.Free import Control.Monad.IO.Class import Control.Monad.Trans.Control (MonadBaseControl)-import Data.String.Interpolate+import qualified Data.Text as T import GHC.Stack import Test.QuickCheck as QC import Test.Sandwich@@ -39,7 +41,7 @@ quickCheckContext = Label :: Label "quickCheckContext" QuickCheckContext type HasQuickCheckContext context = HasLabel context "quickCheckContext" QuickCheckContext -data QuickCheckException = QuickCheckException QC.Result+data QuickCheckException = QuickCheckException   deriving (Show) instance Exception QuickCheckException @@ -62,11 +64,9 @@ prop :: (HasCallStack, HasQuickCheckContext context, MonadIO m, MonadThrow m, Testable prop) => String -> prop -> Free (SpecCommand context m) () prop msg p = it msg $ do   QuickCheckContext args <- getContext quickCheckContext-  liftIO (quickCheckWithResult args p) >>= \case-    QC.Success {..} -> do-      info [i|Success (#{numTests} tests, #{numDiscarded} skipped)|]-      return ()-    x -> throwIO (QuickCheckException x)+  liftIO (quickCheckWithResult (args { QC.chatty = False }) p) >>= \case+    QC.Success {..} -> info (T.pack output)+    x -> throwIO $ Reason (Just callStack) (output x)  -- | Modify the 'Args' for the given spec. modifyArgs :: (HasQuickCheckContext context, Monad m) => (Args -> Args) -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()@@ -76,18 +76,18 @@        QuickCheckContext args <- getContext quickCheckContext        return $ QuickCheckContext (f args) --- | Modify the 'maxSuccess' for given spec.+-- | Modify the 'maxSuccess' for the given spec. modifyMaxSuccess :: (HasQuickCheckContext context, Monad m) => (Int -> Int) -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () modifyMaxSuccess f = modifyArgs $ \args -> args { maxSuccess = f (maxSuccess args) } --- | Modify the 'maxDiscardRatio' for given spec.+-- | Modify the 'maxDiscardRatio' for the given spec. modifyMaxDiscardRatio :: (HasQuickCheckContext context, Monad m) => (Int -> Int) -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () modifyMaxDiscardRatio f = modifyArgs $ \args -> args { maxDiscardRatio = f (maxDiscardRatio args) } --- | Modify the 'maxSize' for given spec.+-- | Modify the 'maxSize' for the given spec. modifyMaxSize :: (HasQuickCheckContext context, Monad m) => (Int -> Int) -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () modifyMaxSize f = modifyArgs $ \args -> args { maxSize = f (maxSize args) } --- | Modify the 'maxShrinks' for given spec.+-- | Modify the 'maxShrinks' for the given spec. modifyMaxShrinks :: (HasQuickCheckContext context, Monad m) => (Int -> Int) -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () modifyMaxShrinks f = modifyArgs $ \args -> args { maxShrinks = f (maxShrinks args) }