Advertisement
kpfp_linux

Untitled

Aug 25th, 2014
291
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 "does not work, heatsink (I)" $ do
  8.       let res :: Either String Int
  9.           res = foo
  10.       res @?= Left "nope"
  11.       --uncaught exception: ErrorCall (nope)
  12.     it "does not work, heatsink (II)" $ do
  13.       let res :: Either String Int
  14.           res = foo
  15.       return res `shouldReturn` Left "nope"
  16.       --uncaught exception: ErrorCall (nope)
  17.     it "works!" $ do
  18.       let res :: Maybe Int
  19.           res = foo
  20.       res `shouldBe` Nothing
  21.     it "this does not work" $ do
  22.       let res :: Either String Int
  23.           res = foo
  24.           exp :: Either String Int
  25.           exp = Left "nope"
  26.       res `shouldBe` exp
  27.       -- uncaught exception: ErrorCall (nope)
  28.     it "this does not work either..." $ do
  29.       let res :: Either String Int
  30.           res = foo
  31.       return res `shouldThrow` anyException
  32.       -- did not get expected exception: SomeException
  33.     it "...neither this" $ do
  34.       let res :: Either String Int
  35.           res = foo
  36.       return res `shouldThrow` errorCall "nope"
  37.       -- did not get expected exception: ErrorCall
  38.     it "...nor this" $ do
  39.       let res :: Either String Int
  40.           res = foo
  41.       return res `shouldThrow` anyErrorCall
  42.       -- did not get expected exception: ErrorCall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement