summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-06-29 15:00:14 +0100
committerSimon Marlow <marlowsd@gmail.com>2011-07-06 11:59:27 +0100
commit3a17ededcb87fe04252ad83793b16713fed49eaf (patch)
treed929a7aabd40cc081c07122989d4aa05c6231442 /testsuite
parent44fcc0a91d6060c289d105a8a27449d0ab5f5454 (diff)
downloadhaskell-3a17ededcb87fe04252ad83793b16713fed49eaf.tar.gz
Add test for #5129
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/ghc-regress/codeGen/should_run/5129.hs21
-rw-r--r--testsuite/tests/ghc-regress/codeGen/should_run/all.T1
2 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/ghc-regress/codeGen/should_run/5129.hs b/testsuite/tests/ghc-regress/codeGen/should_run/5129.hs
new file mode 100644
index 0000000000..6bc1912754
--- /dev/null
+++ b/testsuite/tests/ghc-regress/codeGen/should_run/5129.hs
@@ -0,0 +1,21 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+import Control.Exception as E
+import Data.Typeable
+
+throwIfNegative :: Int -> String
+throwIfNegative n | n < 0 = error "negative"
+ | otherwise = "no worries"
+{-# NOINLINE throwIfNegative #-}
+
+data HUnitFailure = HUnitFailure String deriving (Show,Typeable)
+instance Exception HUnitFailure
+
+assertFailure msg = E.throw (HUnitFailure msg)
+
+case_negative =
+ handleJust errorCalls (const $ return ()) $ do
+ evaluate $ throwIfNegative (-1)
+ assertFailure "must throw when given a negative number"
+ where errorCalls (ErrorCall _) = Just ()
+
+main = case_negative
diff --git a/testsuite/tests/ghc-regress/codeGen/should_run/all.T b/testsuite/tests/ghc-regress/codeGen/should_run/all.T
index c5c5829712..c12de29a72 100644
--- a/testsuite/tests/ghc-regress/codeGen/should_run/all.T
+++ b/testsuite/tests/ghc-regress/codeGen/should_run/all.T
@@ -86,3 +86,4 @@ test('3677', extra_run_opts('+RTS -K8k -RTS'), compile_and_run, [''])
test('4441', normal, compile_and_run, [''])
test('5149', omit_ways(['ghci']), multisrc_compile_and_run,
['5149', ['5149_cmm.cmm'], ''])
+test('5129', normal, compile_and_run, [''])