sandwich-quickcheck 0.1.0.7 → 0.2.0.0
raw patch · 5 files changed
+29/−29 lines, 5 filesdep +unliftiodep −monad-controldep −mtldep −safe-exceptionsPVP ok
version bump matches the API change (PVP)
Dependencies added: unliftio
Dependencies removed: monad-control, mtl, safe-exceptions, time
API changes (from Hackage documentation)
+ Test.Sandwich.QuickCheck: type HasQuickCheckContext context = HasLabel context "quickCheckContext" QuickCheckContext
- Test.Sandwich.QuickCheck: introduceQuickCheck :: (MonadIO m, MonadBaseControl IO m) => SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
+ Test.Sandwich.QuickCheck: introduceQuickCheck :: MonadIO m => SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
- Test.Sandwich.QuickCheck: introduceQuickCheck' :: (MonadIO m, MonadBaseControl IO m) => Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
+ Test.Sandwich.QuickCheck: introduceQuickCheck' :: MonadIO m => Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
- Test.Sandwich.QuickCheck: introduceQuickCheck'' :: (MonadIO m, MonadBaseControl IO m) => String -> Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
+ Test.Sandwich.QuickCheck: introduceQuickCheck'' :: MonadIO m => String -> Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
- Test.Sandwich.QuickCheck: introduceQuickCheckCommandLineOptions :: forall a m context. (MonadIO m, MonadBaseControl IO m, HasLabel context "commandLineOptions" (CommandLineOptions a), MonadReader context m) => SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
+ Test.Sandwich.QuickCheck: introduceQuickCheckCommandLineOptions :: forall a m context. (MonadIO m, HasLabel context "commandLineOptions" (CommandLineOptions a)) => SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
- Test.Sandwich.QuickCheck: introduceQuickCheckCommandLineOptions' :: forall a m context. (MonadIO m, MonadBaseControl IO m, HasLabel context "commandLineOptions" (CommandLineOptions a), MonadReader context m) => Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
+ Test.Sandwich.QuickCheck: introduceQuickCheckCommandLineOptions' :: forall a m context. (MonadIO m, HasLabel context "commandLineOptions" (CommandLineOptions a)) => Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
- Test.Sandwich.QuickCheck: introduceQuickCheckCommandLineOptions'' :: forall a m context. (MonadIO m, MonadBaseControl IO m, HasLabel context "commandLineOptions" (CommandLineOptions a), MonadReader context m) => String -> Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
+ Test.Sandwich.QuickCheck: introduceQuickCheckCommandLineOptions'' :: forall a m context. (MonadIO m, HasLabel context "commandLineOptions" (CommandLineOptions a)) => String -> Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()
- Test.Sandwich.QuickCheck: prop :: (HasCallStack, HasQuickCheckContext context, MonadIO m, MonadThrow m, Testable prop) => String -> prop -> Free (SpecCommand context m) ()
+ Test.Sandwich.QuickCheck: prop :: (HasCallStack, HasQuickCheckContext context, MonadIO m, Testable prop) => String -> prop -> Free (SpecCommand context m) ()
Files
- ChangeLog.md +6/−1
- LICENSE +1/−1
- sandwich-quickcheck.cabal +6/−12
- src/Test/Sandwich/QuickCheck.hs +15/−13
- test/Spec.hs +1/−2
ChangeLog.md view
@@ -1,6 +1,11 @@ # Changelog for sandwich-quickcheck -## Unreleased changes+## Unreleased++## 0.2.0.0++* Don't use MonadBaseControl anymore+* Expose HasQuickCheckContext ## 0.1.0.7
LICENSE view
@@ -1,4 +1,4 @@-Copyright Tom McLaughlin (c) 2023+Copyright Tom McLaughlin (c) 2024 All rights reserved.
sandwich-quickcheck.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.1.+-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack ----- hash: 496ab214547ab49a21ff2bed85694f6d3b52326cdd719476fd8f526488cae467+-- hash: 40d1ce983b1eb830c952dc625f9797925e149442f7b080d45c58a63c6e322278 name: sandwich-quickcheck-version: 0.1.0.7+version: 0.2.0.0 synopsis: Sandwich integration with QuickCheck description: Please see the <https://codedownio.github.io/sandwich/docs/extensions/sandwich-quickcheck documentation>. category: Testing@@ -15,7 +15,7 @@ bug-reports: https://github.com/codedownio/sandwich/issues author: Tom McLaughlin maintainer: tom@codedown.io-copyright: 2023 Tom McLaughlin+copyright: 2025 Tom McLaughlin license: BSD3 license-file: LICENSE build-type: Simple@@ -46,12 +46,9 @@ QuickCheck , base <5 , free- , monad-control- , mtl- , safe-exceptions , sandwich >=0.1.0.4 , text- , time+ , unliftio default-language: Haskell2010 test-suite sandwich-quickcheck-test@@ -75,10 +72,7 @@ QuickCheck , base <5 , free- , monad-control- , mtl- , safe-exceptions , sandwich >=0.1.0.4 , text- , time+ , unliftio default-language: Haskell2010
src/Test/Sandwich/QuickCheck.hs view
@@ -30,13 +30,13 @@ , modifyMaxDiscardRatio , modifyMaxSize , modifyMaxShrinks++ -- * Types+ , HasQuickCheckContext ) where -import Control.Exception.Safe import Control.Monad.Free import Control.Monad.IO.Class-import Control.Monad.Reader-import Control.Monad.Trans.Control (MonadBaseControl) import Data.Maybe import qualified Data.Text as T import GHC.Stack@@ -44,11 +44,13 @@ import Test.QuickCheck.Random as QC import Test.Sandwich import Test.Sandwich.Internal+import UnliftIO.Exception data QuickCheckContext = QuickCheckContext Args deriving Show-quickCheckContext = Label :: Label "quickCheckContext" QuickCheckContext+quickCheckContext :: Label "quickCheckContext" QuickCheckContext+quickCheckContext = Label type HasQuickCheckContext context = HasLabel context "quickCheckContext" QuickCheckContext data QuickCheckException = QuickCheckException@@ -56,43 +58,43 @@ instance Exception QuickCheckException -- | Same as 'introduceQuickCheck'' but with default args.-introduceQuickCheck :: (MonadIO m, MonadBaseControl IO m)+introduceQuickCheck :: (MonadIO m) => SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () introduceQuickCheck = introduceQuickCheck'' "Introduce QuickCheck context" stdArgs -- | Same as 'introduceQuickCheck''' but with a default message.-introduceQuickCheck' :: (MonadIO m, MonadBaseControl IO m)+introduceQuickCheck' :: (MonadIO m) => Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () introduceQuickCheck' = introduceQuickCheck'' "Introduce QuickCheck context" -- | Introduce QuickCheck args with configurable message.-introduceQuickCheck'' :: (MonadIO m, MonadBaseControl IO m)+introduceQuickCheck'' :: (MonadIO m) => String -> Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () introduceQuickCheck'' msg args = introduce msg quickCheckContext (return $ QuickCheckContext args) (const $ return ()) -- | Same as 'introduceQuickCheckCommandLineOptions'' but with default args.-introduceQuickCheckCommandLineOptions :: forall a m context. (MonadIO m, MonadBaseControl IO m, HasLabel context "commandLineOptions" (CommandLineOptions a), MonadReader context m)+introduceQuickCheckCommandLineOptions :: forall a m context. (MonadIO m, HasLabel context "commandLineOptions" (CommandLineOptions a)) => SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () introduceQuickCheckCommandLineOptions = introduceQuickCheckCommandLineOptions'' @a "Introduce QuickCheck context with command line options" stdArgs -- | Same as 'introduceQuickCheckCommandLineOptions''' but with a default message.-introduceQuickCheckCommandLineOptions' :: forall a m context. (MonadIO m, MonadBaseControl IO m, HasLabel context "commandLineOptions" (CommandLineOptions a), MonadReader context m)+introduceQuickCheckCommandLineOptions' :: forall a m context. (MonadIO m, HasLabel context "commandLineOptions" (CommandLineOptions a)) => Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m () introduceQuickCheckCommandLineOptions' = introduceQuickCheckCommandLineOptions'' @a "Introduce QuickCheck context with command line options" -- | Introduce QuickCheck args with configurable message, overriding those args with any command line options passed.-introduceQuickCheckCommandLineOptions'' :: forall a m context. (MonadIO m, MonadBaseControl IO m, HasLabel context "commandLineOptions" (CommandLineOptions a), MonadReader context m)+introduceQuickCheckCommandLineOptions'' :: forall a m context. (MonadIO m, HasLabel context "commandLineOptions" (CommandLineOptions a)) => String -> Args -> SpecFree (LabelValue "quickCheckContext" QuickCheckContext :> context) m () -> SpecFree context m ()-introduceQuickCheckCommandLineOptions'' msg args = introduce msg quickCheckContext getContext (const $ return ())+introduceQuickCheckCommandLineOptions'' msg args = introduce msg quickCheckContext getContext' (const $ return ()) where- getContext = do+ getContext' = do clo <- getCommandLineOptions @a return $ QuickCheckContext $ addCommandLineOptions clo args -- | Similar to 'it'. Runs the given prop with QuickCheck using the currently introduced 'Args'. Throws an appropriate exception on failure.-prop :: (HasCallStack, HasQuickCheckContext context, MonadIO m, MonadThrow m, Testable prop) => String -> prop -> Free (SpecCommand context m) ()+prop :: (HasCallStack, HasQuickCheckContext context, MonadIO m, Testable prop) => String -> prop -> Free (SpecCommand context m) () prop msg p = it msg $ do QuickCheckContext args <- getContext quickCheckContext liftIO (quickCheckWithResult (args { QC.chatty = False }) p) >>= \case
test/Spec.hs view
@@ -1,6 +1,5 @@ import Test.Sandwich-import Data.Time.Clock import Test.Sandwich.Formatters.Print @@ -12,5 +11,5 @@ main = runSandwich options verySimple where options = defaultOptions {- optionsTestArtifactsDirectory = TestArtifactsGeneratedDirectory "test_runs" (show <$> getCurrentTime)+ optionsTestArtifactsDirectory = defaultTestArtifactsDirectory }