sydtest 0.18.0.0 → 0.18.0.1
raw patch · 4 files changed
+17/−15 lines, 4 files
Files
- CHANGELOG.md +8/−0
- src/Test/Syd/Expectation.hs +2/−2
- src/Test/Syd/Run.hs +6/−12
- sydtest.cabal +1/−1
CHANGELOG.md view
@@ -1,5 +1,13 @@ # Changelog +## [0.18.0.1] - 2024-11-01++### Changed++- Fixed `mkNotEqualButShouldHaveBeenEqual` logic so it keeps the escape+ sequence for `Text` and `String`. This fix a regression introduced in+ 0.18.0.0.+ ## [0.18.0.0] - 2024-09-26 ### Added
src/Test/Syd/Expectation.hs view
@@ -29,7 +29,7 @@ -- | Assert that two values are equal according to `==`. shouldBe :: (HasCallStack, Show a, Eq a) => a -> a -> IO ()-shouldBe actual expected = unless (actual == expected) $ throwIO =<< mkNotEqualButShouldHaveBeenEqual actual expected+shouldBe actual expected = unless (actual == expected) $ throwIO =<< mkNotEqualButShouldHaveBeenEqual (ppShow actual) (ppShow expected) infix 1 `shouldBe` @@ -63,7 +63,7 @@ shouldReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> IO () shouldReturn computeActual expected = do actual <- computeActual- unless (actual == expected) $ throwIO =<< mkNotEqualButShouldHaveBeenEqual actual expected+ unless (actual == expected) $ throwIO =<< mkNotEqualButShouldHaveBeenEqual (ppShow actual) (ppShow expected) infix 1 `shouldReturn`
src/Test/Syd/Run.hs view
@@ -26,7 +26,6 @@ import qualified Data.Map as M import Data.Text (Text) import qualified Data.Text as T-import Data.Typeable import qualified Data.Vector as V import Data.Word import GHC.Clock (getMonotonicTimeNSec)@@ -41,7 +40,6 @@ import qualified Test.QuickCheck.Property as QCP import Test.QuickCheck.Random import Text.Printf-import Text.Show.Pretty (ppShow) class IsTest e where -- | The argument from 'aroundAll'@@ -506,7 +504,7 @@ !(Maybe String) -- Name of the predicate | ExpectationFailed !String | Context !Assertion !String- deriving (Show, Eq, Typeable, Generic)+ deriving (Show, Eq, Generic) -- | Returns the diff between two strings --@@ -520,22 +518,18 @@ -- | Assertion when both arguments are not equal. While display a diff between -- both at the end of tests. The diff computation is cancelled after 2s. mkNotEqualButShouldHaveBeenEqual ::- (Show a) =>- a ->- a ->+ String ->+ String -> IO Assertion mkNotEqualButShouldHaveBeenEqual actual expected = do- let ppActual = ppShow actual- let ppExpected = ppShow expected-- let diffNotEvaluated = computeDiff ppActual ppExpected+ let diffNotEvaluated = computeDiff actual expected -- we want to evaluate the diff in order to ensure that its -- computation happen in the timeout block -- and is not instead later because of lazy evaluation. -- -- The safe option here is to evaluate to normal form with `force`. diff <- timeout 2e6 (evaluate (force diffNotEvaluated))- pure $ NotEqualButShouldHaveBeenEqualWithDiff ppActual ppExpected diff+ pure $ NotEqualButShouldHaveBeenEqualWithDiff actual expected diff instance Exception Assertion @@ -559,7 +553,7 @@ = GoldenNotFound | GoldenStarted | GoldenReset- deriving (Show, Eq, Typeable, Generic)+ deriving (Show, Eq, Generic) type ProgressReporter = Progress -> IO ()
sydtest.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: sydtest-version: 0.18.0.0+version: 0.18.0.1 synopsis: A modern testing framework for Haskell with good defaults and advanced testing features. description: A modern testing framework for Haskell with good defaults and advanced testing features. Sydtest aims to make the common easy and the hard possible. See https://github.com/NorfairKing/sydtest#readme for more information. category: Testing