Advertisement
kpfp_linux

Untitled

Aug 25th, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. foo :: Monad m => m Int
  2. foo = fail "nope"
  3.  
  4. spec :: Spec
  5. spec = do
  6.   describe "foo" $ do
  7.     it "works!" $ do
  8.       let res :: Maybe Int
  9.           res = foo
  10.       res `shouldBe` Nothing
  11.     it "this does not work" $ do
  12.       let res :: Either String Int
  13.           res = foo
  14.           exp :: Either String Int
  15.           exp = Left "nope"
  16.       res `shouldBe` exp
  17.       -- uncaught exception: ErrorCall (nope)
  18.     it "this does not work either..." $ do
  19.       let res :: Either String Int
  20.           res = foo
  21.       return res `shouldThrow` anyException
  22.       -- did not get expected exception: SomeException
  23.     it "...neither this" $ do
  24.       let res :: Either String Int
  25.           res = foo
  26.       return res `shouldThrow` errorCall "nope"
  27.       -- did not get expected exception: ErrorCall
  28.     it "...nor this" $ do
  29.       let res :: Either String Int
  30.           res = foo
  31.       return res `shouldThrow` anyErrorCall
  32.       -- did not get expected exception: ErrorCall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement