dwergaz 0.3.0.0 → 0.3.0.1
raw patch · 4 files changed
+23/−8 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- dwergaz.cabal +1/−1
- src/Test/Dwergaz.hs +3/−1
- test/Main.hs +15/−6
ChangeLog.md view
@@ -47,3 +47,7 @@ * Added a second type variable `b` to `Expect`, allowing a wider variety of tests. * Added `assertFailure`, `assertBool`, and `assertEqual` helper functions for creating tests. * Simplified `Predicate` to only accept a boolean argument instead of separate predicate function and value arguments.++## 0.3.0.1 -- 2024-12-02++* Tweaked tests and formatting.
dwergaz.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: dwergaz-version: 0.3.0.0+version: 0.3.0.1 synopsis: A minimal testing library description: dwergaz is a minimal testing library. license: ISC
src/Test/Dwergaz.hs view
@@ -26,7 +26,9 @@ import Text.PrettyPrint data Test- = forall a b. (Show a, Show b) => Expect+ = forall a b.+ (Show a, Show b) =>+ Expect -- | Test description String -- | Test function
test/Main.hs view
@@ -22,7 +22,7 @@ expectExample02 = assertEqual "Ints are equal" 42 (testFun02 "quux") predicateExample01, predicateExample02, predicateExample03 :: Test-predicateExample01 = Predicate "Value is a Left" (isLeft $ testFun03 "quux")+predicateExample01 = Predicate "Value is a Left" (isLeft (testFun03 "quux")) predicateExample02 = assertBool "Value is a Right" (isRight (testFun04 "quux")) predicateExample03 = assertFailure "Just fail" @@ -35,11 +35,20 @@ predicateExample03 ] -results :: [Result]-results = fmap runTest exampleTests+step :: Result -> (ShowS, Bool) -> (ShowS, Bool)+step result (f, allPassed) =+ ( showString (resultToString result) . showChar '\n' . f,+ resultIsPassed result && allPassed+ ) +results :: (String, Bool)+results = (buildString mempty, allPassed)+ where+ (buildString, allPassed) = foldr (step . runTest) (id, True) exampleTests+ main :: IO () main = do- mapM_ (putStrLn . resultToString) results- -- The following should use 'Control.Monad.unless' in real usage.- when (all resultIsPassed results) exitFailure+ let (output, passed) = results+ putStr output+ -- The following should be 'Control.Monad.unless' in real usage.+ when passed exitFailure