summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonm <unknown>1998-08-12 11:05:16 +0000
committersimonm <unknown>1998-08-12 11:05:16 +0000
commitfa7605804521e04066b31fcc91e5e0872334f995 (patch)
tree0ebfebfd64f94e35bc7f0c5c3da509317791a92d
parent736492ced360555aa600c761b3e39f100fc6293f (diff)
downloadhaskell-fa7605804521e04066b31fcc91e5e0872334f995.tar.gz
[project @ 1998-08-12 11:05:14 by simonm]
Exception library tests.
-rw-r--r--ghc/tests/lib/should_run/Makefile4
-rw-r--r--ghc/tests/lib/should_run/exceptions001.hs57
-rw-r--r--ghc/tests/lib/should_run/exceptions001.stdout0
3 files changed, 60 insertions, 1 deletions
diff --git a/ghc/tests/lib/should_run/Makefile b/ghc/tests/lib/should_run/Makefile
index 2df31549e9..ca76c0fa2b 100644
--- a/ghc/tests/lib/should_run/Makefile
+++ b/ghc/tests/lib/should_run/Makefile
@@ -1,5 +1,5 @@
#-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.4 1998/08/11 21:08:51 sof Exp $
+# $Id: Makefile,v 1.5 1998/08/12 11:05:14 simonm Exp $
TOP = ../..
include $(TOP)/mk/boilerplate.mk
@@ -8,6 +8,8 @@ include $(TOP)/mk/should_run.mk
SRC_HC_OPTS += -dcore-lint
packedstring001_HC_OPTS = -syslib misc
+exceptions001_HC_OPTS = -fglasgow-exts
+
stableptr001_RUNTEST_OPTS = +RTS -K4m
dynamic001_HC_OPTS = -syslib exts
diff --git a/ghc/tests/lib/should_run/exceptions001.hs b/ghc/tests/lib/should_run/exceptions001.hs
new file mode 100644
index 0000000000..38411a81b4
--- /dev/null
+++ b/ghc/tests/lib/should_run/exceptions001.hs
@@ -0,0 +1,57 @@
+module Main where
+
+import Prelude hiding (catch)
+import Exception
+import IO hiding (try)
+
+main = do
+ ioTest
+ errorTest
+ noMethodTest
+ patMatchTest
+ guardTest
+ dynTest
+
+ioTest :: IO ()
+ioTest = catchIO (fail (userError "wibble"))
+ (\ex -> if isUserError ex then putStr "io exception caught\n"
+ else error "help!")
+
+errorTest :: IO ()
+errorTest = case getExceptions (1 + error "call to 'error'") of
+ Left exceptions -> putStr "error call caught\n"
+ Right val -> error "help!"
+
+instance (Show a, Eq a) => Num (Maybe a) where {}
+
+noMethodTest :: IO ()
+noMethodTest = catch (case Just () + Just () of Nothing -> return ())
+ (\exs -> case unsafePromiseSingleton exs of
+ NoMethodError err -> putStr "no method error\n"
+ other -> error "help!")
+
+patMatchTest :: IO ()
+patMatchTest = catchOne (case test1 [1..10] of () -> return ())
+ (\ex -> case ex of
+ PatternMatchFail err -> putStr err
+ other -> error "help!")
+
+test1 [] = ()
+
+guardTest = catchOne (case test2 of () -> return ())
+ (\ex -> case ex of
+ NonExhaustiveGuards err -> putStr err
+ other -> error "help!")
+
+test2 | all (==0) [1] = ()
+
+dynTest = catchDyn (case throwDyn (42::Int, (+1)::Int->Int) of () -> return ())
+ (\(i,f) -> let x = f (i::Int) :: Int in putStr (show x))
+
+{-
+recSelTest
+recConTest
+recUpdTest
+assertTest
+arithTest
+-}
diff --git a/ghc/tests/lib/should_run/exceptions001.stdout b/ghc/tests/lib/should_run/exceptions001.stdout
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/tests/lib/should_run/exceptions001.stdout