Add a test making sure pattern match failures on GhcModT work the way I expect

This commit is contained in:
Daniel Gröber 2014-08-06 20:41:59 +02:00
parent fad99f466f
commit 7388b50474
2 changed files with 20 additions and 0 deletions

View File

@ -169,6 +169,7 @@ Test-Suite spec
LangSpec
LintSpec
ListSpec
MonadSpec
GhcPkgSpec
TestUtils
Build-Depends: base >= 4.0 && < 5

19
test/MonadSpec.hs Normal file
View File

@ -0,0 +1,19 @@
module MonadSpec where
import Test.Hspec
import Control.Monad.Error.Class
import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.Monad
import Language.Haskell.GhcMod.Find
spec :: Spec
spec = do
describe "When using GhcModT in a do block" $
it "a pattern match failure causes a call to `fail` on ErrorT in the monad stack" $ do
(a, w)
<- runGhcModT defaultOptions $
do
Just a <- return Nothing
return "hello"
`catchError` (const $ fail "oh noes")
a `shouldBe` (Left $ GMEString "oh noes")