Skip to content

Commit

Permalink
comment out property test to start and add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jisantuc committed Nov 2, 2020
1 parent a6efaab commit a4ea520
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import GHC.IO.Exception (ExitCode (..))
import Lib (add)
import Matchers (shouldBe)
import Result (fromProp2, isSuccess)
import Result as Result
import System.Exit (exitWith)
import TestSuite (TestSuite (..), runTests)

main :: IO ()
main = do
addUnitExit <- runTestSuite addUnitSuite
addPropExit <- addPropSuite >>= runTestSuite
exitWith (max addUnitExit addPropExit)
-- addPropExit <- addPropSuite >>= runTestSuite
exitWith addUnitExit

runTestSuite :: TestSuite -> IO ExitCode
runTestSuite testSuite =
Expand All @@ -21,7 +21,7 @@ runTestSuite testSuite =
rs
(TestSuite rs) ->
rs
anyFailures = not . all isSuccess $ results
anyFailures = not . all Result.isSuccess $ results
in do
runTests testSuite
pure $ if anyFailures then ExitFailure 1 else ExitSuccess
Expand All @@ -34,16 +34,20 @@ addUnitSuite =
[ add 3 4 `shouldBe` 7,
add 5 9 `shouldBe` 14,
add (-3) 9 `shouldBe` 6,
add (-3) 28 `shouldBe` 25
add (-3) 28 `shouldBe` 25,
add 14 51 `shouldBe` 65,
add 23 55 `shouldBe` 78,
add 71 0 `shouldBe` 71,
add 2 9 `shouldBe` 11
]
}

addPropSuite :: IO TestSuite
addPropSuite =
do
result <- fromProp2 (\x y -> add x y `shouldBe` (x + y))
pure $
NamedTestSuite
{ suiteName = "addition prop tests",
suite = [result]
}
-- addPropSuite :: IO TestSuite
-- addPropSuite =
-- do
-- result <- Result.fromProp2 (\x y -> add x y `shouldBe` (x + y))
-- pure $
-- NamedTestSuite
-- { suiteName = "addition prop tests",
-- suite = [result]
-- }

0 comments on commit a4ea520

Please sign in to comment.