projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 2001-05-18 14:18:34 by simonmar]
[ghc-hetmet.git]
/
ghc
/
tests
/
lib
/
should_run
/
exceptions001.hs
diff --git
a/ghc/tests/lib/should_run/exceptions001.hs
b/ghc/tests/lib/should_run/exceptions001.hs
index
fa38c0f
..
e585ca5
100644
(file)
--- a/
ghc/tests/lib/should_run/exceptions001.hs
+++ b/
ghc/tests/lib/should_run/exceptions001.hs
@@
-1,7
+1,7
@@
module Main where
import Prelude hiding (catch)
module Main where
import Prelude hiding (catch)
-import Exception
+import Exception
import IO hiding (try, catch)
main = do
import IO hiding (try, catch)
main = do
@@
-13,23
+13,22
@@
main = do
dynTest
ioTest :: IO ()
dynTest
ioTest :: IO ()
-ioTest = catchIO (fail (userError "wibble"))
- (\ex -> if isUserError ex then putStr "io exception caught\n"
- else error "help!")
+ioTest = catchJust userErrors (ioError (userError "wibble"))
+ (\ex -> putStr "user exception caught\n")
errorTest :: IO ()
errorTest :: IO ()
-errorTest = getException (1 + error "call to 'error'") >>= \r ->
+errorTest = try (evaluate (1 + error "call to 'error'")) >>= \r ->
case r of
case r of
- Just exception -> putStr "error call caught\n"
- Nothing -> error "help!"
+ Left exception -> putStr "error call caught\n"
+ Right _ -> error "help!"
instance (Show a, Eq a) => Num (Maybe a) where {}
noMethodTest :: IO ()
instance (Show a, Eq a) => Num (Maybe a) where {}
noMethodTest :: IO ()
-noMethodTest = getException (Just () + Just ()) >>= \ r ->
+noMethodTest = try (evaluate (Just () + Just ())) >>= \ r ->
case r of
case r of
- Just (NoMethodError err) -> putStr "no method error\n"
- other -> error "help!"
+ Left (NoMethodError err) -> putStr "no method error\n"
+ Right _ -> error "help!"
patMatchTest :: IO ()
patMatchTest = catch (case test1 [1..10] of () -> return ())
patMatchTest :: IO ()
patMatchTest = catch (case test1 [1..10] of () -> return ())
@@
-41,7
+40,7
@@
test1 [] = ()
guardTest = catch (case test2 of () -> return ())
(\ex -> case ex of
guardTest = catch (case test2 of () -> return ())
(\ex -> case ex of
- NonExhaustiveGuards err -> putStr err
+ PatternMatchFail err -> putStr err
other -> error "help!")
test2 | all (==0) [1] = ()
other -> error "help!")
test2 | all (==0) [1] = ()