lish/src-test/Main.hs
Yann Esposito (Yogsototh) 05ad021c99
tests and benchmarks cleanup
2019-09-07 14:13:04 +02:00

41 lines
862 B
Haskell

import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.SmallCheck
import Lish.Test.Parser
main :: IO ()
main = defaultMain $ testGroup "all-tests" tests
inc = (+1)
tests :: [TestTree]
tests =
[ testGroup "SmallCheck" scTests
, testGroup "Unit tests" huTests
, parseTests
]
scTests :: [TestTree]
scTests =
[ testProperty "inc == succ" prop_succ
, testProperty "inc . negate == negate . pred" prop_pred
]
huTests :: [TestTree]
huTests =
[ testCase "Increment below TheAnswer" case_inc_below
, testCase "Decrement above TheAnswer" case_dec_above
]
prop_succ :: Int -> Bool
prop_succ n = inc n == succ n
prop_pred :: Int -> Bool
prop_pred n = inc (negate n) == negate (pred n)
case_inc_below :: Assertion
case_inc_below = inc 41 @?= (42 :: Int)
case_dec_above :: Assertion
case_dec_above = negate (inc (negate 43)) @?= (42 :: Int)