module MaybeSpec
import Test.Hspec
import Test.HUnit
Copyright By PowCoder代写 加微信 powcoder
import qualified Maybe
testOneEighth :: (Int -> Maybe Int) -> Spec
testOneEighth oneEighth =
it “correctly computes” $ do
oneEighth 8 @?= Just 1
oneEighth 64 @?= Just 8
oneEighth 328 @?= Just 41
oneEighth 9 @?= Nothing
oneEighth 36 @?= Nothing
oneEighth 353 @?= Nothing
tests :: Spec
tests = do
describe “half” $ do
it “takes half if even” $ do
Maybe.half 8 @?= Just 4
Maybe.half 32 @?= Just 16
Maybe.half 64 @?= Just 32
it “returns nothing if odd” $ do
Maybe.half 7 @?= Nothing
Maybe.half 51 @?= Nothing
Maybe.half 23 @?= Nothing
describe “oneEighth” $ testOneEighth Maybe.oneEighth
describe “oneEighth'” $ testOneEighth Maybe.oneEighth’
describe “oneEighth”” $ testOneEighth Maybe.oneEighth”
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com