From 7388b50474e70cc8d4c8c0a5713a09856e4142a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Wed, 6 Aug 2014 20:41:59 +0200 Subject: [PATCH] Add a test making sure pattern match failures on GhcModT work the way I expect --- ghc-mod.cabal | 1 + test/MonadSpec.hs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/MonadSpec.hs diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 02ae914..73922a3 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -169,6 +169,7 @@ Test-Suite spec LangSpec LintSpec ListSpec + MonadSpec GhcPkgSpec TestUtils Build-Depends: base >= 4.0 && < 5 diff --git a/test/MonadSpec.hs b/test/MonadSpec.hs new file mode 100644 index 0000000..7594e88 --- /dev/null +++ b/test/MonadSpec.hs @@ -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")