packages feed

sandwich 0.1.5.1 → 0.1.5.2

raw patch · 3 files changed

+18/−1 lines, 3 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Test.Sandwich.Contexts: popContext :: forall m l a intro context. Monad m => Label l intro -> ExampleT context m a -> ExampleT (LabelValue l intro :> context) m a
+ Test.Sandwich.Contexts: pushContext :: forall m l a intro context. Monad m => Label l intro -> intro -> ExampleT (LabelValue l intro :> context) m a -> ExampleT context m a

Files

CHANGELOG.md view
@@ -2,6 +2,10 @@  ## Unreleased changes +## 0.1.5.2++* Contexts: add pushContext and popContext helpers.+ ## 0.1.5.1  * Logging: add readCreateProcessWithLogging
sandwich.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           sandwich-version:        0.1.5.1+version:        0.1.5.2 synopsis:       Yet another test framework for Haskell description:    Please see the <https://codedownio.github.io/sandwich documentation>. category:       Testing
src/Test/Sandwich/Contexts.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE MonoLocalBinds #-}+{-# LANGUAGE TypeOperators #-}  -- | Functions for retrieving context information from within tests. @@ -36,3 +37,15 @@ -- This just calls 'getCommandLineOptions' and pulls out the user options. getUserCommandLineOptions :: (HasCommandLineOptions context a, MonadReader context m, MonadIO m) => m a getUserCommandLineOptions = optUserOptions <$> getContext commandLineOptions++-- * Low-level context management helpers++-- | Push a label to the context.+pushContext :: forall m l a intro context. (Monad m) => Label l intro -> intro -> ExampleT (LabelValue l intro :> context) m a -> ExampleT context m a+pushContext _label value (ExampleT action) = do+  ExampleT $ withReaderT (\context -> LabelValue value :> context) $ action++-- | Remove a label from the context.+popContext :: forall m l a intro context. (Monad m) => Label l intro -> ExampleT context m a -> ExampleT (LabelValue l intro :> context) m a+popContext _label (ExampleT action) = do+  ExampleT $ withReaderT (\(_ :> context) -> context) $ action