[project @ 1998-10-08 11:52:34 by simonm]
authorsimonm <unknown>
Thu, 8 Oct 1998 11:52:36 +0000 (11:52 +0000)
committersimonm <unknown>
Thu, 8 Oct 1998 11:52:36 +0000 (11:52 +0000)
fixup tests for 4.00

ghc/tests/lib/should_run/Makefile
ghc/tests/lib/should_run/exceptions001.hs
ghc/tests/lib/should_run/exceptions001.stdout
ghc/tests/lib/should_run/list001.hs
ghc/tests/lib/should_run/packedstring001.hs

index 7ba9700..5d86a0c 100644 (file)
@@ -1,5 +1,5 @@
 #-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.6 1998/08/14 13:02:00 simonm Exp $
+# $Id: Makefile,v 1.7 1998/10/08 11:52:34 simonm Exp $
 
 TOP = ../..
 include $(TOP)/mk/boilerplate.mk
@@ -9,7 +9,8 @@ SRC_HC_OPTS += -dcore-lint
 
 packedstring001_HC_OPTS = -syslib misc
 exceptions001_HC_OPTS   = -fglasgow-exts
-stableptr002_HC_OPTS   = -fglasgow-exts
+stableptr002_HC_OPTS    = -fglasgow-exts
+list001_HC_OPTS         = -fglasgow-exts
 
 stableptr001_RUNTEST_OPTS = +RTS -K4m
 dynamic001_HC_OPTS = -syslib exts
index 38411a8..fa38c0f 100644 (file)
@@ -2,7 +2,7 @@ module Main where
 
 import Prelude hiding (catch)
 import Exception
-import IO hiding (try)
+import IO hiding (try, catch)
 
 main = do
   ioTest
@@ -18,27 +18,28 @@ ioTest = catchIO (fail (userError "wibble"))
                                     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!"
+errorTest = getException (1 + error "call to 'error'") >>= \r ->
+           case r of
+               Just exception -> putStr "error call caught\n"
+               Nothing        -> 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!")
+noMethodTest = getException (Just () + Just ()) >>= \ r ->
+       case r of
+               Just (NoMethodError err) -> putStr "no method error\n"
+               other                    -> error "help!"
 
 patMatchTest :: IO ()
-patMatchTest = catchOne (case test1 [1..10] of () -> return ())
+patMatchTest = catch (case test1 [1..10] of () -> return ())
   (\ex -> case ex of
                PatternMatchFail err -> putStr err
                other                -> error "help!")
                  
 test1 [] = ()
 
-guardTest = catchOne (case test2 of () -> return ())
+guardTest = catch (case test2 of () -> return ())
   (\ex -> case ex of
                NonExhaustiveGuards err -> putStr err
                other                -> error "help!")
index e69de29..c0af830 100644 (file)
@@ -0,0 +1,6 @@
+io exception caught
+error call caught
+no method error
+exceptions001.hs:40: Non-exhaustive patterns in function test1
+exceptions001.hs:47: Non-exhaustive guards in 
+43
\ No newline at end of file
index 48104c6..a1ea650 100644 (file)
@@ -13,19 +13,19 @@ main = do
 
   -- head
   print (head [1,2,3,4], head "a")
-  catchOne (print (head [] :: String)) (\_ -> putStr "head []\n")
+  catch (print (head [] :: String)) (\_ -> putStr "head []\n")
 
   -- tail
   print (tail [1,2,3,4], tail "a")
-  catchOne (print (tail [] :: String)) (\_ -> putStr "tail []\n")
+  catch (print (tail [] :: String)) (\_ -> putStr "tail []\n")
 
   -- init
   print (init [1,2,3,4], init "a")
-  catchOne (print (init [] :: String)) (\_ -> putStr "init []\n")
+  catch (print (init [] :: String)) (\_ -> putStr "init []\n")
 
   -- last
   print (last [1,2,3,4], last "a")
-  catchOne (print (last [] :: String)) (\_ -> putStr "last []\n")
+  catch (print (last [] :: String)) (\_ -> putStr "last []\n")
 
   -- null
   print [null [], null "abc"]
@@ -38,43 +38,43 @@ main = do
 
   -- foldl1
   print (foldl1 (+) [1..10])
-  catchOne (print (foldl1 (+) [] :: Int)) (\_ -> putStr "foldl1 []\n")
+  catch (print (foldl1 (+) [] :: Int)) (\_ -> putStr "foldl1 []\n")
 
   -- scanl
   print (scanl  (+) 1 [1..10])
 
   -- scanl1
   print (scanl1 (+) [1..10])
-  catchOne (print (scanl1 (+) [] :: [Int])) (\_ -> putStr "scanl1 []\n")
+  catch (print (scanl1 (+) [] :: [Int])) (\_ -> putStr "scanl1 []\n")
 
   -- foldr1
   print (foldr1 (+) [1..10])
-  catchOne (print (foldr1 (+) [] :: Int)) (\_ -> putStr "foldr1 []\n")
+  catch (print (foldr1 (+) [] :: Int)) (\_ -> putStr "foldr1 []\n")
 
   -- scanr
   print (scanr  (+) 1 [1..10])
 
   -- scanr1
   print (scanr1 (+) [1..10])
-  catchOne (print (scanr1 (+) [] :: [Int])) (\_ -> putStr "scanr1 []\n")
+  catch (print (scanr1 (+) [] :: [Int])) (\_ -> putStr "scanr1 []\n")
 
   -- iterate
   print (take 10 (cycle (take 4 (iterate (+1) 1))))
 
   -- take
   print (take 4 (repeat "x"), take 0 (repeat "x"), take 5 [1..4])
-  catchOne (print (take (-1) [1..10])) (\_ -> putStr "take (-1)\n")
+  catch (print (take (-1) [1..10])) (\_ -> putStr "take (-1)\n")
 
   -- replicate
   print [replicate 2 "abc", replicate 0 "abc", replicate 3 []]
 
   -- drop
   print [drop 5 [1..10], drop 0 [1..10], drop 5 [1..4]]
-  catchOne (print (drop (-1) [1..10])) (\_ -> putStr "drop (-1)\n")
+  catch (print (drop (-1) [1..10])) (\_ -> putStr "drop (-1)\n")
 
   -- splitAt
   print [splitAt 5 [1..10], splitAt 5 [1..4]]
-  catchOne (print (splitAt (-1) [1..10])) (\_ -> putStr "splitAt (-1)\n")
+  catch (print (splitAt (-1) [1..10])) (\_ -> putStr "splitAt (-1)\n")
 
   -- scan
   print (span (<5) [1..10])
@@ -108,11 +108,11 @@ main = do
 
   -- maximum
   print (maximum [1..10])
-  catchOne (print (maximum [] :: Int)) (\_ -> putStr "maximum []\n")
+  catch (print (maximum [] :: Int)) (\_ -> putStr "maximum []\n")
 
   -- minimum
   print (minimum [1..10])
-  catchOne (print (minimum [] :: Int)) (\_ -> putStr "minimum []\n")
+  catch (print (minimum [] :: Int)) (\_ -> putStr "minimum []\n")
 
   -- concatMap
   print (concatMap (:[]) [(1::Int)..10])
index 7ffce8e..3ed6a11 100644 (file)
@@ -1,3 +1,5 @@
+{-# OPTIONS -fglasgow-exts #-}
+
 module Main (main) where
 
 import Char (isSpace)