daytripper 0.3.0 → 0.3.1
raw patch · 3 files changed
+13/−13 lines, 3 filesdep ~optparse-applicativePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: optparse-applicative
API changes (from Hackage documentation)
- Test.Daytripper: class MonadFail m => MonadExpect m
+ Test.Daytripper: class (MonadFail m) => MonadExpect m
Files
- daytripper.cabal +3/−3
- src/Test/Daytripper.hs +8/−8
- test/Main.hs +2/−2
daytripper.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: daytripper-version: 0.3.0+version: 0.3.1 synopsis: Helpers for round-trip tests description: Please see the README on GitHub at <https://github.com/ejconlon/daytripper#readme> homepage: https://github.com/ejconlon/daytripper#readme@@ -62,7 +62,7 @@ , bytestring ==0.11.* , directory ==1.3.* , falsify ==0.2.*- , optparse-applicative ==0.17.*+ , optparse-applicative >=0.17 && <0.19 , tagged ==0.8.* , tasty ==1.4.* , tasty-hunit ==0.10.*@@ -107,7 +107,7 @@ , daytripper , directory ==1.3.* , falsify ==0.2.*- , optparse-applicative ==0.17.*+ , optparse-applicative >=0.17 && <0.19 , tagged ==0.8.* , tasty ==1.4.* , tasty-hunit ==0.10.*
src/Test/Daytripper.hs view
@@ -38,7 +38,7 @@ -- | Interface for asserting and performing IO in tests. -- TODO Migrate to 'MonadIO' superclass when Falsify supports it.-class MonadFail m => MonadExpect m where+class (MonadFail m) => MonadExpect m where expectLiftIO :: IO a -> m a expectAssertEq :: (Eq a, Show a) => a -> a -> m () expectAssertFailure :: String -> m ()@@ -66,21 +66,21 @@ eitherMay = either (const Nothing) Just -- | Assert something before processing (before encoding and before decoding)-expectBefore :: Monad m => (Maybe a -> m ()) -> Expect m a b c -> Expect m a b c+expectBefore :: (Monad m) => (Maybe a -> m ()) -> Expect m a b c -> Expect m a b c expectBefore f ex i = f (eitherMay i) >> ex i -- | Assert something during processing (after encoding and before decoding)-expectDuring :: Monad m => (Maybe a -> b -> m ()) -> Expect m a b c -> Expect m a b c+expectDuring :: (Monad m) => (Maybe a -> b -> m ()) -> Expect m a b c -> Expect m a b c expectDuring f ex i = ex i >>= \p@(b, _) -> p <$ f (eitherMay i) b -- | Asserting something after processing (after encoding and after decoding)-expectAfter :: Monad m => (Maybe a -> b -> c -> m ()) -> Expect m a b c -> Expect m a b c+expectAfter :: (Monad m) => (Maybe a -> b -> c -> m ()) -> Expect m a b c -> Expect m a b c expectAfter f ex i = ex i >>= \(b, end) -> end >>= \c -> (b, pure c) <$ f (eitherMay i) b c -- | A way of definining expectations from a pair of encode/decode functions and -- a comparison function. mkExpect- :: MonadExpect m+ :: (MonadExpect m) => (a -> m b) -> (b -> m c) -> (Maybe a -> c -> m ())@@ -93,14 +93,14 @@ pure c -- | Simple way to run an expectation, ignoring the intermediate value.-runExpect :: Monad m => Expect m a b c -> a -> m c+runExpect :: (Monad m) => Expect m a b c -> a -> m c runExpect f a = f (Right a) >>= snd data PropRT where- PropRT :: Show a => TestName -> Expect Property a b c -> Gen a -> PropRT+ PropRT :: (Show a) => TestName -> Expect Property a b c -> Gen a -> PropRT -- | Create a property-based roundtrip test-mkPropRT :: Show a => TestName -> Expect Property a b c -> Gen a -> RT+mkPropRT :: (Show a) => TestName -> Expect Property a b c -> Gen a -> RT mkPropRT name expec gen = RTProp (PropRT name expec gen) testPropRT :: PropRT -> TestTree
test/Main.hs view
@@ -15,7 +15,7 @@ type Cmp m = Maybe ByteString -> Maybe ByteString -> m () -expec :: MonadExpect m => Cmp m -> Expect m ByteString ByteString (Maybe ByteString)+expec :: (MonadExpect m) => Cmp m -> Expect m ByteString ByteString (Maybe ByteString) expec = mkExpect enc dec where enc a = pure (a <> a)@@ -26,7 +26,7 @@ then Just a else Nothing -expecOk, expecFail :: MonadExpect m => Expect m ByteString ByteString (Maybe ByteString)+expecOk, expecFail :: (MonadExpect m) => Expect m ByteString ByteString (Maybe ByteString) expecOk = expec $ maybe