diff options
Diffstat (limited to 'testsuite/tests/lib/should_run')
90 files changed, 5447 insertions, 0 deletions
diff --git a/testsuite/tests/lib/should_run/4006.hs b/testsuite/tests/lib/should_run/4006.hs new file mode 100644 index 0000000000..662b0f62e3 --- /dev/null +++ b/testsuite/tests/lib/should_run/4006.hs @@ -0,0 +1,8 @@ +import System.Process + +testUnicode :: String -> IO String +testUnicode str = readProcess "printf" ["%s", str] "" + +main = do + testUnicode "It works here" >>= putStrLn + testUnicode "А здесь сломалось" >>= putStrLn diff --git a/testsuite/tests/lib/should_run/4006.stdout b/testsuite/tests/lib/should_run/4006.stdout new file mode 100644 index 0000000000..9db8a8ced2 --- /dev/null +++ b/testsuite/tests/lib/should_run/4006.stdout @@ -0,0 +1,2 @@ +It works here +А здесь сломалось diff --git a/testsuite/tests/lib/should_run/Makefile b/testsuite/tests/lib/should_run/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/lib/should_run/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/lib/should_run/Memo1.lhs b/testsuite/tests/lib/should_run/Memo1.lhs new file mode 100644 index 0000000000..796f6121e4 --- /dev/null +++ b/testsuite/tests/lib/should_run/Memo1.lhs @@ -0,0 +1,142 @@ +% $Id: Memo.lhs,v 1.1 2005/12/16 10:46:05 simonmar Exp $ +% +% (c) The GHC Team, 1999 +% +% Hashing memo tables. + +\begin{code} +{-# LANGUAGE CPP #-} + +module Memo1 + {-# DEPRECATED "This module is unmaintained, and will disappear soon" #-} +#ifndef __PARALLEL_HASKELL__ + ( memo -- :: (a -> b) -> a -> b + , memoSized -- :: Int -> (a -> b) -> a -> b + ) +#endif + where + +#ifndef __PARALLEL_HASKELL__ + +import System.Mem.StableName ( StableName, makeStableName, hashStableName ) +import System.Mem.Weak ( Weak, mkWeakPtr, mkWeak, deRefWeak, finalize ) +import Data.Array.IO ( IOArray, newArray, readArray, writeArray ) +import System.IO.Unsafe ( unsafePerformIO ) +import Control.Concurrent.MVar ( MVar, newMVar, putMVar, takeMVar ) +\end{code} + +----------------------------------------------------------------------------- +Memo table representation. + +The representation is this: a fixed-size hash table where each bucket +is a list of table entries, of the form (key,value). + +The key in this case is (StableName key), and we use hashStableName to +hash it. + +It's important that we can garbage collect old entries in the table +when the key is no longer reachable in the heap. Hence the value part +of each table entry is (Weak val), where the weak pointer "key" is the +key for our memo table, and 'val' is the value of this memo table +entry. When the key becomes unreachable, a finalizer will fire and +remove this entry from the hash bucket, and further attempts to +dereference the weak pointer will return Nothing. References from +'val' to the key are ignored (see the semantics of weak pointers in +the documentation). + +\begin{code} +type MemoTable key val + = MVar ( + Int, -- current table size + IOArray Int [MemoEntry key val] -- hash table + ) + +-- a memo table entry: compile with -funbox-strict-fields to eliminate +-- the boxes around the StableName and Weak fields. +data MemoEntry key val = MemoEntry !(StableName key) !(Weak val) +\end{code} + +We use an MVar to the hash table, so that several threads may safely +access it concurrently. This includes the finalization threads that +remove entries from the table. + +ToDo: Can efficiency be improved at all? + +\begin{code} +memo :: (a -> b) -> a -> b +memo f = memoSized default_table_size f + +default_table_size = 1001 + +-- Our memo functions are *strict*. Lazy memo functions tend to be +-- less useful because it is less likely you'll get a memo table hit +-- for a thunk. This change was made to match Hugs's Memo +-- implementation, and as the result of feedback from Conal Elliot +-- <conal@microsoft.com>. + +memoSized :: Int -> (a -> b) -> a -> b +memoSized size f = strict (lazyMemoSized size f) + +strict = ($!) + +lazyMemoSized :: Int -> (a -> b) -> a -> b +lazyMemoSized size f = + let (table,weak) = unsafePerformIO ( + do { tbl <- newArray (0,size) [] + ; mvar <- newMVar (size,tbl) + ; weak <- mkWeakPtr mvar (Just (table_finalizer tbl size)) + ; return (mvar,weak) + }) + in memo' f table weak + +table_finalizer :: IOArray Int [MemoEntry key val] -> Int -> IO () +table_finalizer table size = + sequence_ [ finalizeBucket i | i <- [0..size] ] + where + finalizeBucket i = do + bucket <- readArray table i + sequence_ [ finalize w | MemoEntry _ w <- bucket ] + +memo' :: (a -> b) -> MemoTable a b -> Weak (MemoTable a b) -> a -> b +memo' f ref weak_ref = \k -> unsafePerformIO $ do + stable_key <- makeStableName k + (size, table) <- takeMVar ref + let hash_key = hashStableName stable_key `mod` size + bucket <- readArray table hash_key + lkp <- lookupSN stable_key bucket + + case lkp of + Just result -> do + putMVar ref (size,table) + return result + Nothing -> do + let result = f k + weak <- mkWeak k result (Just (finalizer hash_key stable_key weak_ref)) + writeArray table hash_key (MemoEntry stable_key weak : bucket) + putMVar ref (size,table) + return result + +finalizer :: Int -> StableName a -> Weak (MemoTable a b) -> IO () +finalizer hash_key stable_key weak_ref = + do r <- deRefWeak weak_ref + case r of + Nothing -> return () + Just mvar -> do + (size,table) <- takeMVar mvar + bucket <- readArray table hash_key + let new_bucket = [ e | e@(MemoEntry sn weak) <- bucket, + sn /= stable_key ] + writeArray table hash_key new_bucket + putMVar mvar (size,table) + +lookupSN :: StableName key -> [MemoEntry key val] -> IO (Maybe val) +lookupSN sn [] = sn `seq` return Nothing -- make it strict in sn +lookupSN sn (MemoEntry sn' weak : xs) + | sn == sn' = do maybe_item <- deRefWeak weak + case maybe_item of + Nothing -> error ("dead weak pair: " ++ + show (hashStableName sn)) + Just v -> return (Just v) + | otherwise = lookupSN sn xs +#endif +\end{code} diff --git a/testsuite/tests/lib/should_run/Memo2.lhs b/testsuite/tests/lib/should_run/Memo2.lhs new file mode 100644 index 0000000000..5193ec2899 --- /dev/null +++ b/testsuite/tests/lib/should_run/Memo2.lhs @@ -0,0 +1,142 @@ +% $Id: Memo.lhs,v 1.1 2005/12/16 10:46:05 simonmar Exp $ +% +% (c) The GHC Team, 1999 +% +% Hashing memo tables. + +\begin{code} +{-# LANGUAGE CPP #-} + +module Memo2 + {-# DEPRECATED "This module is unmaintained, and will disappear soon" #-} +#ifndef __PARALLEL_HASKELL__ + ( memo -- :: (a -> b) -> a -> b + , memoSized -- :: Int -> (a -> b) -> a -> b + ) +#endif + where + +#ifndef __PARALLEL_HASKELL__ + +import System.Mem.StableName ( StableName, makeStableName, hashStableName ) +import System.Mem.Weak ( Weak, mkWeakPtr, mkWeak, deRefWeak, finalize ) +import Data.Array.IO ( IOArray, newArray, readArray, writeArray ) +import System.IO.Unsafe ( unsafePerformIO ) +import Control.Concurrent.MVar ( MVar, newMVar, putMVar, takeMVar ) +\end{code} + +----------------------------------------------------------------------------- +Memo table representation. + +The representation is this: a fixed-size hash table where each bucket +is a list of table entries, of the form (key,value). + +The key in this case is (StableName key), and we use hashStableName to +hash it. + +It's important that we can garbage collect old entries in the table +when the key is no longer reachable in the heap. Hence the value part +of each table entry is (Weak val), where the weak pointer "key" is the +key for our memo table, and 'val' is the value of this memo table +entry. When the key becomes unreachable, a finalizer will fire and +remove this entry from the hash bucket, and further attempts to +dereference the weak pointer will return Nothing. References from +'val' to the key are ignored (see the semantics of weak pointers in +the documentation). + +\begin{code} +type MemoTable key val + = MVar ( + Int, -- current table size + IOArray Int [MemoEntry key val] -- hash table + ) + +-- a memo table entry: compile with -funbox-strict-fields to eliminate +-- the boxes around the StableName and Weak fields. +data MemoEntry key val = MemoEntry !(StableName key) !(Weak val) +\end{code} + +We use an MVar to the hash table, so that several threads may safely +access it concurrently. This includes the finalization threads that +remove entries from the table. + +ToDo: Can efficiency be improved at all? + +\begin{code} +memo :: (a -> b) -> a -> b +memo f = memoSized default_table_size f + +default_table_size = 1001 + +-- Our memo functions are *strict*. Lazy memo functions tend to be +-- less useful because it is less likely you'll get a memo table hit +-- for a thunk. This change was made to match Hugs's Memo +-- implementation, and as the result of feedback from Conal Elliot +-- <conal@microsoft.com>. + +memoSized :: Int -> (a -> b) -> a -> b +memoSized size f = strict (lazyMemoSized size f) + +strict = ($!) + +lazyMemoSized :: Int -> (a -> b) -> a -> b +lazyMemoSized size f = + let (table,weak) = unsafePerformIO ( + do { tbl <- newArray (0,size) [] + ; mvar <- newMVar (size,tbl) + ; weak <- mkWeakPtr mvar (Just (table_finalizer tbl size)) + ; return (mvar,weak) + }) + in memo' f table weak + +table_finalizer :: IOArray Int [MemoEntry key val] -> Int -> IO () +table_finalizer table size = + sequence_ [ finalizeBucket i | i <- [0..size] ] + where + finalizeBucket i = do + bucket <- readArray table i + sequence_ [ finalize w | MemoEntry _ w <- bucket ] + +memo' :: (a -> b) -> MemoTable a b -> Weak (MemoTable a b) -> a -> b +memo' f ref weak_ref = \k -> unsafePerformIO $ do + stable_key <- makeStableName k + (size, table) <- takeMVar ref + let hash_key = hashStableName stable_key `mod` size + bucket <- readArray table hash_key + lkp <- lookupSN stable_key bucket + + case lkp of + Just result -> do + putMVar ref (size,table) + return result + Nothing -> do + let result = f k + weak <- mkWeak k result (Just (finalizer hash_key stable_key weak_ref)) + writeArray table hash_key (MemoEntry stable_key weak : bucket) + putMVar ref (size,table) + return result + +finalizer :: Int -> StableName a -> Weak (MemoTable a b) -> IO () +finalizer hash_key stable_key weak_ref = + do r <- deRefWeak weak_ref + case r of + Nothing -> return () + Just mvar -> do + (size,table) <- takeMVar mvar + bucket <- readArray table hash_key + let new_bucket = [ e | e@(MemoEntry sn weak) <- bucket, + sn /= stable_key ] + writeArray table hash_key new_bucket + putMVar mvar (size,table) + +lookupSN :: StableName key -> [MemoEntry key val] -> IO (Maybe val) +lookupSN sn [] = sn `seq` return Nothing -- make it strict in sn +lookupSN sn (MemoEntry sn' weak : xs) + | sn == sn' = do maybe_item <- deRefWeak weak + case maybe_item of + Nothing -> error ("dead weak pair: " ++ + show (hashStableName sn)) + Just v -> return (Just v) + | otherwise = lookupSN sn xs +#endif +\end{code} diff --git a/testsuite/tests/lib/should_run/addr001.hs b/testsuite/tests/lib/should_run/addr001.hs new file mode 100644 index 0000000000..436a066063 --- /dev/null +++ b/testsuite/tests/lib/should_run/addr001.hs @@ -0,0 +1,10 @@ +-- !!! Testing that Show for Addr is OK.. +module Main(main) where + +import Foreign.Ptr + +main :: IO () +main = do + print (nullPtr `plusPtr` maxBound) + print (nullPtr `plusPtr` minBound) + diff --git a/testsuite/tests/lib/should_run/addr001.stdout b/testsuite/tests/lib/should_run/addr001.stdout new file mode 100644 index 0000000000..e098b1be49 --- /dev/null +++ b/testsuite/tests/lib/should_run/addr001.stdout @@ -0,0 +1,2 @@ +0x7fffffff +0x80000000 diff --git a/testsuite/tests/lib/should_run/addr001.stdout-alpha-dec-osf3 b/testsuite/tests/lib/should_run/addr001.stdout-alpha-dec-osf3 new file mode 100644 index 0000000000..f38ea71861 --- /dev/null +++ b/testsuite/tests/lib/should_run/addr001.stdout-alpha-dec-osf3 @@ -0,0 +1,2 @@ +0x7fffffffffffffff +0x8000000000000000 diff --git a/testsuite/tests/lib/should_run/addr001.stdout-mips-sgi-irix b/testsuite/tests/lib/should_run/addr001.stdout-mips-sgi-irix new file mode 100644 index 0000000000..f38ea71861 --- /dev/null +++ b/testsuite/tests/lib/should_run/addr001.stdout-mips-sgi-irix @@ -0,0 +1,2 @@ +0x7fffffffffffffff +0x8000000000000000 diff --git a/testsuite/tests/lib/should_run/addr001.stdout-ws-64 b/testsuite/tests/lib/should_run/addr001.stdout-ws-64 new file mode 100644 index 0000000000..f38ea71861 --- /dev/null +++ b/testsuite/tests/lib/should_run/addr001.stdout-ws-64 @@ -0,0 +1,2 @@ +0x7fffffffffffffff +0x8000000000000000 diff --git a/testsuite/tests/lib/should_run/addr001.stdout-x86_64-unknown-openbsd b/testsuite/tests/lib/should_run/addr001.stdout-x86_64-unknown-openbsd new file mode 100644 index 0000000000..f38ea71861 --- /dev/null +++ b/testsuite/tests/lib/should_run/addr001.stdout-x86_64-unknown-openbsd @@ -0,0 +1,2 @@ +0x7fffffffffffffff +0x8000000000000000 diff --git a/testsuite/tests/lib/should_run/all.T b/testsuite/tests/lib/should_run/all.T new file mode 100644 index 0000000000..502f868e7f --- /dev/null +++ b/testsuite/tests/lib/should_run/all.T @@ -0,0 +1,70 @@ +test('array001', normal, compile_and_run, ['']) + +test('char001', normal, compile_and_run, ['']) +test('char002', normal, compile_and_run, ['']) + +test('cstring001', normal, compile_and_run, ['']) + +test('length001', + # This fails without -O, as it relies on a RULE being applied + expect_fail_for(['normal', 'threaded1', 'llvm']), + compile_and_run, + ['']) + +test('ratio001', normal, compile_and_run, ['']) + +test('rand001', reqlib('random'), compile_and_run, ['']) +test('reads001', normal, compile_and_run, ['']) +test('show001', normal, compile_and_run, ['']) +test('text001', normal, compile_and_run, ['']) + +test('tup001', normal, compile_and_run, ['']) + +test('addr001', normal, compile_and_run, ['']) +test('dynamic001', normal, compile_and_run, ['']) +test('dynamic002', normal, compile_and_run, ['']) +test('dynamic003', extra_run_opts('+RTS -K32m -RTS'), compile_and_run, ['']) +test('dynamic004', normal, compile_and_run, ['']) +test('dynamic005', normal, compile_and_run, ['']) +test('enum01', skip_if_fast, compile_and_run, ['-cpp']) +test('enum02', skip_if_fast, compile_and_run, ['-cpp']) +test('enum03', skip_if_fast, compile_and_run, ['-cpp']) +test('enum04', normal, compile_and_run, ['']) +test('exceptionsrun001', normal, compile_and_run, ['']) +test('exceptionsrun002', normal, compile_and_run, ['']) +test('list001' , skip_if_fast, compile_and_run, ['']) +test('list002', skip_if_fast, compile_and_run, ['']) +test('list003', skip_if_fast, compile_and_run, ['']) + +test('memo001', + [skip_if_fast, + extra_run_opts('+RTS -A10k -RTS'), + extra_clean(['Memo1.hi', 'Memo1.o'])], + multimod_compile_and_run, + ['memo001','']) + +test('memo002', + [skip_if_fast, + extra_run_opts('20'), + extra_clean(['Memo2.hi', 'Memo2.o'])], + multimod_compile_and_run, ['memo002','']) + +test('packedstring001', reqlib('packedstring'), compile_and_run, ['-package packedstring']) + +test('stableptr001', + [skip_if_fast, extra_run_opts('+RTS -K8m -RTS')], + compile_and_run, ['']) +test('stableptr003', normal, compile_and_run, ['']) +test('stableptr004', extra_run_opts('+RTS -K4m -RTS'), compile_and_run, ['']) +test('stableptr005', normal, compile_and_run, ['']) + +test('weak001', normal, compile_and_run, ['']) + +# In the 65001 codepage, we can't even cat the expected output on msys: +# $ cat 4006.stdout +# It works here +# cat: write error: Permission denied +# Seems to be a known problem, e.g. +# http://mingw-users.1079350.n2.nabble.com/Bug-re-Unicode-on-the-console-td3121717.html +test('4006', if_msys(expect_fail), compile_and_run, ['']) + diff --git a/testsuite/tests/lib/should_run/array001.hs b/testsuite/tests/lib/should_run/array001.hs new file mode 100644 index 0000000000..b5839b9d53 --- /dev/null +++ b/testsuite/tests/lib/should_run/array001.hs @@ -0,0 +1,34 @@ +-- !!! Testing that #4827 is fixed (hPutArray/hGetArray use count argument) +module Main(main) where + +import Control.Monad + +import Data.Array.MArray +import Data.Array.IO + +import System.IO + +main :: IO () +main = do + the_array <- newListArray (0, 11) [1..12] + + -- Write out almost all of the array + h_out <- openBinaryFile "array001.data" WriteMode + hPutArray h_out the_array 11 + hClose h_out + + + the_array <- newListArray (0, 11) [0 | i <- [1..12]] + + -- Read in almost all of the array + h_in <- openBinaryFile "array001.data" ReadMode + wrote_size <- hFileSize h_in + hGetArray h_in the_array 10 + hClose h_in + + + read_elems <- getElems the_array + + + print wrote_size -- Bytes written, should == 11 + print read_elems -- Bytes read, should match written array in first 10 bytes, be 0 afterwards diff --git a/testsuite/tests/lib/should_run/array001.stdout b/testsuite/tests/lib/should_run/array001.stdout new file mode 100644 index 0000000000..7c9b768654 --- /dev/null +++ b/testsuite/tests/lib/should_run/array001.stdout @@ -0,0 +1,2 @@ +11 +[1,2,3,4,5,6,7,8,9,10,0,0] diff --git a/testsuite/tests/lib/should_run/char001.hs b/testsuite/tests/lib/should_run/char001.hs new file mode 100644 index 0000000000..2fb0edce0f --- /dev/null +++ b/testsuite/tests/lib/should_run/char001.hs @@ -0,0 +1,43 @@ +-- !!! Testing the behaviour of Char.lexLitChar a little.. + +-- [March 2003] We now allow \X and \O as escapes although the +-- spec only permits \x and \o. Seems more consistent. + +module Main where + +import Data.Char + +lex' str = do + putStr ("lex " ++ str ++ " = ") + print (lex str) + +hexes = do + lex' "'\\X00'" + lex' "'\\x0f2'" + lex' "'\\xf2'" + lex' "'\\xf2t'" + lex' "'\\X24'" + lex' "'\\x24b'" + lex' "'\\Xa4b'" + lex' "'\\xa4bg'" + +octs = do + lex' "'\\o00'" + lex' "'\\o05'" + lex' "'\\o50'" + lex' "'\\o72'" + lex' "'\\o82'" + lex' "'\\O24'" + lex' "'\\O000024'" + lex' "'\\024b'" + lex' "'\\o14b'" + lex' "'\\0a4bg'" + +main = do + hexes + octs + + + + + diff --git a/testsuite/tests/lib/should_run/char001.stdout b/testsuite/tests/lib/should_run/char001.stdout new file mode 100644 index 0000000000..0c13ac7c03 --- /dev/null +++ b/testsuite/tests/lib/should_run/char001.stdout @@ -0,0 +1,18 @@ +lex '\X00' = [("'\\X00'","")] +lex '\x0f2' = [("'\\x0f2'","")] +lex '\xf2' = [("'\\xf2'","")] +lex '\xf2t' = [] +lex '\X24' = [("'\\X24'","")] +lex '\x24b' = [("'\\x24b'","")] +lex '\Xa4b' = [("'\\Xa4b'","")] +lex '\xa4bg' = [] +lex '\o00' = [("'\\o00'","")] +lex '\o05' = [("'\\o05'","")] +lex '\o50' = [("'\\o50'","")] +lex '\o72' = [("'\\o72'","")] +lex '\o82' = [] +lex '\O24' = [("'\\O24'","")] +lex '\O000024' = [("'\\O000024'","")] +lex '\024b' = [] +lex '\o14b' = [] +lex '\0a4bg' = [] diff --git a/testsuite/tests/lib/should_run/char002.hs b/testsuite/tests/lib/should_run/char002.hs new file mode 100644 index 0000000000..60b8b03cda --- /dev/null +++ b/testsuite/tests/lib/should_run/char002.hs @@ -0,0 +1,7 @@ +-- !!! tests for large character values in literals +import Data.Char +main = do + print (ord '\xffff') + print (ord '\o7777') + print (ord '\65535') + print (map ord "\xffff\o7777\65535") diff --git a/testsuite/tests/lib/should_run/char002.stdout b/testsuite/tests/lib/should_run/char002.stdout new file mode 100644 index 0000000000..5190ad9c53 --- /dev/null +++ b/testsuite/tests/lib/should_run/char002.stdout @@ -0,0 +1,4 @@ +65535 +4095 +65535 +[65535,4095,65535] diff --git a/testsuite/tests/lib/should_run/cstring001.hs b/testsuite/tests/lib/should_run/cstring001.hs new file mode 100644 index 0000000000..38d0d25db2 --- /dev/null +++ b/testsuite/tests/lib/should_run/cstring001.hs @@ -0,0 +1,18 @@ +import Control.Monad +import Foreign.C.String + +test_strings = ["Hello World", replicate 10000 'a'] + +assertEqual :: (Eq a, Show a) => a -> a -> IO () +assertEqual x y = if x == y then return () else error $ "assertEqual: " ++ show x ++ " /= " ++ show y + +main = do + -- Try roundtripping some ASCII strings through the locale encoding + forM test_strings $ \try_str -> do + got_str <- withCString try_str peekCString + got_str `assertEqual` try_str + + -- Try roundtripping some ASCII strings with lengths through the locale encoding + forM test_strings $ \try_str -> do + got_str <- withCStringLen try_str peekCStringLen + got_str `assertEqual` try_str diff --git a/testsuite/tests/lib/should_run/dynamic001.hs b/testsuite/tests/lib/should_run/dynamic001.hs new file mode 100644 index 0000000000..7a3fd515e9 --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic001.hs @@ -0,0 +1,107 @@ +-- !!! Dynamic library regression tests +module Main(main) where + +import Data.Dynamic + +main :: IO () +main = do + test "toDyn" toDyn_list + testIO "fromDyn" fromDyn_test + +toDyn_list :: [Dynamic] +toDyn_list = + [ toDyn (1::Int) + , toDyn ('a') + , toDyn False + , toDyn ((-1.0)::Float) + , toDyn (0.0::Double) + , toDyn (1394::Integer) + , toDyn (print "hello") + , toDyn toDyn_list + , toDyn ([]::[Int]) + , toDyn (Nothing :: Maybe Int) + , toDyn ((Just 2) :: Maybe Int) + , toDyn ((Just 2) :: Maybe Int) + , toDyn ((Left 3) :: Either Int Bool) + , toDyn ((Right 3) :: Either Char Int) + , toDyn () + , toDyn LT + , toDyn ((),2::Int) + , toDyn ((),2::Int,'a') + , toDyn ((),2::Int,'a',1.0::Double) + , toDyn ((),2::Int,'a',1.0::Double,Nothing::Maybe Bool) + , toDyn ((+) :: Int -> Int -> Int) + , toDyn ((+) :: Integer -> Integer -> Integer) + , toDyn ((++) :: [Char] -> [Char] -> [Char]) + ] + +-- Testing the conversion from Dynamic values: +fromDyn_test :: IO () +fromDyn_test = do + print (fromDyn (toDyn (1::Int)) (0::Int)) + print (fromDyn (toDyn ('a'::Char)) (0::Int)) + print (fromDyn (toDyn 'a') 'b') + print (fromDyn (toDyn (1::Float)) (0::Float)) + print (fromDyn (toDyn (2::Float)) (0::Int)) + print (fromDyn (toDyn (3::Double)) (0::Double)) + print (fromDyn (toDyn (4::Double)) (0::Int)) + print (fromDyn (toDyn (5::Integer)) (0::Integer)) + print (fromDyn (toDyn (6::Integer)) False) + print (fromDyn (toDyn [1,3,5::Integer]) ([]::[Integer])) + print (fromDyn (toDyn (Just True)) (Nothing::Maybe Bool)) + print (fromDyn (toDyn (Left True::Either Bool Bool)) (Right False :: Either Bool Bool)) + print (fromDyn (toDyn LT) GT) + print (fromDyn (toDyn ((+1)::Int->Int)) False) + print ((fromDyn (toDyn ((+1)::Int->Int)) ((+2)::Int->Int)) 3) + print ((fromDyn (toDyn ((++)::[Int]->[Int]->[Int])) ((undefined)::[Int]->[Int]->[Int])) [1] [2]) + + +-- Misc test utilities: +test :: Show a => String -> [a] -> IO () +test str ls = do + putStrLn ("*** Testing: " ++ str ++ " ***") + putStrLn (showListLn ls) + +testIO :: String -> IO () -> IO () +testIO str tst = do + putStrLn ("*** Testing: " ++ str ++ " ***") + tst + + +-- showListLn presents a list in a diff-friendly format. +-- showListLn [a1,..an] +-- => +-- [ a1 +-- , a2 +-- .. +-- , an +-- ] +-- +showListLn :: Show a => [a] -> String +showListLn [] = "" +showListLn ls = '[' : ' ' : go ls + where + go [x] = show x ++ "\n]" + go (x:xs) = show x ++ '\n':',':' ':go xs + +{- +test8 = toDyn (mkAppTy listTc) +test9 :: Float +test9 = fromDyn test8 0 + +printf :: String -> [Dynamic] -> IO () +printf str args = putStr (decode str args) + where + decode [] [] = [] + decode ('%':'n':cs) (d:ds) = + (\ v -> show v++decode cs ds) (fromDyn d (0::Int)) + decode ('%':'c':cs) (d:ds) = + (\ v -> show v++decode cs ds) (fromDyn d ('\0')) + decode ('%':'b':cs) (d:ds) = + (\ v -> show v++decode cs ds) (fromDyn d (False::Bool)) + decode (x:xs) ds = x:decode xs ds + +test10 :: IO () +test10 = printf "%n = %c, that much is %b\n" [toDyn (3::Int),toDyn 'a', toDyn False] + +-} diff --git a/testsuite/tests/lib/should_run/dynamic001.stdout b/testsuite/tests/lib/should_run/dynamic001.stdout new file mode 100644 index 0000000000..c2d365a7c6 --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic001.stdout @@ -0,0 +1,42 @@ +*** Testing: toDyn *** +[ <<Int>> +, <<Char>> +, <<Bool>> +, <<Float>> +, <<Double>> +, <<Integer>> +, <<IO ()>> +, <<[Dynamic]>> +, <<[Int]>> +, <<Maybe Int>> +, <<Maybe Int>> +, <<Maybe Int>> +, <<Either Int Bool>> +, <<Either Char Int>> +, <<()>> +, <<Ordering>> +, <<((),Int)>> +, <<((),Int,Char)>> +, <<((),Int,Char,Double)>> +, <<((),Int,Char,Double,(Maybe Bool))>> +, <<Int -> Int -> Int>> +, <<Integer -> Integer -> Integer>> +, <<[Char] -> [Char] -> [Char]>> +] +*** Testing: fromDyn *** +1 +0 +'a' +1.0 +0 +3.0 +0 +5 +False +[1,3,5] +Just True +Left True +LT +False +4 +[1,2] diff --git a/testsuite/tests/lib/should_run/dynamic002.hs b/testsuite/tests/lib/should_run/dynamic002.hs new file mode 100644 index 0000000000..6d53d2ed1e --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic002.hs @@ -0,0 +1,91 @@ +-- !!! Testing Typeable instances +module Main(main) where + +import Data.Dynamic +import Data.Array +import Data.Array.MArray +import Data.Array.ST +import Data.Array.IO +import Data.Array.Unboxed +import Data.Complex +import Data.Int +import Data.Word +import Data.IORef +import System.IO +import Control.Monad.ST +import System.Mem.StableName +import System.Mem.Weak +import Foreign.StablePtr +import Control.Exception +import Foreign.C.Types + +main :: IO () +main = do + print (typeOf (undefined :: [()])) + print (typeOf (undefined :: ())) + print (typeOf (undefined :: ((),()))) + print (typeOf (undefined :: ((),(),()))) + print (typeOf (undefined :: ((),(),(),()))) + print (typeOf (undefined :: ((),(),(),(),()))) + print (typeOf (undefined :: (() -> ()))) + print (typeOf (undefined :: (Array () ()))) + print (typeOf (undefined :: Bool)) + print (typeOf (undefined :: Char)) + print (typeOf (undefined :: (Complex ()))) + print (typeOf (undefined :: Double)) + print (typeOf (undefined :: (Either () ()))) + print (typeOf (undefined :: Float)) + print (typeOf (undefined :: Handle)) + print (typeOf (undefined :: Int)) + print (typeOf (undefined :: Integer)) + print (typeOf (undefined :: IO ())) + print (typeOf (undefined :: (Maybe ()))) + print (typeOf (undefined :: Ordering)) + + print (typeOf (undefined :: Dynamic)) + print (typeOf (undefined :: (IORef ()))) + print (typeOf (undefined :: Int8)) + print (typeOf (undefined :: Int16)) + print (typeOf (undefined :: Int32)) + print (typeOf (undefined :: Int64)) + print (typeOf (undefined :: (ST () ()))) + print (typeOf (undefined :: (StableName ()))) + print (typeOf (undefined :: (StablePtr ()))) + print (typeOf (undefined :: TyCon)) + print (typeOf (undefined :: TypeRep)) + print (typeOf (undefined :: Word8)) + print (typeOf (undefined :: Word16)) + print (typeOf (undefined :: Word32)) + print (typeOf (undefined :: Word64)) + + print (typeOf (undefined :: ArithException)) + print (typeOf (undefined :: AsyncException)) + print (typeOf (undefined :: (IOArray () ()))) + print (typeOf (undefined :: (IOUArray () ()))) + print (typeOf (undefined :: (STArray () () ()))) + print (typeOf (undefined :: (STUArray () () ()))) + print (typeOf (undefined :: (StableName ()))) + print (typeOf (undefined :: (StablePtr ()))) + print (typeOf (undefined :: (UArray () ()))) + print (typeOf (undefined :: (Weak ()))) + + print (typeOf (undefined :: CChar)) + print (typeOf (undefined :: CSChar)) + print (typeOf (undefined :: CUChar)) + print (typeOf (undefined :: CShort)) + print (typeOf (undefined :: CUShort)) + print (typeOf (undefined :: CInt)) + print (typeOf (undefined :: CUInt)) + print (typeOf (undefined :: CLong)) + print (typeOf (undefined :: CULong)) + print (typeOf (undefined :: CLLong)) + print (typeOf (undefined :: CULLong)) + print (typeOf (undefined :: CFloat)) + print (typeOf (undefined :: CDouble)) + + print (typeOf (undefined :: CPtrdiff)) + print (typeOf (undefined :: CSize)) + print (typeOf (undefined :: CWchar)) + print (typeOf (undefined :: CSigAtomic)) + print (typeOf (undefined :: CClock)) + print (typeOf (undefined :: CTime)) diff --git a/testsuite/tests/lib/should_run/dynamic002.stdout b/testsuite/tests/lib/should_run/dynamic002.stdout new file mode 100644 index 0000000000..8b55566ada --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic002.stdout @@ -0,0 +1,64 @@ +[()] +() +((),()) +((),(),()) +((),(),(),()) +((),(),(),(),()) +() -> () +Array () () +Bool +Char +Complex () +Double +Either () () +Float +Handle +Int +Integer +IO () +Maybe () +Ordering +Dynamic +IORef () +Int8 +Int16 +Int32 +Int64 +ST () () +StableName () +StablePtr () +TyCon +TypeRep +Word8 +Word16 +Word32 +Word64 +ArithException +AsyncException +IOArray () () +IOUArray () () +STArray () () () +STUArray () () () +StableName () +StablePtr () +UArray () () +Weak () +CChar +CSChar +CUChar +CShort +CUShort +CInt +CUInt +CLong +CULong +CLLong +CULLong +CFloat +CDouble +CPtrdiff +CSize +CWchar +CSigAtomic +CClock +CTime diff --git a/testsuite/tests/lib/should_run/dynamic003.hs b/testsuite/tests/lib/should_run/dynamic003.hs new file mode 100644 index 0000000000..fae8bdb276 --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic003.hs @@ -0,0 +1,12 @@ +module Main where + +-- Test generation of large TypeReps +-- (can be used as a benchmark) + +import Data.Typeable + +f :: Typeable a => Int -> a -> TypeRep +f 0 a = typeOf a +f n a = f (n-1) [a] + +main = print (f 50000 () == f 50001 ()) diff --git a/testsuite/tests/lib/should_run/dynamic003.stdout b/testsuite/tests/lib/should_run/dynamic003.stdout new file mode 100644 index 0000000000..bc59c12aa1 --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic003.stdout @@ -0,0 +1 @@ +False diff --git a/testsuite/tests/lib/should_run/dynamic004.hs b/testsuite/tests/lib/should_run/dynamic004.hs new file mode 100644 index 0000000000..e6b7a82bfd --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic004.hs @@ -0,0 +1,36 @@ +module Main where + +import Data.Typeable +import Data.Typeable.Internal +import GHC.Fingerprint +import Text.Printf + +f :: Typeable a => Int -> a -> [TypeRep] +f 0 a = [] +f n a = typeOf a : f (n-1) [a] + +-- pointwise compare 1000x1001 TypeReps, there should be exactly 1000 equalities +-- (can be used as a benchmark) +main = print $ length [ t1 | t1 <- f 1000 (), t2 <- f 1001 (), t1 == t2 ] + +{- + DEBUGGING code to help find bugs in the TypeRep implementation when + this test fails: + + where + g (x:xs) (y:ys) + | x == y = g xs ys + | otherwise = do + print x + case x of + TypeRep f1 (TyCon f2 _ _ _) [TypeRep f3 _ _] -> + printf "f1: %s\nf2: %s\nf3: %s\n" (show_fp f1) (show_fp f2) (show_fp f3) + case y of + TypeRep f1 (TyCon f2 _ _ _) [TypeRep f3 _ _] -> + printf "f1: %s\nf2: %s\nf3: %s\n" (show_fp f1) (show_fp f2) (show_fp f3) + g _ _ = return () + + show_fp :: Fingerprint -> String + show_fp (Fingerprint h l) = + printf "%x %x" h l +-} diff --git a/testsuite/tests/lib/should_run/dynamic004.stdout b/testsuite/tests/lib/should_run/dynamic004.stdout new file mode 100644 index 0000000000..83b33d238d --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic004.stdout @@ -0,0 +1 @@ +1000 diff --git a/testsuite/tests/lib/should_run/dynamic005.hs b/testsuite/tests/lib/should_run/dynamic005.hs new file mode 100644 index 0000000000..e90aeea960 --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic005.hs @@ -0,0 +1,14 @@ +module Main where + +import Data.Typeable + +f :: Typeable a => Int -> a -> [TypeRep] +f 0 a = [] +f n a = typeOf a : f (n-1) [a] + +-- pointwise compare 1000x1000 different TypeReps, there should be no equalities +-- (can be used as a benchmark) + +main = print $ length [ t1 | t1 <- replicate 1000 (f 10 ()), + t2 <- replicate 1000 (f 10 'a'), + t1 == t2 ] diff --git a/testsuite/tests/lib/should_run/dynamic005.stdout b/testsuite/tests/lib/should_run/dynamic005.stdout new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/testsuite/tests/lib/should_run/dynamic005.stdout @@ -0,0 +1 @@ +0 diff --git a/testsuite/tests/lib/should_run/enum01.hs b/testsuite/tests/lib/should_run/enum01.hs new file mode 100644 index 0000000000..d8178667eb --- /dev/null +++ b/testsuite/tests/lib/should_run/enum01.hs @@ -0,0 +1,526 @@ +-- !!! Testing the Prelude's Enum instances. +module Main(main) where + +import Control.Exception +import Prelude hiding (catch) +import Data.Char +import Data.Ratio + +main = do + -- Enum Int + putStrLn "Testing Enum Int: " + testEnumInt + -- Enum Integer + putStrLn "Testing Enum Integer: " + testEnumInteger + -- Enum Char + putStrLn "Testing Enum Char: " + testEnumChar + -- Enum () + putStrLn "Testing Enum (): " + testEnumUnit + -- Enum Ordering + putStrLn "Testing Enum Ordering (derived): " + testEnumOrdering + -- Enum Bool + putStrLn "Testing Enum Bool: " + testEnumBool + -- Enum Rational + putStrLn "Testing Enum Rational: " + testEnumRational + -- Enum (Ratio Int) + putStrLn "Testing Enum (Ratio Int): " + testEnumRatioInt + +{- + Here's the properties that's supposed to + hold for arithmetic sequences over Int: + + - [e1..] = [e1, (e1+1), (e1+2), ..., maxBound] + + - [e1,e2..] = [e1, (e1+i), (e1+2*i), ... upper] + where + i = e2 - e1 + upper + | i > 0 = maxBound + | i < 0 = minBound + | i == 0 = maxBound -- this really shouldn't matter (I feel.) + - [e1..e3] = [e1, (e1+i), (e1+2*i),..e3] + where + i + | e3 >= e1 = 1 + | e3 < e1 = (-1) + + - [e1,e2..e3] = res + where + i = e2 - e1 + + res + | i >= 0 && e3 < e1 = [] + | i < 0 && e3 >= e1 = [] -- (*) + | otherwise = [e1, (e1+i), (e1 + 2*i), .. e3] + + Note: + (*) - I think this instead should be (i < 0 && e3 > e1), since, as is, + + [x,(x+1) ..x] = [x] + [x,(x-1) ..x] = [] + + which does not look right, symmetrically speaking. + + + The same properties hold for other Prelude types that + are instances of Enum as well as being Bounded. + + For non-Bounded types (e.g., Float and Double), the properties are similar, + except that the boundary tests become slightly different, i.e., when an + element becomes greater than (e3 + i/2) (or less than (e3 + i/2) for negative + i.) + + Q - does [(x::Double)..] have an upper bound? (ditto for Float.) + + OK - on with the regression testing. +-} + +#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) }) + + +testEnumInt :: IO () +testEnumInt = do + -- succ + printTest ((succ (0::Int))) + printTest ((succ (minBound::Int))) + mayBomb (printTest ((succ (maxBound::Int)))) + + -- pred + printTest (pred (1::Int)) + printTest (pred (maxBound::Int)) + mayBomb (printTest (pred (minBound::Int))) + + -- toEnum + printTest ((map (toEnum::Int->Int) [1,minBound,maxBound])) + + -- fromEnum + printTest ((map fromEnum [(1::Int),minBound,maxBound])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Int)..])) + printTest ((take 7 [((maxBound::Int)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Int),2..])) + printTest ((take 7 [(1::Int),7..])) + printTest ((take 7 [(1::Int),1..])) + printTest ((take 7 [(1::Int),0..])) + printTest ((take 7 [(5::Int),2..])) + let x = (minBound::Int) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Int) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Int) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- Test overflow conditions + printTest (([minBound::Int,1..])) + printTest (([minBound::Int,0..])) + printTest (([minBound::Int,-1..])) + printTest (([maxBound::Int,1..])) + printTest (([maxBound::Int,0..])) + printTest (([maxBound::Int,-1..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Int) .. 5]))) + printTest ((take 4 ([(1::Int) .. 1]))) + printTest ((take 7 ([(1::Int) .. 0]))) + printTest ((take 7 ([(5::Int) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Int)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Int)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Int),4..1])) + printTest ((take 7 [(5::Int),3..1])) + printTest ((take 7 [(5::Int),3..2])) + printTest ((take 7 [(1::Int),2..1])) + printTest ((take 7 [(2::Int),1..2])) + printTest ((take 7 [(2::Int),1..1])) + printTest ((take 7 [(2::Int),3..1])) + + -- Test overflow conditions + printTest (([minBound, 1..maxBound::Int])) + printTest (([minBound, 0..maxBound::Int])) + printTest (([minBound,-1..maxBound::Int])) + printTest (([minBound,-1..maxBound-1::Int])) + printTest (([minBound,-1..maxBound-2::Int])) + + printTest (([maxBound, 1..minBound::Int])) + printTest (([maxBound, 0..minBound::Int])) + printTest (([maxBound, 0..minBound+1::Int])) + printTest (([maxBound, 0..minBound+2::Int])) + printTest (([maxBound,-1..minBound::Int])) + + let x = (maxBound::Int) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Int) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + +testEnumChar :: IO () +testEnumChar = do + -- succ + printTest ((succ 'a')) + printTest ((succ (minBound::Char))) + mayBomb (printTest ((succ (maxBound::Char)))) + + -- pred + printTest ((pred 'b')) + printTest (pred (maxBound::Char)) + mayBomb (printTest (pred (minBound::Char))) + + -- toEnum + printTest ((map (toEnum::Int->Char) [123,ord (minBound::Char), ord(maxBound::Char)])) + mayBomb (printTest ((toEnum::Int->Char) (minBound::Int))) + + -- fromEnum + printTest ((map fromEnum ['X',minBound,maxBound])) + + -- [x..] aka enumFrom + -- printTest ((take 7 ['\NUL' .. ])) + do{ putStr ( " " ++ "(take 7 ['\\NUL' .. ])" ++ " = " ) ; print (take 7 ['\NUL' .. ]) } + -- printTest ((take 7 ['\250' .. ])) + do{ putStr ( " " ++ "(take 7 ['\\250' .. ])" ++ " = " ) ; print (take 7 ['\250' .. ]) } + + -- [x,y..] aka enumFromThen + printTest ((take 7 ['a','b'..])) + printTest ((take 7 ['a','e'..])) + printTest ((take 7 ['a','a'..])) + printTest ((take 7 ['z','y'..])) + printTest ((take 7 ['z','v'..])) + let x = '\1' + -- printTest ((take 7 ['\1', '\0' ..])) + do{ putStr ( " " ++ "(take 7 ['\\1', '\\0' ..])" ++ " = " ) ; print (take 7 ['\1', '\0' ..]) } + let x = '\5' + -- printTest ((take 7 ['\5', '\4' ..])) + do{ putStr ( " " ++ "(take 7 ['\\5', '\\4' ..])" ++ " = " ) ; print (take 7 ['\5', '\4' ..]) } + let x = (maxBound::Int) - 5 + -- printTest ((take 7 ['\250', '\251' ..])) + do{ putStr ( " " ++ "(take 7 ['\\250', '\\251' ..])" ++ " = " ) ; print (take 7 ['\250', '\251' ..]) } + + -- [x..y] aka enumFromTo + printTest ((take 7 (['a' .. 'e']))) + printTest ((take 4 (['a' .. 'a']))) + printTest ((take 7 (['b' .. 'a']))) + printTest ((take 7 (['e' .. 'a']))) + -- printTest ((take 7 (['\250' .. '\255']))) + do{ putStr ( " " ++ "(take 7 (['\\250' .. '\\255']))" ++ " = " ) ; print (take 7 (['\250' .. '\255'])) } + -- printTest ((take 7 (['\5' .. '\0']))) + do{ putStr ( " " ++ "(take 7 (['\\5' .. '\\0']))" ++ " = " ) ; print (take 7 (['\5' .. '\0'])) } + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 ['f','e' .. 'b'])) + printTest ((take 7 ['g','e' .. 'b'])) + printTest ((take 7 ['g','d' .. 'c'])) + printTest ((take 7 ['b','c' .. 'b'])) + printTest ((take 7 ['c','b' .. 'c'])) + printTest ((take 7 ['c','b' .. 'b'])) + printTest ((take 7 ['c','d' .. 'b'])) + -- printTest ((take 7 ['\251', '\252' .. maxBound])) + do{ putStr ( " " ++ "(take 7 ['\\251', '\\252' .. maxBound])" ++ " = " ) ; print (take 7 ['\251', '\252' .. maxBound]) } + -- printTest ((take 7 ['\5', '\4' .. minBound])) + do{ putStr ( " " ++ "(take 7 ['\\5', '\\4' .. minBound])" ++ " = " ) ; print (take 7 ['\5', '\4' .. minBound]) } + + +testEnumUnit :: IO () +testEnumUnit = do + -- succ: + mayBomb (printTest ((succ ()))) + mayBomb (printTest ((succ (minBound::())))) + mayBomb (printTest ((succ (maxBound::())))) + + -- pred: + mayBomb (printTest ((pred ()))) + mayBomb (printTest ((pred (minBound::())))) + mayBomb (printTest ((pred (maxBound::())))) + + -- toEnum: + printTest ((toEnum 0)::()) + mayBomb (printTest ((toEnum 1)::())) + + -- fromEnum: + printTest ((fromEnum ())) + + -- enumFrom: + printTest ((take 7 [()..])) + + -- enumFromThen: + printTest ((take 7 [(),()..])) + + -- enumFromTo + printTest ((take 7 [()..()])) + + -- enumFromThenTo + printTest ((take 7 [(),()..()])) + +testEnumOrdering :: IO () +testEnumOrdering = do + -- succ: + printTest ((succ LT)) + printTest ((succ (minBound::Ordering))) + mayBomb (printTest ((succ (maxBound::Ordering)))) + + -- pred: + printTest ((pred GT)) + printTest ((pred (maxBound::Ordering))) + mayBomb (printTest ((pred (minBound::Ordering)))) + + -- toEnum: + printTest ((toEnum 0)::Ordering) + mayBomb (printTest ((toEnum 5)::Ordering)) + + -- fromEnum: + printTest ((fromEnum LT)) + printTest ((fromEnum EQ)) + printTest ((fromEnum GT)) + + -- enumFrom: + printTest (([LT ..])) + printTest (([EQ ..])) + printTest (([GT ..])) + + -- enumFromThen: + printTest (([LT,EQ ..])) + printTest (([EQ,GT ..])) + printTest (([EQ,LT ..])) + printTest (([LT,GT ..])) + printTest (([GT,LT ..])) + printTest (take 7 (([GT,GT ..]))) + printTest (take 7 (([LT,LT ..]))) + + -- enumFromTo + printTest (([LT .. GT])) + printTest (([LT .. EQ])) + printTest (([LT .. LT])) + printTest (([GT .. LT])) + printTest (([GT .. EQ])) + printTest (([GT .. GT])) + + -- enumFromThenTo + printTest (([LT,EQ .. GT])) + printTest (([GT,EQ .. LT])) + printTest (([GT,EQ .. EQ])) + printTest (([GT,EQ .. GT])) + printTest (([GT,EQ .. LT])) + printTest (([LT,EQ .. LT])) + printTest (([LT,EQ .. GT])) + printTest (take 7 (([LT,LT .. GT]))) + printTest (take 7 (([GT,GT .. LT]))) + +testEnumBool :: IO () +testEnumBool = do + -- succ: + printTest ((succ False)) + printTest ((succ (minBound::Bool))) + mayBomb (printTest ((succ (maxBound::Bool)))) + + -- pred: + printTest ((pred True)) + printTest ((pred (maxBound::Bool))) + mayBomb (printTest ((pred (minBound::Bool)))) + + -- toEnum: + printTest ((toEnum 0)::Bool) + mayBomb (printTest ((toEnum 5)::Bool)) + + -- fromEnum: + printTest ((fromEnum False)) + printTest ((fromEnum True)) + + -- enumFrom: + printTest (([False ..])) + printTest (([True ..])) + + -- enumFromThen: + printTest (([False,True ..])) + printTest (([True,False ..])) + printTest ((take 7 ([False,False ..]))) + printTest ((take 7 ([True,True ..]))) + + -- enumFromTo + printTest (([False .. True])) + printTest (([True .. False])) + + -- enumFromThenTo + printTest (take 7 ([False,False .. False])) + printTest (take 7 ([False,False .. True])) + printTest (take 7 ([False,True .. False])) + printTest (take 7 ([False,True .. True])) + printTest (take 7 ([True,False .. False])) + printTest (take 7 ([True,False .. True])) + printTest (take 7 ([True,True .. False])) + printTest (take 7 ([True,True .. True])) + + +testEnumInteger :: IO () +testEnumInteger = do + -- succ + printTest ((succ (0::Integer))) + printTest ((succ ((-1)::Integer))) + + -- pred + printTest (pred (1::Integer)) + printTest (pred (0::Integer)) + + -- toEnum + printTest ((map (toEnum::Int->Integer) [1,minBound,maxBound])) + + -- fromEnum + printTest ((map fromEnum [(1::Integer),42,45])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Integer)..])) + printTest ((take 7 [(-5::Integer)..])) + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Integer),2..])) + printTest ((take 7 [(1::Integer),7..])) + printTest ((take 7 [(1::Integer),1..])) + printTest ((take 7 [(1::Integer),0..])) + printTest ((take 7 [(5::Integer),2..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Integer) .. 5]))) + printTest ((take 4 ([(1::Integer) .. 1]))) + printTest ((take 7 ([(1::Integer) .. 0]))) + printTest ((take 7 ([(5::Integer) .. 0]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Integer),4..1])) + printTest ((take 7 [(5::Integer),3..1])) + printTest ((take 7 [(5::Integer),3..2])) + printTest ((take 7 [(1::Integer),2..1])) + printTest ((take 7 [(2::Integer),1..2])) + printTest ((take 7 [(2::Integer),1..1])) + printTest ((take 7 [(2::Integer),3..1])) + +testEnumRational :: IO () +testEnumRational = do + -- succ + printTest ((succ (0::Rational))) + printTest ((succ ((-1)::Rational))) + + -- pred + printTest (pred (1::Rational)) + printTest (pred (0::Rational)) + + -- toEnum + printTest ((map (toEnum::Int->Rational) [1,minBound,maxBound])) + + -- fromEnum + printTest ((map fromEnum [(1::Rational),42,45])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Rational)..])) + printTest ((take 7 [(-5::Rational)..])) + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Rational),2..])) + printTest ((take 7 [(1::Rational),7..])) + printTest ((take 7 [(1::Rational),1..])) + printTest ((take 7 [(1::Rational),0..])) + printTest ((take 7 [(5::Rational),2..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Rational) .. 5]))) + printTest ((take 4 ([(1::Rational) .. 1]))) + printTest ((take 7 ([(1::Rational) .. 0]))) + printTest ((take 7 ([(5::Rational) .. 0]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Rational),4..1])) + printTest ((take 7 [(5::Rational),3..1])) + printTest ((take 7 [(5::Rational),3..2])) + printTest ((take 7 [(1::Rational),2..1])) + printTest ((take 7 [(2::Rational),1..2])) + printTest ((take 7 [(2::Rational),1..1])) + printTest ((take 7 [(2::Rational),3..1])) + +testEnumRatioInt :: IO () +testEnumRatioInt = do + -- succ + printTest ((succ (0::Ratio Int))) + printTest ((succ ((-1)::Ratio Int))) + + -- pred + printTest (pred (1::Ratio Int)) + printTest (pred (0::Ratio Int)) + + -- toEnum + printTest ((map (toEnum::Int->Ratio Int) [1,minBound,maxBound])) + + -- fromEnum + printTest ((map fromEnum [(1::Ratio Int),42,45])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Ratio Int)..])) + printTest ((take 7 [(-5::Ratio Int)..])) + printTest ((take 7 [((toEnum ((maxBound::Int)-5))::Ratio Int)..])) + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Ratio Int),2..])) + printTest ((take 7 [(1::Ratio Int),7..])) + printTest ((take 7 [(1::Ratio Int),1..])) + printTest ((take 7 [(1::Ratio Int),0..])) + printTest ((take 7 [(5::Ratio Int),2..])) + let x = (toEnum ((minBound::Int) + 1))::Ratio Int + printTest ((take 7 [x, x-1 ..])) + let x = (toEnum ((minBound::Int) + 5))::Ratio Int + printTest ((take 7 [x, x-1 ..])) + let x = (toEnum ((maxBound::Int) - 5))::Ratio Int + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Ratio Int) .. 5]))) + printTest ((take 4 ([(1::Ratio Int) .. 1]))) + printTest ((take 7 ([(1::Ratio Int) .. 0]))) + printTest ((take 7 ([(5::Ratio Int) .. 0]))) + let x = (toEnum (maxBound - (5::Int))) :: Ratio Int + let y = (toEnum (maxBound::Int)) :: Ratio Int + printTest ((take 7 ([x..y]))) + let x = (toEnum (minBound + (5::Int))) :: Ratio Int + let y = (toEnum (minBound::Int)) :: Ratio Int + printTest ((take 7 ([x..y]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Ratio Int),4..1])) + printTest ((take 7 [(5::Ratio Int),3..1])) + printTest ((take 7 [(5::Ratio Int),3..2])) + printTest ((take 7 [(1::Ratio Int),2..1])) + printTest ((take 7 [(2::Ratio Int),1..2])) + printTest ((take 7 [(2::Ratio Int),1..1])) + printTest ((take 7 [(2::Ratio Int),3..1])) + + let x = (toEnum ((maxBound::Int) - 4)) :: Ratio Int + let y = (toEnum (maxBound::Int)) :: Ratio Int + printTest ((take 7 [x,(x+1)..y])) + let x = (toEnum ((minBound::Int) + 5)) :: Ratio Int + let y = (toEnum (minBound::Int)) :: Ratio Int + printTest ((take 7 [x,(x-1)..y])) + +-- +-- +-- Utils +-- +-- + + +mayBomb x = catch x (\(ErrorCall e) -> putStrLn ("error " ++ show e)) + `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeException))) + +test :: Show a => String -> String -> a -> IO () +test test_nm expected val = do + putStr test_nm + if expected == got then + putStrLn ": SUCCEEDED" + else do + putStr ": FAILED" + putStrLn ("( expected: " ++ show expected ++ " , got: " ++ show got ++ " )") + where + got = show val diff --git a/testsuite/tests/lib/should_run/enum01.stdout b/testsuite/tests/lib/should_run/enum01.stdout new file mode 100644 index 0000000000..71e5bd6d1a --- /dev/null +++ b/testsuite/tests/lib/should_run/enum01.stdout @@ -0,0 +1,246 @@ +Testing Enum Int: + (succ (0::Int)) = 1 + (succ (minBound::Int)) = -2147483647 + (succ (maxBound::Int)) = error "Prelude.Enum.succ{Int}: tried to take `succ' of maxBound" + pred (1::Int) = 0 + pred (maxBound::Int) = 2147483646 + pred (minBound::Int) = error "Prelude.Enum.pred{Int}: tried to take `pred' of minBound" + (map (toEnum::Int->Int) [1,minBound,maxBound]) = [1,-2147483648,2147483647] + (map fromEnum [(1::Int),minBound,maxBound]) = [1,-2147483648,2147483647] + (take 7 [(1::Int)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [(1::Int),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-2147483647,-2147483648] + (take 7 [x, x-1 ..]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] + (take 7 [x, (x+1) ..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + ([minBound::Int,1..]) = [-2147483648,1] + ([minBound::Int,0..]) = [-2147483648,0] + ([minBound::Int,-1..]) = [-2147483648,-1,2147483646] + ([maxBound::Int,1..]) = [2147483647,1,-2147483645] + ([maxBound::Int,0..]) = [2147483647,0,-2147483647] + ([maxBound::Int,-1..]) = [2147483647,-1] + (take 7 ([(1::Int) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int) .. 1])) = [1] + (take 7 ([(1::Int) .. 0])) = [] + (take 7 ([(5::Int) .. 0])) = [] + (take 7 ([(maxBound-(5::Int)) .. maxBound])) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(minBound+(5::Int)) .. minBound])) = [] + (take 7 [(5::Int),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int),3..1]) = [5,3,1] + (take 7 [(5::Int),3..2]) = [5,3] + (take 7 [(1::Int),2..1]) = [1] + (take 7 [(2::Int),1..2]) = [2] + (take 7 [(2::Int),1..1]) = [2,1] + (take 7 [(2::Int),3..1]) = [] + ([minBound, 1..maxBound::Int]) = [-2147483648,1] + ([minBound, 0..maxBound::Int]) = [-2147483648,0] + ([minBound,-1..maxBound::Int]) = [-2147483648,-1,2147483646] + ([minBound,-1..maxBound-1::Int]) = [-2147483648,-1,2147483646] + ([minBound,-1..maxBound-2::Int]) = [-2147483648,-1] + ([maxBound, 1..minBound::Int]) = [2147483647,1,-2147483645] + ([maxBound, 0..minBound::Int]) = [2147483647,0,-2147483647] + ([maxBound, 0..minBound+1::Int]) = [2147483647,0,-2147483647] + ([maxBound, 0..minBound+2::Int]) = [2147483647,0] + ([maxBound,-1..minBound::Int]) = [2147483647,-1] + (take 7 [x,(x+1)..maxBound]) = [2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [x,(x-1)..minBound]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] +Testing Enum Integer: + (succ (0::Integer)) = 1 + (succ ((-1)::Integer)) = 0 + pred (1::Integer) = 0 + pred (0::Integer) = -1 + (map (toEnum::Int->Integer) [1,minBound,maxBound]) = [1,-2147483648,2147483647] + (map fromEnum [(1::Integer),42,45]) = [1,42,45] + (take 7 [(1::Integer)..]) = [1,2,3,4,5,6,7] + (take 7 [(-5::Integer)..]) = [-5,-4,-3,-2,-1,0,1] + (take 7 [(1::Integer),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Integer),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Integer),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Integer),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Integer),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 ([(1::Integer) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Integer) .. 1])) = [1] + (take 7 ([(1::Integer) .. 0])) = [] + (take 7 ([(5::Integer) .. 0])) = [] + (take 7 [(5::Integer),4..1]) = [5,4,3,2,1] + (take 7 [(5::Integer),3..1]) = [5,3,1] + (take 7 [(5::Integer),3..2]) = [5,3] + (take 7 [(1::Integer),2..1]) = [1] + (take 7 [(2::Integer),1..2]) = [2] + (take 7 [(2::Integer),1..1]) = [2,1] + (take 7 [(2::Integer),3..1]) = [] +Testing Enum Char: + (succ 'a') = 'b' + (succ (minBound::Char)) = '\SOH' + (succ (maxBound::Char)) = error "Prelude.Enum.Char.succ: bad argument" + (pred 'b') = 'a' + pred (maxBound::Char) = '\1114110' + pred (minBound::Char) = error "Prelude.Enum.Char.pred: bad argument" + (map (toEnum::Int->Char) [123,ord (minBound::Char), ord(maxBound::Char)]) = "{\NUL\1114111" + (toEnum::Int->Char) (minBound::Int) = error "Prelude.chr: bad argument: (-2147483648)" + (map fromEnum ['X',minBound,maxBound]) = [88,0,1114111] + (take 7 ['\NUL' .. ]) = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK" + (take 7 ['\250' .. ]) = "\250\251\252\253\254\255\256" + (take 7 ['a','b'..]) = "abcdefg" + (take 7 ['a','e'..]) = "aeimquy" + (take 7 ['a','a'..]) = "aaaaaaa" + (take 7 ['z','y'..]) = "zyxwvut" + (take 7 ['z','v'..]) = "zvrnjfb" + (take 7 ['\1', '\0' ..]) = "\SOH\NUL" + (take 7 ['\5', '\4' ..]) = "\ENQ\EOT\ETX\STX\SOH\NUL" + (take 7 ['\250', '\251' ..]) = "\250\251\252\253\254\255\256" + (take 7 (['a' .. 'e'])) = "abcde" + (take 4 (['a' .. 'a'])) = "a" + (take 7 (['b' .. 'a'])) = "" + (take 7 (['e' .. 'a'])) = "" + (take 7 (['\250' .. '\255'])) = "\250\251\252\253\254\255" + (take 7 (['\5' .. '\0'])) = "" + (take 7 ['f','e' .. 'b']) = "fedcb" + (take 7 ['g','e' .. 'b']) = "gec" + (take 7 ['g','d' .. 'c']) = "gd" + (take 7 ['b','c' .. 'b']) = "b" + (take 7 ['c','b' .. 'c']) = "c" + (take 7 ['c','b' .. 'b']) = "cb" + (take 7 ['c','d' .. 'b']) = "" + (take 7 ['\251', '\252' .. maxBound]) = "\251\252\253\254\255\256\257" + (take 7 ['\5', '\4' .. minBound]) = "\ENQ\EOT\ETX\STX\SOH\NUL" +Testing Enum (): + (succ ()) = error "Prelude.Enum.().succ: bad argument" + (succ (minBound::())) = error "Prelude.Enum.().succ: bad argument" + (succ (maxBound::())) = error "Prelude.Enum.().succ: bad argument" + (pred ()) = error "Prelude.Enum.().pred: bad argument" + (pred (minBound::())) = error "Prelude.Enum.().pred: bad argument" + (pred (maxBound::())) = error "Prelude.Enum.().pred: bad argument" + (toEnum 0)::() = () + (toEnum 1)::() = error "Prelude.Enum.().toEnum: bad argument" + (fromEnum ()) = 0 + (take 7 [()..]) = [()] + (take 7 [(),()..]) = [(),(),(),(),(),(),()] + (take 7 [()..()]) = [()] + (take 7 [(),()..()]) = [(),(),(),(),(),(),()] +Testing Enum Ordering (derived): + (succ LT) = EQ + (succ (minBound::Ordering)) = EQ + (succ (maxBound::Ordering)) = error "Prelude.Enum.Ordering.succ: bad argument" + (pred GT) = EQ + (pred (maxBound::Ordering)) = EQ + (pred (minBound::Ordering)) = error "Prelude.Enum.Ordering.pred: bad argument" + (toEnum 0)::Ordering = LT + (toEnum 5)::Ordering = error "Prelude.Enum.Ordering.toEnum: bad argument" + (fromEnum LT) = 0 + (fromEnum EQ) = 1 + (fromEnum GT) = 2 + ([LT ..]) = [LT,EQ,GT] + ([EQ ..]) = [EQ,GT] + ([GT ..]) = [GT] + ([LT,EQ ..]) = [LT,EQ,GT] + ([EQ,GT ..]) = [EQ,GT] + ([EQ,LT ..]) = [EQ,LT] + ([LT,GT ..]) = [LT,GT] + ([GT,LT ..]) = [GT,LT] + take 7 (([GT,GT ..])) = [GT,GT,GT,GT,GT,GT,GT] + take 7 (([LT,LT ..])) = [LT,LT,LT,LT,LT,LT,LT] + ([LT .. GT]) = [LT,EQ,GT] + ([LT .. EQ]) = [LT,EQ] + ([LT .. LT]) = [LT] + ([GT .. LT]) = [] + ([GT .. EQ]) = [] + ([GT .. GT]) = [GT] + ([LT,EQ .. GT]) = [LT,EQ,GT] + ([GT,EQ .. LT]) = [GT,EQ,LT] + ([GT,EQ .. EQ]) = [GT,EQ] + ([GT,EQ .. GT]) = [GT] + ([GT,EQ .. LT]) = [GT,EQ,LT] + ([LT,EQ .. LT]) = [LT] + ([LT,EQ .. GT]) = [LT,EQ,GT] + take 7 (([LT,LT .. GT])) = [LT,LT,LT,LT,LT,LT,LT] + take 7 (([GT,GT .. LT])) = [] +Testing Enum Bool: + (succ False) = True + (succ (minBound::Bool)) = True + (succ (maxBound::Bool)) = error "Prelude.Enum.Bool.succ: bad argument" + (pred True) = False + (pred (maxBound::Bool)) = False + (pred (minBound::Bool)) = error "Prelude.Enum.Bool.pred: bad argument" + (toEnum 0)::Bool = False + (toEnum 5)::Bool = error "Prelude.Enum.Bool.toEnum: bad argument" + (fromEnum False) = 0 + (fromEnum True) = 1 + ([False ..]) = [False,True] + ([True ..]) = [True] + ([False,True ..]) = [False,True] + ([True,False ..]) = [True,False] + (take 7 ([False,False ..])) = [False,False,False,False,False,False,False] + (take 7 ([True,True ..])) = [True,True,True,True,True,True,True] + ([False .. True]) = [False,True] + ([True .. False]) = [] + take 7 ([False,False .. False]) = [False,False,False,False,False,False,False] + take 7 ([False,False .. True]) = [False,False,False,False,False,False,False] + take 7 ([False,True .. False]) = [False] + take 7 ([False,True .. True]) = [False,True] + take 7 ([True,False .. False]) = [True,False] + take 7 ([True,False .. True]) = [True] + take 7 ([True,True .. False]) = [] + take 7 ([True,True .. True]) = [True,True,True,True,True,True,True] +Testing Enum Rational: + (succ (0::Rational)) = 1 % 1 + (succ ((-1)::Rational)) = 0 % 1 + pred (1::Rational) = 0 % 1 + pred (0::Rational) = (-1) % 1 + (map (toEnum::Int->Rational) [1,minBound,maxBound]) = [1 % 1,(-2147483648) % 1,2147483647 % 1] + (map fromEnum [(1::Rational),42,45]) = [1,42,45] + (take 7 [(1::Rational)..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(-5::Rational)..]) = [(-5) % 1,(-4) % 1,(-3) % 1,(-2) % 1,(-1) % 1,0 % 1,1 % 1] + (take 7 [(1::Rational),2..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(1::Rational),7..]) = [1 % 1,7 % 1,13 % 1,19 % 1,25 % 1,31 % 1,37 % 1] + (take 7 [(1::Rational),1..]) = [1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1] + (take 7 [(1::Rational),0..]) = [1 % 1,0 % 1,(-1) % 1,(-2) % 1,(-3) % 1,(-4) % 1,(-5) % 1] + (take 7 [(5::Rational),2..]) = [5 % 1,2 % 1,(-1) % 1,(-4) % 1,(-7) % 1,(-10) % 1,(-13) % 1] + (take 7 ([(1::Rational) .. 5])) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1] + (take 4 ([(1::Rational) .. 1])) = [1 % 1] + (take 7 ([(1::Rational) .. 0])) = [] + (take 7 ([(5::Rational) .. 0])) = [] + (take 7 [(5::Rational),4..1]) = [5 % 1,4 % 1,3 % 1,2 % 1,1 % 1] + (take 7 [(5::Rational),3..1]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(5::Rational),3..2]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(1::Rational),2..1]) = [1 % 1] + (take 7 [(2::Rational),1..2]) = [2 % 1] + (take 7 [(2::Rational),1..1]) = [2 % 1,1 % 1] + (take 7 [(2::Rational),3..1]) = [] +Testing Enum (Ratio Int): + (succ (0::Ratio Int)) = 1 % 1 + (succ ((-1)::Ratio Int)) = 0 % 1 + pred (1::Ratio Int) = 0 % 1 + pred (0::Ratio Int) = (-1) % 1 + (map (toEnum::Int->Ratio Int) [1,minBound,maxBound]) = [1 % 1,(-2147483648) % 1,2147483647 % 1] + (map fromEnum [(1::Ratio Int),42,45]) = [1,42,45] + (take 7 [(1::Ratio Int)..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(-5::Ratio Int)..]) = [(-5) % 1,(-4) % 1,(-3) % 1,(-2) % 1,(-1) % 1,0 % 1,1 % 1] + (take 7 [((toEnum ((maxBound::Int)-5))::Ratio Int)..]) = [2147483642 % 1,2147483643 % 1,2147483644 % 1,2147483645 % 1,2147483646 % 1,2147483647 % 1,(-2147483648) % 1] + (take 7 [(1::Ratio Int),2..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(1::Ratio Int),7..]) = [1 % 1,7 % 1,13 % 1,19 % 1,25 % 1,31 % 1,37 % 1] + (take 7 [(1::Ratio Int),1..]) = [1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1] + (take 7 [(1::Ratio Int),0..]) = [1 % 1,0 % 1,(-1) % 1,(-2) % 1,(-3) % 1,(-4) % 1,(-5) % 1] + (take 7 [(5::Ratio Int),2..]) = [5 % 1,2 % 1,(-1) % 1,(-4) % 1,(-7) % 1,(-10) % 1,(-13) % 1] + (take 7 [x, x-1 ..]) = [(-2147483647) % 1,(-2147483648) % 1,2147483647 % 1,2147483646 % 1,2147483645 % 1,2147483644 % 1,2147483643 % 1] + (take 7 [x, x-1 ..]) = [(-2147483643) % 1,(-2147483644) % 1,(-2147483645) % 1,(-2147483646) % 1,(-2147483647) % 1,(-2147483648) % 1,2147483647 % 1] + (take 7 [x, (x+1) ..]) = [2147483642 % 1,2147483643 % 1,2147483644 % 1,2147483645 % 1,2147483646 % 1,2147483647 % 1,(-2147483648) % 1] + (take 7 ([(1::Ratio Int) .. 5])) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1] + (take 4 ([(1::Ratio Int) .. 1])) = [1 % 1] + (take 7 ([(1::Ratio Int) .. 0])) = [] + (take 7 ([(5::Ratio Int) .. 0])) = [] + (take 7 ([x..y])) = [2147483642 % 1,2147483643 % 1,2147483644 % 1,2147483645 % 1,2147483646 % 1,2147483647 % 1] + (take 7 ([x..y])) = [] + (take 7 [(5::Ratio Int),4..1]) = [5 % 1,4 % 1,3 % 1,2 % 1,1 % 1] + (take 7 [(5::Ratio Int),3..1]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(5::Ratio Int),3..2]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(1::Ratio Int),2..1]) = [1 % 1] + (take 7 [(2::Ratio Int),1..2]) = [2 % 1] + (take 7 [(2::Ratio Int),1..1]) = [2 % 1,1 % 1] + (take 7 [(2::Ratio Int),3..1]) = [] + (take 7 [x,(x+1)..y]) = [2147483643 % 1,2147483644 % 1,2147483645 % 1,2147483646 % 1,2147483647 % 1] + (take 7 [x,(x-1)..y]) = [(-2147483643) % 1,(-2147483644) % 1,(-2147483645) % 1,(-2147483646) % 1,(-2147483647) % 1,(-2147483648) % 1] diff --git a/testsuite/tests/lib/should_run/enum01.stdout-alpha-dec-osf3 b/testsuite/tests/lib/should_run/enum01.stdout-alpha-dec-osf3 new file mode 100644 index 0000000000..63ba3e2fb3 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum01.stdout-alpha-dec-osf3 @@ -0,0 +1,230 @@ +Testing Enum Int: + (succ (0::Int)) = 1 + (succ (minBound::Int)) = -9223372036854775807 + (succ (maxBound::Int)) = error "Prelude.Enum.succ{Int}: tried to take `succ' of maxBound" + pred (1::Int) = 0 + pred (maxBound::Int) = 9223372036854775806 + pred (minBound::Int) = error "Prelude.Enum.pred{Int}: tried to take `pred' of minBound" + (map (toEnum::Int->Int) [1,minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807] + (map fromEnum [(1::Int),minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807] + (take 7 [(1::Int)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int)-5)..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [(1::Int),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-9223372036854775807,-9223372036854775808] + (take 7 [x, x-1 ..]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] + (take 7 [x, (x+1) ..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(1::Int) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int) .. 1])) = [1] + (take 7 ([(1::Int) .. 0])) = [] + (take 7 ([(5::Int) .. 0])) = [] + (take 7 ([(maxBound-(5::Int)) .. maxBound])) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(minBound+(5::Int)) .. minBound])) = [] + (take 7 [(5::Int),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int),3..1]) = [5,3,1] + (take 7 [(5::Int),3..2]) = [5,3] + (take 7 [(1::Int),2..1]) = [1] + (take 7 [(2::Int),1..2]) = [2] + (take 7 [(2::Int),1..1]) = [2,1] + (take 7 [(2::Int),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [x,(x-1)..minBound]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] +Testing Enum Integer: + (succ (0::Integer)) = 1 + (succ ((-1)::Integer)) = 0 + pred (1::Integer) = 0 + pred (0::Integer) = -1 + (map (toEnum::Int->Integer) [1,minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807] + (map fromEnum [(1::Integer),42,45]) = [1,42,45] + (take 7 [(1::Integer)..]) = [1,2,3,4,5,6,7] + (take 7 [(-5::Integer)..]) = [-5,-4,-3,-2,-1,0,1] + (take 7 [(1::Integer),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Integer),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Integer),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Integer),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Integer),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 ([(1::Integer) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Integer) .. 1])) = [1] + (take 7 ([(1::Integer) .. 0])) = [] + (take 7 ([(5::Integer) .. 0])) = [] + (take 7 [(5::Integer),4..1]) = [5,4,3,2,1] + (take 7 [(5::Integer),3..1]) = [5,3,1] + (take 7 [(5::Integer),3..2]) = [5,3] + (take 7 [(1::Integer),2..1]) = [1] + (take 7 [(2::Integer),1..2]) = [2] + (take 7 [(2::Integer),1..1]) = [2,1] + (take 7 [(2::Integer),3..1]) = [] +Testing Enum Char: + (succ 'a') = 'b' + (succ (minBound::Char)) = '\SOH' + (succ (maxBound::Char)) = error "Prelude.Enum.Char.succ: bad argument" + (pred 'b') = 'a' + pred (maxBound::Char) = '\1114110' + pred (minBound::Char) = error "Prelude.Enum.Char.pred: bad argument" + (map (toEnum::Int->Char) [123,ord (minBound::Char), ord(maxBound::Char)]) = "{\NUL\1114111" + (toEnum::Int->Char) (minBound::Int) = error "Prelude.chr: bad argument" + (map fromEnum ['X',minBound,maxBound]) = [88,0,1114111] + (take 7 ['\NUL' .. ]) = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK" + (take 7 ['\250' .. ]) = "\250\251\252\253\254\255\256" + (take 7 ['a','b'..]) = "abcdefg" + (take 7 ['a','e'..]) = "aeimquy" + (take 7 ['a','a'..]) = "aaaaaaa" + (take 7 ['z','y'..]) = "zyxwvut" + (take 7 ['z','v'..]) = "zvrnjfb" + (take 7 ['\1', '\0' ..]) = "\SOH\NUL" + (take 7 ['\5', '\4' ..]) = "\ENQ\EOT\ETX\STX\SOH\NUL" + (take 7 ['\250', '\251' ..]) = "\250\251\252\253\254\255\256" + (take 7 (['a' .. 'e'])) = "abcde" + (take 4 (['a' .. 'a'])) = "a" + (take 7 (['b' .. 'a'])) = "" + (take 7 (['e' .. 'a'])) = "" + (take 7 (['\250' .. '\255'])) = "\250\251\252\253\254\255" + (take 7 (['\5' .. '\0'])) = "" + (take 7 ['f','e' .. 'b']) = "fedcb" + (take 7 ['g','e' .. 'b']) = "gec" + (take 7 ['g','d' .. 'c']) = "gd" + (take 7 ['b','c' .. 'b']) = "b" + (take 7 ['c','b' .. 'c']) = "c" + (take 7 ['c','b' .. 'b']) = "cb" + (take 7 ['c','d' .. 'b']) = "" + (take 7 ['\251', '\252' .. maxBound]) = "\251\252\253\254\255\256\257" + (take 7 ['\5', '\4' .. minBound]) = "\ENQ\EOT\ETX\STX\SOH\NUL" +Testing Enum (): + (succ ()) = error "Prelude.Enum.().succ: bad argument" + (succ (minBound::())) = error "Prelude.Enum.().succ: bad argument" + (succ (maxBound::())) = error "Prelude.Enum.().succ: bad argument" + (pred ()) = error "Prelude.Enum.().pred: bad argument" + (pred (minBound::())) = error "Prelude.Enum.().pred: bad argument" + (pred (maxBound::())) = error "Prelude.Enum.().pred: bad argument" + (toEnum 0)::() = () + (toEnum 1)::() = error "Prelude.Enum.().toEnum: bad argument" + (fromEnum ()) = 0 + (take 7 [()..]) = [()] + (take 7 [(),()..]) = [(),(),(),(),(),(),()] + (take 7 [()..()]) = [()] + (take 7 [(),()..()]) = [(),(),(),(),(),(),()] +Testing Enum Ordering (derived): + (succ LT) = EQ + (succ (minBound::Ordering)) = EQ + (succ (maxBound::Ordering)) = error "Prelude.Enum.Ordering.succ: bad argument" + (pred GT) = EQ + (pred (maxBound::Ordering)) = EQ + (pred (minBound::Ordering)) = error "Prelude.Enum.Ordering.pred: bad argument" + (toEnum 0)::Ordering = LT + (toEnum 5)::Ordering = error "Prelude.Enum.Ordering.toEnum: bad argument" + (fromEnum LT) = 0 + (fromEnum EQ) = 1 + (fromEnum GT) = 2 + ([LT ..]) = [LT,EQ,GT] + ([EQ ..]) = [EQ,GT] + ([GT ..]) = [GT] + ([LT,EQ ..]) = [LT,EQ,GT] + ([EQ,GT ..]) = [EQ,GT] + ([EQ,LT ..]) = [EQ,LT] + ([LT,GT ..]) = [LT,GT] + ([GT,LT ..]) = [GT,LT] + take 7 (([GT,GT ..])) = [GT,GT,GT,GT,GT,GT,GT] + take 7 (([LT,LT ..])) = [LT,LT,LT,LT,LT,LT,LT] + ([LT .. GT]) = [LT,EQ,GT] + ([LT .. EQ]) = [LT,EQ] + ([LT .. LT]) = [LT] + ([GT .. LT]) = [] + ([GT .. EQ]) = [] + ([GT .. GT]) = [GT] + ([LT,EQ .. GT]) = [LT,EQ,GT] + ([GT,EQ .. LT]) = [GT,EQ,LT] + ([GT,EQ .. EQ]) = [GT,EQ] + ([GT,EQ .. GT]) = [GT] + ([GT,EQ .. LT]) = [GT,EQ,LT] + ([LT,EQ .. LT]) = [LT] + ([LT,EQ .. GT]) = [LT,EQ,GT] + take 7 (([LT,LT .. GT])) = [LT,LT,LT,LT,LT,LT,LT] + take 7 (([GT,GT .. LT])) = [] +Testing Enum Bool: + (succ False) = True + (succ (minBound::Bool)) = True + (succ (maxBound::Bool)) = error "Prelude.Enum.Bool.succ: bad argument" + (pred True) = False + (pred (maxBound::Bool)) = False + (pred (minBound::Bool)) = error "Prelude.Enum.Bool.pred: bad argument" + (toEnum 0)::Bool = False + (toEnum 5)::Bool = error "Prelude.Enum.Bool.toEnum: bad argument" + (fromEnum False) = 0 + (fromEnum True) = 1 + ([False ..]) = [False,True] + ([True ..]) = [True] + ([False,True ..]) = [False,True] + ([True,False ..]) = [True,False] + (take 7 ([False,False ..])) = [False,False,False,False,False,False,False] + (take 7 ([True,True ..])) = [True,True,True,True,True,True,True] + ([False .. True]) = [False,True] + ([True .. False]) = [] + take 7 ([False,False .. False]) = [False,False,False,False,False,False,False] + take 7 ([False,False .. True]) = [False,False,False,False,False,False,False] + take 7 ([False,True .. False]) = [False] + take 7 ([False,True .. True]) = [False,True] + take 7 ([True,False .. False]) = [True,False] + take 7 ([True,False .. True]) = [True] + take 7 ([True,True .. False]) = [] + take 7 ([True,True .. True]) = [True,True,True,True,True,True,True] +Testing Enum Rational: + (succ (0::Rational)) = 1%1 + (succ ((-1)::Rational)) = 0%1 + pred (1::Rational) = 0%1 + pred (0::Rational) = (-1)%1 + (map (toEnum::Int->Rational) [1,minBound,maxBound]) = [1%1,(-9223372036854775808)%1,9223372036854775807%1] + (map fromEnum [(1::Rational),42,45]) = [1,42,45] + (take 7 [(1::Rational)..]) = [1%1,2%1,3%1,4%1,5%1,6%1,7%1] + (take 7 [(-5::Rational)..]) = [(-5)%1,(-4)%1,(-3)%1,(-2)%1,(-1)%1,0%1,1%1] + (take 7 [(1::Rational),2..]) = [1%1,2%1,3%1,4%1,5%1,6%1,7%1] + (take 7 [(1::Rational),7..]) = [1%1,7%1,13%1,19%1,25%1,31%1,37%1] + (take 7 [(1::Rational),1..]) = [1%1,1%1,1%1,1%1,1%1,1%1,1%1] + (take 7 [(1::Rational),0..]) = [1%1,0%1,(-1)%1,(-2)%1,(-3)%1,(-4)%1,(-5)%1] + (take 7 [(5::Rational),2..]) = [5%1,2%1,(-1)%1,(-4)%1,(-7)%1,(-10)%1,(-13)%1] + (take 7 ([(1::Rational) .. 5])) = [1%1,2%1,3%1,4%1,5%1] + (take 4 ([(1::Rational) .. 1])) = [1%1] + (take 7 ([(1::Rational) .. 0])) = [] + (take 7 ([(5::Rational) .. 0])) = [] + (take 7 [(5::Rational),4..1]) = [5%1,4%1,3%1,2%1,1%1] + (take 7 [(5::Rational),3..1]) = [5%1,3%1,1%1] + (take 7 [(5::Rational),3..2]) = [5%1,3%1,1%1] + (take 7 [(1::Rational),2..1]) = [1%1] + (take 7 [(2::Rational),1..2]) = [2%1] + (take 7 [(2::Rational),1..1]) = [2%1,1%1] + (take 7 [(2::Rational),3..1]) = [] +Testing Enum (Ratio Int): + (succ (0::Ratio Int)) = 1%1 + (succ ((-1)::Ratio Int)) = 0%1 + pred (1::Ratio Int) = 0%1 + pred (0::Ratio Int) = (-1)%1 + (map (toEnum::Int->Ratio Int) [1,minBound,maxBound]) = [1%1,(-9223372036854775808)%1,9223372036854775807%1] + (map fromEnum [(1::Ratio Int),42,45]) = [1,42,45] + (take 7 [(1::Ratio Int)..]) = [1%1,2%1,3%1,4%1,5%1,6%1,7%1] + (take 7 [(-5::Ratio Int)..]) = [(-5)%1,(-4)%1,(-3)%1,(-2)%1,(-1)%1,0%1,1%1] + (take 7 [((toEnum ((maxBound::Int)-5))::Ratio Int)..]) = [9223372036854775802%1,9223372036854775803%1,9223372036854775804%1,9223372036854775805%1,9223372036854775806%1,9223372036854775807%1,(-9223372036854775808)%1] + (take 7 [(1::Ratio Int),2..]) = [1%1,2%1,3%1,4%1,5%1,6%1,7%1] + (take 7 [(1::Ratio Int),7..]) = [1%1,7%1,13%1,19%1,25%1,31%1,37%1] + (take 7 [(1::Ratio Int),1..]) = [1%1,1%1,1%1,1%1,1%1,1%1,1%1] + (take 7 [(1::Ratio Int),0..]) = [1%1,0%1,(-1)%1,(-2)%1,(-3)%1,(-4)%1,(-5)%1] + (take 7 [(5::Ratio Int),2..]) = [5%1,2%1,(-1)%1,(-4)%1,(-7)%1,(-10)%1,(-13)%1] + (take 7 [x, x-1 ..]) = [(-9223372036854775807)%1,(-9223372036854775808)%1,9223372036854775807%1,9223372036854775806%1,9223372036854775805%1,9223372036854775804%1,9223372036854775803%1] + (take 7 [x, x-1 ..]) = [(-9223372036854775803)%1,(-9223372036854775804)%1,(-9223372036854775805)%1,(-9223372036854775806)%1,(-9223372036854775807)%1,(-9223372036854775808)%1,9223372036854775807%1] + (take 7 [x, (x+1) ..]) = [9223372036854775802%1,9223372036854775803%1,9223372036854775804%1,9223372036854775805%1,9223372036854775806%1,9223372036854775807%1,(-9223372036854775808)%1] + (take 7 ([(1::Ratio Int) .. 5])) = [1%1,2%1,3%1,4%1,5%1] + (take 4 ([(1::Ratio Int) .. 1])) = [1%1] + (take 7 ([(1::Ratio Int) .. 0])) = [] + (take 7 ([(5::Ratio Int) .. 0])) = [] + (take 7 ([x..y])) = [9223372036854775802%1,9223372036854775803%1,9223372036854775804%1,9223372036854775805%1,9223372036854775806%1,9223372036854775807%1] + (take 7 ([x..y])) = [] + (take 7 [(5::Ratio Int),4..1]) = [5%1,4%1,3%1,2%1,1%1] + (take 7 [(5::Ratio Int),3..1]) = [5%1,3%1,1%1] + (take 7 [(5::Ratio Int),3..2]) = [5%1,3%1,1%1] + (take 7 [(1::Ratio Int),2..1]) = [1%1] + (take 7 [(2::Ratio Int),1..2]) = [2%1] + (take 7 [(2::Ratio Int),1..1]) = [2%1,1%1] + (take 7 [(2::Ratio Int),3..1]) = [] + (take 7 [x,(x+1)..y]) = [9223372036854775803%1,9223372036854775804%1,9223372036854775805%1,9223372036854775806%1,9223372036854775807%1] + (take 7 [x,(x-1)..y]) = [(-9223372036854775803)%1,(-9223372036854775804)%1,(-9223372036854775805)%1,(-9223372036854775806)%1,(-9223372036854775807)%1,(-9223372036854775808)%1] diff --git a/testsuite/tests/lib/should_run/enum01.stdout-hugs b/testsuite/tests/lib/should_run/enum01.stdout-hugs new file mode 100644 index 0000000000..41bb64d598 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum01.stdout-hugs @@ -0,0 +1,246 @@ +Testing Enum Int: + (succ (0::Int)) = 1 + (succ (minBound::Int)) = -2147483647 + (succ (maxBound::Int)) = error "succ: applied to maxBound" + pred (1::Int) = 0 + pred (maxBound::Int) = 2147483646 + pred (minBound::Int) = error "pred: applied to minBound" + (map (toEnum::Int->Int) [1,minBound,maxBound]) = [1,-2147483648,2147483647] + (map fromEnum [(1::Int),minBound,maxBound]) = [1,-2147483648,2147483647] + (take 7 [(1::Int)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [(1::Int),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-2147483647,-2147483648] + (take 7 [x, x-1 ..]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] + (take 7 [x, (x+1) ..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + ([minBound::Int,1..]) = [-2147483648,1] + ([minBound::Int,0..]) = [-2147483648,0] + ([minBound::Int,-1..]) = [-2147483648,-1,2147483646] + ([maxBound::Int,1..]) = [2147483647,1,-2147483645] + ([maxBound::Int,0..]) = [2147483647,0,-2147483647] + ([maxBound::Int,-1..]) = [2147483647,-1] + (take 7 ([(1::Int) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int) .. 1])) = [1] + (take 7 ([(1::Int) .. 0])) = [] + (take 7 ([(5::Int) .. 0])) = [] + (take 7 ([(maxBound-(5::Int)) .. maxBound])) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(minBound+(5::Int)) .. minBound])) = [] + (take 7 [(5::Int),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int),3..1]) = [5,3,1] + (take 7 [(5::Int),3..2]) = [5,3] + (take 7 [(1::Int),2..1]) = [1] + (take 7 [(2::Int),1..2]) = [2] + (take 7 [(2::Int),1..1]) = [2,1] + (take 7 [(2::Int),3..1]) = [] + ([minBound, 1..maxBound::Int]) = [-2147483648,1] + ([minBound, 0..maxBound::Int]) = [-2147483648,0] + ([minBound,-1..maxBound::Int]) = [-2147483648,-1,2147483646] + ([minBound,-1..maxBound-1::Int]) = [-2147483648,-1,2147483646] + ([minBound,-1..maxBound-2::Int]) = [-2147483648,-1] + ([maxBound, 1..minBound::Int]) = [2147483647,1,-2147483645] + ([maxBound, 0..minBound::Int]) = [2147483647,0,-2147483647] + ([maxBound, 0..minBound+1::Int]) = [2147483647,0,-2147483647] + ([maxBound, 0..minBound+2::Int]) = [2147483647,0] + ([maxBound,-1..minBound::Int]) = [2147483647,-1] + (take 7 [x,(x+1)..maxBound]) = [2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [x,(x-1)..minBound]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] +Testing Enum Integer: + (succ (0::Integer)) = 1 + (succ ((-1)::Integer)) = 0 + pred (1::Integer) = 0 + pred (0::Integer) = -1 + (map (toEnum::Int->Integer) [1,minBound,maxBound]) = [1,-2147483648,2147483647] + (map fromEnum [(1::Integer),42,45]) = [1,42,45] + (take 7 [(1::Integer)..]) = [1,2,3,4,5,6,7] + (take 7 [(-5::Integer)..]) = [-5,-4,-3,-2,-1,0,1] + (take 7 [(1::Integer),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Integer),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Integer),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Integer),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Integer),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 ([(1::Integer) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Integer) .. 1])) = [1] + (take 7 ([(1::Integer) .. 0])) = [] + (take 7 ([(5::Integer) .. 0])) = [] + (take 7 [(5::Integer),4..1]) = [5,4,3,2,1] + (take 7 [(5::Integer),3..1]) = [5,3,1] + (take 7 [(5::Integer),3..2]) = [5,3] + (take 7 [(1::Integer),2..1]) = [1] + (take 7 [(2::Integer),1..2]) = [2] + (take 7 [(2::Integer),1..1]) = [2,1] + (take 7 [(2::Integer),3..1]) = [] +Testing Enum Char: + (succ 'a') = 'b' + (succ (minBound::Char)) = '\SOH' + (succ (maxBound::Char)) = error "chr: out of range" + (pred 'b') = 'a' + pred (maxBound::Char) = '\1114110' + pred (minBound::Char) = error "chr: out of range" + (map (toEnum::Int->Char) [123,ord (minBound::Char), ord(maxBound::Char)]) = "{\NUL\1114111" + (toEnum::Int->Char) (minBound::Int) = error "chr: out of range" + (map fromEnum ['X',minBound,maxBound]) = [88,0,1114111] + (take 7 ['\NUL' .. ]) = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK" + (take 7 ['\250' .. ]) = "\250\251\252\253\254\255\256" + (take 7 ['a','b'..]) = "abcdefg" + (take 7 ['a','e'..]) = "aeimquy" + (take 7 ['a','a'..]) = "aaaaaaa" + (take 7 ['z','y'..]) = "zyxwvut" + (take 7 ['z','v'..]) = "zvrnjfb" + (take 7 ['\1', '\0' ..]) = "\SOH\NUL" + (take 7 ['\5', '\4' ..]) = "\ENQ\EOT\ETX\STX\SOH\NUL" + (take 7 ['\250', '\251' ..]) = "\250\251\252\253\254\255\256" + (take 7 (['a' .. 'e'])) = "abcde" + (take 4 (['a' .. 'a'])) = "a" + (take 7 (['b' .. 'a'])) = "" + (take 7 (['e' .. 'a'])) = "" + (take 7 (['\250' .. '\255'])) = "\250\251\252\253\254\255" + (take 7 (['\5' .. '\0'])) = "" + (take 7 ['f','e' .. 'b']) = "fedcb" + (take 7 ['g','e' .. 'b']) = "gec" + (take 7 ['g','d' .. 'c']) = "gd" + (take 7 ['b','c' .. 'b']) = "b" + (take 7 ['c','b' .. 'c']) = "c" + (take 7 ['c','b' .. 'b']) = "cb" + (take 7 ['c','d' .. 'b']) = "" + (take 7 ['\251', '\252' .. maxBound]) = "\251\252\253\254\255\256\257" + (take 7 ['\5', '\4' .. minBound]) = "\ENQ\EOT\ETX\STX\SOH\NUL" +Testing Enum (): + (succ ()) = Fail: pattern match failure + (succ (minBound::())) = Fail: pattern match failure + (succ (maxBound::())) = Fail: pattern match failure + (pred ()) = Fail: pattern match failure + (pred (minBound::())) = Fail: pattern match failure + (pred (maxBound::())) = Fail: pattern match failure + (toEnum 0)::() = () + (toEnum 1)::() = Fail: pattern match failure + (fromEnum ()) = 0 + (take 7 [()..]) = [()] + (take 7 [(),()..]) = [(),(),(),(),(),(),()] + (take 7 [()..()]) = [()] + (take 7 [(),()..()]) = [(),(),(),(),(),(),()] +Testing Enum Ordering (derived): + (succ LT) = EQ + (succ (minBound::Ordering)) = EQ + (succ (maxBound::Ordering)) = error "toEnum: out of range" + (pred GT) = EQ + (pred (maxBound::Ordering)) = EQ + (pred (minBound::Ordering)) = error "toEnum: out of range" + (toEnum 0)::Ordering = LT + (toEnum 5)::Ordering = error "toEnum: out of range" + (fromEnum LT) = 0 + (fromEnum EQ) = 1 + (fromEnum GT) = 2 + ([LT ..]) = [LT,EQ,GT] + ([EQ ..]) = [EQ,GT] + ([GT ..]) = [GT] + ([LT,EQ ..]) = [LT,EQ,GT] + ([EQ,GT ..]) = [EQ,GT] + ([EQ,LT ..]) = [EQ,LT] + ([LT,GT ..]) = [LT,GT] + ([GT,LT ..]) = [GT,LT] + take 7 (([GT,GT ..])) = [GT,GT,GT,GT,GT,GT,GT] + take 7 (([LT,LT ..])) = [LT,LT,LT,LT,LT,LT,LT] + ([LT .. GT]) = [LT,EQ,GT] + ([LT .. EQ]) = [LT,EQ] + ([LT .. LT]) = [LT] + ([GT .. LT]) = [] + ([GT .. EQ]) = [] + ([GT .. GT]) = [GT] + ([LT,EQ .. GT]) = [LT,EQ,GT] + ([GT,EQ .. LT]) = [GT,EQ,LT] + ([GT,EQ .. EQ]) = [GT,EQ] + ([GT,EQ .. GT]) = [GT] + ([GT,EQ .. LT]) = [GT,EQ,LT] + ([LT,EQ .. LT]) = [LT] + ([LT,EQ .. GT]) = [LT,EQ,GT] + take 7 (([LT,LT .. GT])) = [LT,LT,LT,LT,LT,LT,LT] + take 7 (([GT,GT .. LT])) = [] +Testing Enum Bool: + (succ False) = True + (succ (minBound::Bool)) = True + (succ (maxBound::Bool)) = error "toEnum: out of range" + (pred True) = False + (pred (maxBound::Bool)) = False + (pred (minBound::Bool)) = error "toEnum: out of range" + (toEnum 0)::Bool = False + (toEnum 5)::Bool = error "toEnum: out of range" + (fromEnum False) = 0 + (fromEnum True) = 1 + ([False ..]) = [False,True] + ([True ..]) = [True] + ([False,True ..]) = [False,True] + ([True,False ..]) = [True,False] + (take 7 ([False,False ..])) = [False,False,False,False,False,False,False] + (take 7 ([True,True ..])) = [True,True,True,True,True,True,True] + ([False .. True]) = [False,True] + ([True .. False]) = [] + take 7 ([False,False .. False]) = [False,False,False,False,False,False,False] + take 7 ([False,False .. True]) = [False,False,False,False,False,False,False] + take 7 ([False,True .. False]) = [False] + take 7 ([False,True .. True]) = [False,True] + take 7 ([True,False .. False]) = [True,False] + take 7 ([True,False .. True]) = [True] + take 7 ([True,True .. False]) = [] + take 7 ([True,True .. True]) = [True,True,True,True,True,True,True] +Testing Enum Rational: + (succ (0::Rational)) = 1 % 1 + (succ ((-1)::Rational)) = 0 % 1 + pred (1::Rational) = 0 % 1 + pred (0::Rational) = (-1) % 1 + (map (toEnum::Int->Rational) [1,minBound,maxBound]) = [1 % 1,(-2147483648) % 1,2147483647 % 1] + (map fromEnum [(1::Rational),42,45]) = [1,42,45] + (take 7 [(1::Rational)..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(-5::Rational)..]) = [(-5) % 1,(-4) % 1,(-3) % 1,(-2) % 1,(-1) % 1,0 % 1,1 % 1] + (take 7 [(1::Rational),2..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(1::Rational),7..]) = [1 % 1,7 % 1,13 % 1,19 % 1,25 % 1,31 % 1,37 % 1] + (take 7 [(1::Rational),1..]) = [1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1] + (take 7 [(1::Rational),0..]) = [1 % 1,0 % 1,(-1) % 1,(-2) % 1,(-3) % 1,(-4) % 1,(-5) % 1] + (take 7 [(5::Rational),2..]) = [5 % 1,2 % 1,(-1) % 1,(-4) % 1,(-7) % 1,(-10) % 1,(-13) % 1] + (take 7 ([(1::Rational) .. 5])) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1] + (take 4 ([(1::Rational) .. 1])) = [1 % 1] + (take 7 ([(1::Rational) .. 0])) = [] + (take 7 ([(5::Rational) .. 0])) = [] + (take 7 [(5::Rational),4..1]) = [5 % 1,4 % 1,3 % 1,2 % 1,1 % 1] + (take 7 [(5::Rational),3..1]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(5::Rational),3..2]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(1::Rational),2..1]) = [1 % 1] + (take 7 [(2::Rational),1..2]) = [2 % 1] + (take 7 [(2::Rational),1..1]) = [2 % 1,1 % 1] + (take 7 [(2::Rational),3..1]) = [] +Testing Enum (Ratio Int): + (succ (0::Ratio Int)) = 1 % 1 + (succ ((-1)::Ratio Int)) = 0 % 1 + pred (1::Ratio Int) = 0 % 1 + pred (0::Ratio Int) = (-1) % 1 + (map (toEnum::Int->Ratio Int) [1,minBound,maxBound]) = [1 % 1,(-2147483648) % 1,2147483647 % 1] + (map fromEnum [(1::Ratio Int),42,45]) = [1,42,45] + (take 7 [(1::Ratio Int)..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(-5::Ratio Int)..]) = [(-5) % 1,(-4) % 1,(-3) % 1,(-2) % 1,(-1) % 1,0 % 1,1 % 1] + (take 7 [((toEnum ((maxBound::Int)-5))::Ratio Int)..]) = [2147483642 % 1,2147483643 % 1,2147483644 % 1,2147483645 % 1,2147483646 % 1,2147483647 % 1,(-2147483648) % 1] + (take 7 [(1::Ratio Int),2..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(1::Ratio Int),7..]) = [1 % 1,7 % 1,13 % 1,19 % 1,25 % 1,31 % 1,37 % 1] + (take 7 [(1::Ratio Int),1..]) = [1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1] + (take 7 [(1::Ratio Int),0..]) = [1 % 1,0 % 1,(-1) % 1,(-2) % 1,(-3) % 1,(-4) % 1,(-5) % 1] + (take 7 [(5::Ratio Int),2..]) = [5 % 1,2 % 1,(-1) % 1,(-4) % 1,(-7) % 1,(-10) % 1,(-13) % 1] + (take 7 [x, x-1 ..]) = [(-2147483647) % 1,(-2147483648) % 1,2147483647 % 1,2147483646 % 1,2147483645 % 1,2147483644 % 1,2147483643 % 1] + (take 7 [x, x-1 ..]) = [(-2147483643) % 1,(-2147483644) % 1,(-2147483645) % 1,(-2147483646) % 1,(-2147483647) % 1,(-2147483648) % 1,2147483647 % 1] + (take 7 [x, (x+1) ..]) = [2147483642 % 1,2147483643 % 1,2147483644 % 1,2147483645 % 1,2147483646 % 1,2147483647 % 1,(-2147483648) % 1] + (take 7 ([(1::Ratio Int) .. 5])) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1] + (take 4 ([(1::Ratio Int) .. 1])) = [1 % 1] + (take 7 ([(1::Ratio Int) .. 0])) = [] + (take 7 ([(5::Ratio Int) .. 0])) = [] + (take 7 ([x..y])) = [2147483642 % 1,2147483643 % 1,2147483644 % 1,2147483645 % 1,2147483646 % 1,2147483647 % 1] + (take 7 ([x..y])) = [] + (take 7 [(5::Ratio Int),4..1]) = [5 % 1,4 % 1,3 % 1,2 % 1,1 % 1] + (take 7 [(5::Ratio Int),3..1]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(5::Ratio Int),3..2]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(1::Ratio Int),2..1]) = [1 % 1] + (take 7 [(2::Ratio Int),1..2]) = [2 % 1] + (take 7 [(2::Ratio Int),1..1]) = [2 % 1,1 % 1] + (take 7 [(2::Ratio Int),3..1]) = [] + (take 7 [x,(x+1)..y]) = [2147483643 % 1,2147483644 % 1,2147483645 % 1,2147483646 % 1,2147483647 % 1] + (take 7 [x,(x-1)..y]) = [(-2147483643) % 1,(-2147483644) % 1,(-2147483645) % 1,(-2147483646) % 1,(-2147483647) % 1,(-2147483648) % 1] diff --git a/testsuite/tests/lib/should_run/enum01.stdout-ws-64 b/testsuite/tests/lib/should_run/enum01.stdout-ws-64 new file mode 100644 index 0000000000..3804dd2470 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum01.stdout-ws-64 @@ -0,0 +1,246 @@ +Testing Enum Int: + (succ (0::Int)) = 1 + (succ (minBound::Int)) = -9223372036854775807 + (succ (maxBound::Int)) = error "Prelude.Enum.succ{Int}: tried to take `succ' of maxBound" + pred (1::Int) = 0 + pred (maxBound::Int) = 9223372036854775806 + pred (minBound::Int) = error "Prelude.Enum.pred{Int}: tried to take `pred' of minBound" + (map (toEnum::Int->Int) [1,minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807] + (map fromEnum [(1::Int),minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807] + (take 7 [(1::Int)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int)-5)..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [(1::Int),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-9223372036854775807,-9223372036854775808] + (take 7 [x, x-1 ..]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] + (take 7 [x, (x+1) ..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + ([minBound::Int,1..]) = [-9223372036854775808,1] + ([minBound::Int,0..]) = [-9223372036854775808,0] + ([minBound::Int,-1..]) = [-9223372036854775808,-1,9223372036854775806] + ([maxBound::Int,1..]) = [9223372036854775807,1,-9223372036854775805] + ([maxBound::Int,0..]) = [9223372036854775807,0,-9223372036854775807] + ([maxBound::Int,-1..]) = [9223372036854775807,-1] + (take 7 ([(1::Int) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int) .. 1])) = [1] + (take 7 ([(1::Int) .. 0])) = [] + (take 7 ([(5::Int) .. 0])) = [] + (take 7 ([(maxBound-(5::Int)) .. maxBound])) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(minBound+(5::Int)) .. minBound])) = [] + (take 7 [(5::Int),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int),3..1]) = [5,3,1] + (take 7 [(5::Int),3..2]) = [5,3] + (take 7 [(1::Int),2..1]) = [1] + (take 7 [(2::Int),1..2]) = [2] + (take 7 [(2::Int),1..1]) = [2,1] + (take 7 [(2::Int),3..1]) = [] + ([minBound, 1..maxBound::Int]) = [-9223372036854775808,1] + ([minBound, 0..maxBound::Int]) = [-9223372036854775808,0] + ([minBound,-1..maxBound::Int]) = [-9223372036854775808,-1,9223372036854775806] + ([minBound,-1..maxBound-1::Int]) = [-9223372036854775808,-1,9223372036854775806] + ([minBound,-1..maxBound-2::Int]) = [-9223372036854775808,-1] + ([maxBound, 1..minBound::Int]) = [9223372036854775807,1,-9223372036854775805] + ([maxBound, 0..minBound::Int]) = [9223372036854775807,0,-9223372036854775807] + ([maxBound, 0..minBound+1::Int]) = [9223372036854775807,0,-9223372036854775807] + ([maxBound, 0..minBound+2::Int]) = [9223372036854775807,0] + ([maxBound,-1..minBound::Int]) = [9223372036854775807,-1] + (take 7 [x,(x+1)..maxBound]) = [9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [x,(x-1)..minBound]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] +Testing Enum Integer: + (succ (0::Integer)) = 1 + (succ ((-1)::Integer)) = 0 + pred (1::Integer) = 0 + pred (0::Integer) = -1 + (map (toEnum::Int->Integer) [1,minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807] + (map fromEnum [(1::Integer),42,45]) = [1,42,45] + (take 7 [(1::Integer)..]) = [1,2,3,4,5,6,7] + (take 7 [(-5::Integer)..]) = [-5,-4,-3,-2,-1,0,1] + (take 7 [(1::Integer),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Integer),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Integer),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Integer),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Integer),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 ([(1::Integer) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Integer) .. 1])) = [1] + (take 7 ([(1::Integer) .. 0])) = [] + (take 7 ([(5::Integer) .. 0])) = [] + (take 7 [(5::Integer),4..1]) = [5,4,3,2,1] + (take 7 [(5::Integer),3..1]) = [5,3,1] + (take 7 [(5::Integer),3..2]) = [5,3] + (take 7 [(1::Integer),2..1]) = [1] + (take 7 [(2::Integer),1..2]) = [2] + (take 7 [(2::Integer),1..1]) = [2,1] + (take 7 [(2::Integer),3..1]) = [] +Testing Enum Char: + (succ 'a') = 'b' + (succ (minBound::Char)) = '\SOH' + (succ (maxBound::Char)) = error "Prelude.Enum.Char.succ: bad argument" + (pred 'b') = 'a' + pred (maxBound::Char) = '\1114110' + pred (minBound::Char) = error "Prelude.Enum.Char.pred: bad argument" + (map (toEnum::Int->Char) [123,ord (minBound::Char), ord(maxBound::Char)]) = "{\NUL\1114111" + (toEnum::Int->Char) (minBound::Int) = error "Prelude.chr: bad argument: (-9223372036854775808)" + (map fromEnum ['X',minBound,maxBound]) = [88,0,1114111] + (take 7 ['\NUL' .. ]) = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK" + (take 7 ['\250' .. ]) = "\250\251\252\253\254\255\256" + (take 7 ['a','b'..]) = "abcdefg" + (take 7 ['a','e'..]) = "aeimquy" + (take 7 ['a','a'..]) = "aaaaaaa" + (take 7 ['z','y'..]) = "zyxwvut" + (take 7 ['z','v'..]) = "zvrnjfb" + (take 7 ['\1', '\0' ..]) = "\SOH\NUL" + (take 7 ['\5', '\4' ..]) = "\ENQ\EOT\ETX\STX\SOH\NUL" + (take 7 ['\250', '\251' ..]) = "\250\251\252\253\254\255\256" + (take 7 (['a' .. 'e'])) = "abcde" + (take 4 (['a' .. 'a'])) = "a" + (take 7 (['b' .. 'a'])) = "" + (take 7 (['e' .. 'a'])) = "" + (take 7 (['\250' .. '\255'])) = "\250\251\252\253\254\255" + (take 7 (['\5' .. '\0'])) = "" + (take 7 ['f','e' .. 'b']) = "fedcb" + (take 7 ['g','e' .. 'b']) = "gec" + (take 7 ['g','d' .. 'c']) = "gd" + (take 7 ['b','c' .. 'b']) = "b" + (take 7 ['c','b' .. 'c']) = "c" + (take 7 ['c','b' .. 'b']) = "cb" + (take 7 ['c','d' .. 'b']) = "" + (take 7 ['\251', '\252' .. maxBound]) = "\251\252\253\254\255\256\257" + (take 7 ['\5', '\4' .. minBound]) = "\ENQ\EOT\ETX\STX\SOH\NUL" +Testing Enum (): + (succ ()) = error "Prelude.Enum.().succ: bad argument" + (succ (minBound::())) = error "Prelude.Enum.().succ: bad argument" + (succ (maxBound::())) = error "Prelude.Enum.().succ: bad argument" + (pred ()) = error "Prelude.Enum.().pred: bad argument" + (pred (minBound::())) = error "Prelude.Enum.().pred: bad argument" + (pred (maxBound::())) = error "Prelude.Enum.().pred: bad argument" + (toEnum 0)::() = () + (toEnum 1)::() = error "Prelude.Enum.().toEnum: bad argument" + (fromEnum ()) = 0 + (take 7 [()..]) = [()] + (take 7 [(),()..]) = [(),(),(),(),(),(),()] + (take 7 [()..()]) = [()] + (take 7 [(),()..()]) = [(),(),(),(),(),(),()] +Testing Enum Ordering (derived): + (succ LT) = EQ + (succ (minBound::Ordering)) = EQ + (succ (maxBound::Ordering)) = error "Prelude.Enum.Ordering.succ: bad argument" + (pred GT) = EQ + (pred (maxBound::Ordering)) = EQ + (pred (minBound::Ordering)) = error "Prelude.Enum.Ordering.pred: bad argument" + (toEnum 0)::Ordering = LT + (toEnum 5)::Ordering = error "Prelude.Enum.Ordering.toEnum: bad argument" + (fromEnum LT) = 0 + (fromEnum EQ) = 1 + (fromEnum GT) = 2 + ([LT ..]) = [LT,EQ,GT] + ([EQ ..]) = [EQ,GT] + ([GT ..]) = [GT] + ([LT,EQ ..]) = [LT,EQ,GT] + ([EQ,GT ..]) = [EQ,GT] + ([EQ,LT ..]) = [EQ,LT] + ([LT,GT ..]) = [LT,GT] + ([GT,LT ..]) = [GT,LT] + take 7 (([GT,GT ..])) = [GT,GT,GT,GT,GT,GT,GT] + take 7 (([LT,LT ..])) = [LT,LT,LT,LT,LT,LT,LT] + ([LT .. GT]) = [LT,EQ,GT] + ([LT .. EQ]) = [LT,EQ] + ([LT .. LT]) = [LT] + ([GT .. LT]) = [] + ([GT .. EQ]) = [] + ([GT .. GT]) = [GT] + ([LT,EQ .. GT]) = [LT,EQ,GT] + ([GT,EQ .. LT]) = [GT,EQ,LT] + ([GT,EQ .. EQ]) = [GT,EQ] + ([GT,EQ .. GT]) = [GT] + ([GT,EQ .. LT]) = [GT,EQ,LT] + ([LT,EQ .. LT]) = [LT] + ([LT,EQ .. GT]) = [LT,EQ,GT] + take 7 (([LT,LT .. GT])) = [LT,LT,LT,LT,LT,LT,LT] + take 7 (([GT,GT .. LT])) = [] +Testing Enum Bool: + (succ False) = True + (succ (minBound::Bool)) = True + (succ (maxBound::Bool)) = error "Prelude.Enum.Bool.succ: bad argument" + (pred True) = False + (pred (maxBound::Bool)) = False + (pred (minBound::Bool)) = error "Prelude.Enum.Bool.pred: bad argument" + (toEnum 0)::Bool = False + (toEnum 5)::Bool = error "Prelude.Enum.Bool.toEnum: bad argument" + (fromEnum False) = 0 + (fromEnum True) = 1 + ([False ..]) = [False,True] + ([True ..]) = [True] + ([False,True ..]) = [False,True] + ([True,False ..]) = [True,False] + (take 7 ([False,False ..])) = [False,False,False,False,False,False,False] + (take 7 ([True,True ..])) = [True,True,True,True,True,True,True] + ([False .. True]) = [False,True] + ([True .. False]) = [] + take 7 ([False,False .. False]) = [False,False,False,False,False,False,False] + take 7 ([False,False .. True]) = [False,False,False,False,False,False,False] + take 7 ([False,True .. False]) = [False] + take 7 ([False,True .. True]) = [False,True] + take 7 ([True,False .. False]) = [True,False] + take 7 ([True,False .. True]) = [True] + take 7 ([True,True .. False]) = [] + take 7 ([True,True .. True]) = [True,True,True,True,True,True,True] +Testing Enum Rational: + (succ (0::Rational)) = 1 % 1 + (succ ((-1)::Rational)) = 0 % 1 + pred (1::Rational) = 0 % 1 + pred (0::Rational) = (-1) % 1 + (map (toEnum::Int->Rational) [1,minBound,maxBound]) = [1 % 1,(-9223372036854775808) % 1,9223372036854775807 % 1] + (map fromEnum [(1::Rational),42,45]) = [1,42,45] + (take 7 [(1::Rational)..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(-5::Rational)..]) = [(-5) % 1,(-4) % 1,(-3) % 1,(-2) % 1,(-1) % 1,0 % 1,1 % 1] + (take 7 [(1::Rational),2..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(1::Rational),7..]) = [1 % 1,7 % 1,13 % 1,19 % 1,25 % 1,31 % 1,37 % 1] + (take 7 [(1::Rational),1..]) = [1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1] + (take 7 [(1::Rational),0..]) = [1 % 1,0 % 1,(-1) % 1,(-2) % 1,(-3) % 1,(-4) % 1,(-5) % 1] + (take 7 [(5::Rational),2..]) = [5 % 1,2 % 1,(-1) % 1,(-4) % 1,(-7) % 1,(-10) % 1,(-13) % 1] + (take 7 ([(1::Rational) .. 5])) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1] + (take 4 ([(1::Rational) .. 1])) = [1 % 1] + (take 7 ([(1::Rational) .. 0])) = [] + (take 7 ([(5::Rational) .. 0])) = [] + (take 7 [(5::Rational),4..1]) = [5 % 1,4 % 1,3 % 1,2 % 1,1 % 1] + (take 7 [(5::Rational),3..1]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(5::Rational),3..2]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(1::Rational),2..1]) = [1 % 1] + (take 7 [(2::Rational),1..2]) = [2 % 1] + (take 7 [(2::Rational),1..1]) = [2 % 1,1 % 1] + (take 7 [(2::Rational),3..1]) = [] +Testing Enum (Ratio Int): + (succ (0::Ratio Int)) = 1 % 1 + (succ ((-1)::Ratio Int)) = 0 % 1 + pred (1::Ratio Int) = 0 % 1 + pred (0::Ratio Int) = (-1) % 1 + (map (toEnum::Int->Ratio Int) [1,minBound,maxBound]) = [1 % 1,(-9223372036854775808) % 1,9223372036854775807 % 1] + (map fromEnum [(1::Ratio Int),42,45]) = [1,42,45] + (take 7 [(1::Ratio Int)..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(-5::Ratio Int)..]) = [(-5) % 1,(-4) % 1,(-3) % 1,(-2) % 1,(-1) % 1,0 % 1,1 % 1] + (take 7 [((toEnum ((maxBound::Int)-5))::Ratio Int)..]) = [9223372036854775802 % 1,9223372036854775803 % 1,9223372036854775804 % 1,9223372036854775805 % 1,9223372036854775806 % 1,9223372036854775807 % 1,(-9223372036854775808) % 1] + (take 7 [(1::Ratio Int),2..]) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1,6 % 1,7 % 1] + (take 7 [(1::Ratio Int),7..]) = [1 % 1,7 % 1,13 % 1,19 % 1,25 % 1,31 % 1,37 % 1] + (take 7 [(1::Ratio Int),1..]) = [1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1,1 % 1] + (take 7 [(1::Ratio Int),0..]) = [1 % 1,0 % 1,(-1) % 1,(-2) % 1,(-3) % 1,(-4) % 1,(-5) % 1] + (take 7 [(5::Ratio Int),2..]) = [5 % 1,2 % 1,(-1) % 1,(-4) % 1,(-7) % 1,(-10) % 1,(-13) % 1] + (take 7 [x, x-1 ..]) = [(-9223372036854775807) % 1,(-9223372036854775808) % 1,9223372036854775807 % 1,9223372036854775806 % 1,9223372036854775805 % 1,9223372036854775804 % 1,9223372036854775803 % 1] + (take 7 [x, x-1 ..]) = [(-9223372036854775803) % 1,(-9223372036854775804) % 1,(-9223372036854775805) % 1,(-9223372036854775806) % 1,(-9223372036854775807) % 1,(-9223372036854775808) % 1,9223372036854775807 % 1] + (take 7 [x, (x+1) ..]) = [9223372036854775802 % 1,9223372036854775803 % 1,9223372036854775804 % 1,9223372036854775805 % 1,9223372036854775806 % 1,9223372036854775807 % 1,(-9223372036854775808) % 1] + (take 7 ([(1::Ratio Int) .. 5])) = [1 % 1,2 % 1,3 % 1,4 % 1,5 % 1] + (take 4 ([(1::Ratio Int) .. 1])) = [1 % 1] + (take 7 ([(1::Ratio Int) .. 0])) = [] + (take 7 ([(5::Ratio Int) .. 0])) = [] + (take 7 ([x..y])) = [9223372036854775802 % 1,9223372036854775803 % 1,9223372036854775804 % 1,9223372036854775805 % 1,9223372036854775806 % 1,9223372036854775807 % 1] + (take 7 ([x..y])) = [] + (take 7 [(5::Ratio Int),4..1]) = [5 % 1,4 % 1,3 % 1,2 % 1,1 % 1] + (take 7 [(5::Ratio Int),3..1]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(5::Ratio Int),3..2]) = [5 % 1,3 % 1,1 % 1] + (take 7 [(1::Ratio Int),2..1]) = [1 % 1] + (take 7 [(2::Ratio Int),1..2]) = [2 % 1] + (take 7 [(2::Ratio Int),1..1]) = [2 % 1,1 % 1] + (take 7 [(2::Ratio Int),3..1]) = [] + (take 7 [x,(x+1)..y]) = [9223372036854775803 % 1,9223372036854775804 % 1,9223372036854775805 % 1,9223372036854775806 % 1,9223372036854775807 % 1] + (take 7 [x,(x-1)..y]) = [(-9223372036854775803) % 1,(-9223372036854775804) % 1,(-9223372036854775805) % 1,(-9223372036854775806) % 1,(-9223372036854775807) % 1,(-9223372036854775808) % 1] diff --git a/testsuite/tests/lib/should_run/enum02.hs b/testsuite/tests/lib/should_run/enum02.hs new file mode 100644 index 0000000000..3ba9d4912d --- /dev/null +++ b/testsuite/tests/lib/should_run/enum02.hs @@ -0,0 +1,263 @@ +-- !!! Testing the Int Enum instances. +module Main(main) where + +import Control.Exception +import Prelude hiding (catch) +import Data.Int + +main = do + putStrLn "Testing Enum Int8:" + testEnumInt8 + putStrLn "Testing Enum Int16:" + testEnumInt16 + putStrLn "Testing Enum Int32:" + testEnumInt32 + putStrLn "Testing Enum Int64:" + testEnumInt64 + +#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) }) + +testEnumInt8 :: IO () +testEnumInt8 = do + -- succ + printTest ((succ (0::Int8))) + printTest ((succ (minBound::Int8))) + mayBomb (printTest ((succ (maxBound::Int8)))) + + -- pred + printTest (pred (1::Int8)) + printTest (pred (maxBound::Int8)) + mayBomb (printTest (pred (minBound::Int8))) + + -- toEnum + printTest ((map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)])) + mayBomb (printTest ((toEnum (maxBound::Int))::Int8)) + + -- fromEnum + printTest ((map fromEnum [(1::Int8),minBound,maxBound])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Int8)..])) + printTest ((take 7 [((maxBound::Int8)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Int8),2..])) + printTest ((take 7 [(1::Int8),7..])) + printTest ((take 7 [(1::Int8),1..])) + printTest ((take 7 [(1::Int8),0..])) + printTest ((take 7 [(5::Int8),2..])) + let x = (minBound::Int8) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Int8) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Int8) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Int8) .. 5]))) + printTest ((take 4 ([(1::Int8) .. 1]))) + printTest ((take 7 ([(1::Int8) .. 0]))) + printTest ((take 7 ([(5::Int8) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Int8)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Int8)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Int8),4..1])) + printTest ((take 7 [(5::Int8),3..1])) + printTest ((take 7 [(5::Int8),3..2])) + printTest ((take 7 [(1::Int8),2..1])) + printTest ((take 7 [(2::Int8),1..2])) + printTest ((take 7 [(2::Int8),1..1])) + printTest ((take 7 [(2::Int8),3..1])) + + let x = (maxBound::Int8) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Int8) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + +testEnumInt16 :: IO () +testEnumInt16 = do + -- succ + printTest ((succ (0::Int16))) + printTest ((succ (minBound::Int16))) + mayBomb (printTest ((succ (maxBound::Int16)))) + + -- pred + printTest (pred (1::Int16)) + printTest (pred (maxBound::Int16)) + mayBomb (printTest (pred (minBound::Int16))) + + -- toEnum + printTest ((map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)])) + mayBomb (printTest ((toEnum (maxBound::Int))::Int16)) + + + -- fromEnum + printTest ((map fromEnum [(1::Int16),minBound,maxBound])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Int16)..])) + printTest ((take 7 [((maxBound::Int16)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Int16),2..])) + printTest ((take 7 [(1::Int16),7..])) + printTest ((take 7 [(1::Int16),1..])) + printTest ((take 7 [(1::Int16),0..])) + printTest ((take 7 [(5::Int16),2..])) + let x = (minBound::Int16) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Int16) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Int16) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Int16) .. 5]))) + printTest ((take 4 ([(1::Int16) .. 1]))) + printTest ((take 7 ([(1::Int16) .. 0]))) + printTest ((take 7 ([(5::Int16) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Int16)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Int16)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Int16),4..1])) + printTest ((take 7 [(5::Int16),3..1])) + printTest ((take 7 [(5::Int16),3..2])) + printTest ((take 7 [(1::Int16),2..1])) + printTest ((take 7 [(2::Int16),1..2])) + printTest ((take 7 [(2::Int16),1..1])) + printTest ((take 7 [(2::Int16),3..1])) + + let x = (maxBound::Int16) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Int16) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + +testEnumInt32 :: IO () +testEnumInt32 = do + -- succ + printTest ((succ (0::Int32))) + printTest ((succ (minBound::Int32))) + mayBomb (printTest ((succ (maxBound::Int32)))) + + -- pred + printTest (pred (1::Int32)) + printTest (pred (maxBound::Int32)) + mayBomb (printTest (pred (minBound::Int32))) + + -- toEnum + printTest ((map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)])) + mayBomb (printTest ((toEnum (maxBound::Int))::Int32)) + + -- fromEnum + printTest ((map fromEnum [(1::Int32),minBound,maxBound])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Int32)..])) + printTest ((take 7 [((maxBound::Int32)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Int32),2..])) + printTest ((take 7 [(1::Int32),7..])) + printTest ((take 7 [(1::Int32),1..])) + printTest ((take 7 [(1::Int32),0..])) + printTest ((take 7 [(5::Int32),2..])) + let x = (minBound::Int32) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Int32) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Int32) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Int32) .. 5]))) + printTest ((take 4 ([(1::Int32) .. 1]))) + printTest ((take 7 ([(1::Int32) .. 0]))) + printTest ((take 7 ([(5::Int32) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Int32)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Int32)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Int32),4..1])) + printTest ((take 7 [(5::Int32),3..1])) + printTest ((take 7 [(5::Int32),3..2])) + printTest ((take 7 [(1::Int32),2..1])) + printTest ((take 7 [(2::Int32),1..2])) + printTest ((take 7 [(2::Int32),1..1])) + printTest ((take 7 [(2::Int32),3..1])) + + let x = (maxBound::Int32) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Int32) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + +testEnumInt64 :: IO () +testEnumInt64 = do + -- succ + printTest ((succ (0::Int64))) + printTest ((succ (minBound::Int64))) + mayBomb (printTest ((succ (maxBound::Int64)))) + + -- pred + printTest (pred (1::Int64)) + printTest (pred (maxBound::Int64)) + mayBomb (printTest (pred (minBound::Int64))) + + -- toEnum + mayBomb (printTest ((map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]))) + mayBomb (printTest ((toEnum (maxBound::Int))::Int64)) + + -- fromEnum + printTest ((map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)])) + mayBomb (printTest (fromEnum (maxBound::Int64))) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Int64)..])) + printTest ((take 7 [((maxBound::Int64)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Int64),2..])) + printTest ((take 7 [(1::Int64),7..])) + printTest ((take 7 [(1::Int64),1..])) + printTest ((take 7 [(1::Int64),0..])) + printTest ((take 7 [(5::Int64),2..])) + let x = (minBound::Int64) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Int64) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Int64) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Int64) .. 5]))) + printTest ((take 4 ([(1::Int64) .. 1]))) + printTest ((take 7 ([(1::Int64) .. 0]))) + printTest ((take 7 ([(5::Int64) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Int64)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Int64)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Int64),4..1])) + printTest ((take 7 [(5::Int64),3..1])) + printTest ((take 7 [(5::Int64),3..2])) + printTest ((take 7 [(1::Int64),2..1])) + printTest ((take 7 [(2::Int64),1..2])) + printTest ((take 7 [(2::Int64),1..1])) + printTest ((take 7 [(2::Int64),3..1])) + + let x = (maxBound::Int64) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Int64) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + + +-- +-- +-- Utils +-- +-- + + +mayBomb x = catch x (\(ErrorCall e) -> putStrLn ("error " ++ show e)) + `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeException))) diff --git a/testsuite/tests/lib/should_run/enum02.stdout b/testsuite/tests/lib/should_run/enum02.stdout new file mode 100644 index 0000000000..06d3bb5cae --- /dev/null +++ b/testsuite/tests/lib/should_run/enum02.stdout @@ -0,0 +1,141 @@ +Testing Enum Int8: + (succ (0::Int8)) = 1 + (succ (minBound::Int8)) = -127 + (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound" + pred (1::Int8) = 0 + pred (maxBound::Int8) = 126 + pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound" + (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127] + (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (2147483647) is outside of bounds (-128,127)" + (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127] + (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127] + (take 7 [(1::Int8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int8),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int8),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-127,-128] + (take 7 [x, x-1 ..]) = [-123,-124,-125,-126,-127,-128] + (take 7 [x, (x+1) ..]) = [122,123,124,125,126,127] + (take 7 ([(1::Int8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int8) .. 1])) = [1] + (take 7 ([(1::Int8) .. 0])) = [] + (take 7 ([(5::Int8) .. 0])) = [] + (take 7 ([(maxBound-(5::Int8)) .. maxBound])) = [122,123,124,125,126,127] + (take 7 ([(minBound+(5::Int8)) .. minBound])) = [] + (take 7 [(5::Int8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int8),3..1]) = [5,3,1] + (take 7 [(5::Int8),3..2]) = [5,3] + (take 7 [(1::Int8),2..1]) = [1] + (take 7 [(2::Int8),1..2]) = [2] + (take 7 [(2::Int8),1..1]) = [2,1] + (take 7 [(2::Int8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [123,124,125,126,127] + (take 7 [x,(x-1)..minBound]) = [-123,-124,-125,-126,-127,-128] +Testing Enum Int16: + (succ (0::Int16)) = 1 + (succ (minBound::Int16)) = -32767 + (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound" + pred (1::Int16) = 0 + pred (maxBound::Int16) = 32766 + pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound" + (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767] + (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (2147483647) is outside of bounds (-32768,32767)" + (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767] + (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767] + (take 7 [(1::Int16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int16),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int16),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-32767,-32768] + (take 7 [x, x-1 ..]) = [-32763,-32764,-32765,-32766,-32767,-32768] + (take 7 [x, (x+1) ..]) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(1::Int16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int16) .. 1])) = [1] + (take 7 ([(1::Int16) .. 0])) = [] + (take 7 ([(5::Int16) .. 0])) = [] + (take 7 ([(maxBound-(5::Int16)) .. maxBound])) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(minBound+(5::Int16)) .. minBound])) = [] + (take 7 [(5::Int16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int16),3..1]) = [5,3,1] + (take 7 [(5::Int16),3..2]) = [5,3] + (take 7 [(1::Int16),2..1]) = [1] + (take 7 [(2::Int16),1..2]) = [2] + (take 7 [(2::Int16),1..1]) = [2,1] + (take 7 [(2::Int16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [32763,32764,32765,32766,32767] + (take 7 [x,(x-1)..minBound]) = [-32763,-32764,-32765,-32766,-32767,-32768] +Testing Enum Int32: + (succ (0::Int32)) = 1 + (succ (minBound::Int32)) = -2147483647 + (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound" + pred (1::Int32) = 0 + pred (maxBound::Int32) = 2147483646 + pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound" + (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647] + (toEnum (maxBound::Int))::Int32 = 2147483647 + (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647] + (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [(1::Int32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int32),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int32),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-2147483647,-2147483648] + (take 7 [x, x-1 ..]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] + (take 7 [x, (x+1) ..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(1::Int32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int32) .. 1])) = [1] + (take 7 ([(1::Int32) .. 0])) = [] + (take 7 ([(5::Int32) .. 0])) = [] + (take 7 ([(maxBound-(5::Int32)) .. maxBound])) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(minBound+(5::Int32)) .. minBound])) = [] + (take 7 [(5::Int32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int32),3..1]) = [5,3,1] + (take 7 [(5::Int32),3..2]) = [5,3] + (take 7 [(1::Int32),2..1]) = [1] + (take 7 [(2::Int32),1..2]) = [2] + (take 7 [(2::Int32),1..1]) = [2,1] + (take 7 [(2::Int32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [x,(x-1)..minBound]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] +Testing Enum Int64: + (succ (0::Int64)) = 1 + (succ (minBound::Int64)) = -9223372036854775807 + (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound" + pred (1::Int64) = 0 + pred (maxBound::Int64) = 9223372036854775806 + pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound" + (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,0,-1] + (toEnum (maxBound::Int))::Int64 = 2147483647 + (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-2147483648,2147483647] + fromEnum (maxBound::Int64) = error "Enum.fromEnum{Int64}: value (9223372036854775807) is outside of Int's bounds (-2147483648,2147483647)" + (take 7 [(1::Int64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int64)-5)..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [(1::Int64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int64),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int64),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-9223372036854775807,-9223372036854775808] + (take 7 [x, x-1 ..]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] + (take 7 [x, (x+1) ..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(1::Int64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int64) .. 1])) = [1] + (take 7 ([(1::Int64) .. 0])) = [] + (take 7 ([(5::Int64) .. 0])) = [] + (take 7 ([(maxBound-(5::Int64)) .. maxBound])) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(minBound+(5::Int64)) .. minBound])) = [] + (take 7 [(5::Int64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int64),3..1]) = [5,3,1] + (take 7 [(5::Int64),3..2]) = [5,3] + (take 7 [(1::Int64),2..1]) = [1] + (take 7 [(2::Int64),1..2]) = [2] + (take 7 [(2::Int64),1..1]) = [2,1] + (take 7 [(2::Int64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [x,(x-1)..minBound]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] diff --git a/testsuite/tests/lib/should_run/enum02.stdout-alpha-dec-osf3 b/testsuite/tests/lib/should_run/enum02.stdout-alpha-dec-osf3 new file mode 100644 index 0000000000..23222450b5 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum02.stdout-alpha-dec-osf3 @@ -0,0 +1,141 @@ +Testing Enum Int8: + (succ (0::Int8)) = 1 + (succ (minBound::Int8)) = -127 + (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound" + pred (1::Int8) = 0 + pred (maxBound::Int8) = 126 + pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound" + (map (toEnum::Int->Int8) [1, toInt (minBound::Int8), toInt (maxBound::Int8)]) = [1,-128,127] + (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of bounds (-128,127)" + (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127] + (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127] + (take 7 [(1::Int8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int8),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int8),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-127,-128] + (take 7 [x, x-1 ..]) = [-123,-124,-125,-126,-127,-128] + (take 7 [x, (x+1) ..]) = [122,123,124,125,126,127] + (take 7 ([(1::Int8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int8) .. 1])) = [1] + (take 7 ([(1::Int8) .. 0])) = [] + (take 7 ([(5::Int8) .. 0])) = [] + (take 7 ([(maxBound-(5::Int8)) .. maxBound])) = [122,123,124,125,126,127] + (take 7 ([(minBound+(5::Int8)) .. minBound])) = [] + (take 7 [(5::Int8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int8),3..1]) = [5,3,1] + (take 7 [(5::Int8),3..2]) = [5,3] + (take 7 [(1::Int8),2..1]) = [1] + (take 7 [(2::Int8),1..2]) = [2] + (take 7 [(2::Int8),1..1]) = [2,1] + (take 7 [(2::Int8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [123,124,125,126,127] + (take 7 [x,(x-1)..minBound]) = [-123,-124,-125,-126,-127,-128] +Testing Enum Int16: + (succ (0::Int16)) = 1 + (succ (minBound::Int16)) = -32767 + (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound" + pred (1::Int16) = 0 + pred (maxBound::Int16) = 32766 + pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound" + (map (toEnum::Int->Int16) [1, toInt (minBound::Int16), toInt (maxBound::Int16)]) = [1,-32768,32767] + (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of bounds (-32768,32767)" + (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767] + (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767] + (take 7 [(1::Int16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int16),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int16),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-32767,-32768] + (take 7 [x, x-1 ..]) = [-32763,-32764,-32765,-32766,-32767,-32768] + (take 7 [x, (x+1) ..]) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(1::Int16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int16) .. 1])) = [1] + (take 7 ([(1::Int16) .. 0])) = [] + (take 7 ([(5::Int16) .. 0])) = [] + (take 7 ([(maxBound-(5::Int16)) .. maxBound])) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(minBound+(5::Int16)) .. minBound])) = [] + (take 7 [(5::Int16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int16),3..1]) = [5,3,1] + (take 7 [(5::Int16),3..2]) = [5,3] + (take 7 [(1::Int16),2..1]) = [1] + (take 7 [(2::Int16),1..2]) = [2] + (take 7 [(2::Int16),1..1]) = [2,1] + (take 7 [(2::Int16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [32763,32764,32765,32766,32767] + (take 7 [x,(x-1)..minBound]) = [-32763,-32764,-32765,-32766,-32767,-32768] +Testing Enum Int32: + (succ (0::Int32)) = 1 + (succ (minBound::Int32)) = -2147483647 + (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound" + pred (1::Int32) = 0 + pred (maxBound::Int32) = 2147483646 + pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound" + (map (toEnum::Int->Int32) [1, toInt (minBound::Int32), toInt (maxBound::Int32)]) = [1,-2147483648,2147483647] + (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of bounds (-2147483648,2147483647)" + (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647] + (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [(1::Int32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int32),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int32),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-2147483647,-2147483648] + (take 7 [x, x-1 ..]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] + (take 7 [x, (x+1) ..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(1::Int32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int32) .. 1])) = [1] + (take 7 ([(1::Int32) .. 0])) = [] + (take 7 ([(5::Int32) .. 0])) = [] + (take 7 ([(maxBound-(5::Int32)) .. maxBound])) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(minBound+(5::Int32)) .. minBound])) = [] + (take 7 [(5::Int32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int32),3..1]) = [5,3,1] + (take 7 [(5::Int32),3..2]) = [5,3] + (take 7 [(1::Int32),2..1]) = [1] + (take 7 [(2::Int32),1..2]) = [2] + (take 7 [(2::Int32),1..1]) = [2,1] + (take 7 [(2::Int32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [x,(x-1)..minBound]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] +Testing Enum Int64: + (succ (0::Int64)) = 1 + (succ (minBound::Int64)) = -9223372036854775807 + (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound" + pred (1::Int64) = 0 + pred (maxBound::Int64) = 9223372036854775806 + pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound" + (map (toEnum::Int->Int64) [1, toInt (minBound::Int64), toInt (maxBound::Int64)]) = [1,-9223372036854775808,9223372036854775807] + (toEnum (maxBound::Int))::Int64 = 9223372036854775807 + (map fromEnum [(1::Int64),fromInt (minBound::Int) ,fromInt (maxBound::Int)]) = [1,-9223372036854775808,9223372036854775807] + fromEnum (maxBound::Int64) = 9223372036854775807 + (take 7 [(1::Int64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int64)-5)..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [(1::Int64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int64),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int64),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-9223372036854775807,-9223372036854775808] + (take 7 [x, x-1 ..]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] + (take 7 [x, (x+1) ..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(1::Int64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int64) .. 1])) = [1] + (take 7 ([(1::Int64) .. 0])) = [] + (take 7 ([(5::Int64) .. 0])) = [] + (take 7 ([(maxBound-(5::Int64)) .. maxBound])) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(minBound+(5::Int64)) .. minBound])) = [] + (take 7 [(5::Int64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int64),3..1]) = [5,3,1] + (take 7 [(5::Int64),3..2]) = [5,3] + (take 7 [(1::Int64),2..1]) = [1] + (take 7 [(2::Int64),1..2]) = [2] + (take 7 [(2::Int64),1..1]) = [2,1] + (take 7 [(2::Int64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [x,(x-1)..minBound]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] diff --git a/testsuite/tests/lib/should_run/enum02.stdout-hugs b/testsuite/tests/lib/should_run/enum02.stdout-hugs new file mode 100644 index 0000000000..a28b84b187 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum02.stdout-hugs @@ -0,0 +1,141 @@ +Testing Enum Int8: + (succ (0::Int8)) = 1 + (succ (minBound::Int8)) = -127 + (succ (maxBound::Int8)) = error "succ: applied to maxBound" + pred (1::Int8) = 0 + pred (maxBound::Int8) = 126 + pred (minBound::Int8) = error "pred: applied to minBound" + (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127] + (toEnum (maxBound::Int))::Int8 = -1 + (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127] + (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127] + (take 7 [(1::Int8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int8),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int8),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-127,-128] + (take 7 [x, x-1 ..]) = [-123,-124,-125,-126,-127,-128] + (take 7 [x, (x+1) ..]) = [122,123,124,125,126,127] + (take 7 ([(1::Int8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int8) .. 1])) = [1] + (take 7 ([(1::Int8) .. 0])) = [] + (take 7 ([(5::Int8) .. 0])) = [] + (take 7 ([(maxBound-(5::Int8)) .. maxBound])) = [122,123,124,125,126,127] + (take 7 ([(minBound+(5::Int8)) .. minBound])) = [] + (take 7 [(5::Int8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int8),3..1]) = [5,3,1] + (take 7 [(5::Int8),3..2]) = [5,3] + (take 7 [(1::Int8),2..1]) = [1] + (take 7 [(2::Int8),1..2]) = [2] + (take 7 [(2::Int8),1..1]) = [2,1] + (take 7 [(2::Int8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [123,124,125,126,127] + (take 7 [x,(x-1)..minBound]) = [-123,-124,-125,-126,-127,-128] +Testing Enum Int16: + (succ (0::Int16)) = 1 + (succ (minBound::Int16)) = -32767 + (succ (maxBound::Int16)) = error "succ: applied to maxBound" + pred (1::Int16) = 0 + pred (maxBound::Int16) = 32766 + pred (minBound::Int16) = error "pred: applied to minBound" + (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767] + (toEnum (maxBound::Int))::Int16 = -1 + (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767] + (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767] + (take 7 [(1::Int16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int16),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int16),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-32767,-32768] + (take 7 [x, x-1 ..]) = [-32763,-32764,-32765,-32766,-32767,-32768] + (take 7 [x, (x+1) ..]) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(1::Int16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int16) .. 1])) = [1] + (take 7 ([(1::Int16) .. 0])) = [] + (take 7 ([(5::Int16) .. 0])) = [] + (take 7 ([(maxBound-(5::Int16)) .. maxBound])) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(minBound+(5::Int16)) .. minBound])) = [] + (take 7 [(5::Int16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int16),3..1]) = [5,3,1] + (take 7 [(5::Int16),3..2]) = [5,3] + (take 7 [(1::Int16),2..1]) = [1] + (take 7 [(2::Int16),1..2]) = [2] + (take 7 [(2::Int16),1..1]) = [2,1] + (take 7 [(2::Int16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [32763,32764,32765,32766,32767] + (take 7 [x,(x-1)..minBound]) = [-32763,-32764,-32765,-32766,-32767,-32768] +Testing Enum Int32: + (succ (0::Int32)) = 1 + (succ (minBound::Int32)) = -2147483647 + (succ (maxBound::Int32)) = error "succ: applied to maxBound" + pred (1::Int32) = 0 + pred (maxBound::Int32) = 2147483646 + pred (minBound::Int32) = error "pred: applied to minBound" + (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647] + (toEnum (maxBound::Int))::Int32 = 2147483647 + (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647] + (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [(1::Int32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int32),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int32),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-2147483647,-2147483648] + (take 7 [x, x-1 ..]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] + (take 7 [x, (x+1) ..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(1::Int32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int32) .. 1])) = [1] + (take 7 ([(1::Int32) .. 0])) = [] + (take 7 ([(5::Int32) .. 0])) = [] + (take 7 ([(maxBound-(5::Int32)) .. maxBound])) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(minBound+(5::Int32)) .. minBound])) = [] + (take 7 [(5::Int32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int32),3..1]) = [5,3,1] + (take 7 [(5::Int32),3..2]) = [5,3] + (take 7 [(1::Int32),2..1]) = [1] + (take 7 [(2::Int32),1..2]) = [2] + (take 7 [(2::Int32),1..1]) = [2,1] + (take 7 [(2::Int32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [x,(x-1)..minBound]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] +Testing Enum Int64: + (succ (0::Int64)) = 1 + (succ (minBound::Int64)) = -9223372036854775807 + (succ (maxBound::Int64)) = error "succ: applied to maxBound" + pred (1::Int64) = 0 + pred (maxBound::Int64) = 9223372036854775806 + pred (minBound::Int64) = error "pred: applied to minBound" + (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,Fail: arithmetic overflow + (toEnum (maxBound::Int))::Int64 = 2147483647 + (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-2147483648,2147483647] + fromEnum (maxBound::Int64) = Fail: arithmetic overflow + (take 7 [(1::Int64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int64)-5)..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [(1::Int64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int64),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int64),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-9223372036854775807,-9223372036854775808] + (take 7 [x, x-1 ..]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] + (take 7 [x, (x+1) ..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(1::Int64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int64) .. 1])) = [1] + (take 7 ([(1::Int64) .. 0])) = [] + (take 7 ([(5::Int64) .. 0])) = [] + (take 7 ([(maxBound-(5::Int64)) .. maxBound])) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(minBound+(5::Int64)) .. minBound])) = [] + (take 7 [(5::Int64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int64),3..1]) = [5,3,1] + (take 7 [(5::Int64),3..2]) = [5,3] + (take 7 [(1::Int64),2..1]) = [1] + (take 7 [(2::Int64),1..2]) = [2] + (take 7 [(2::Int64),1..1]) = [2,1] + (take 7 [(2::Int64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [x,(x-1)..minBound]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] diff --git a/testsuite/tests/lib/should_run/enum02.stdout-mips-sgi-irix b/testsuite/tests/lib/should_run/enum02.stdout-mips-sgi-irix new file mode 100644 index 0000000000..3177d541f4 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum02.stdout-mips-sgi-irix @@ -0,0 +1,141 @@ +Testing Enum Int8: + (succ (0::Int8)) = 1 + (succ (minBound::Int8)) = -127 + (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound" + pred (1::Int8) = 0 + pred (maxBound::Int8) = 126 + pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound" + (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127] + (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of bounds (-128,127)" + (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127] + (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127] + (take 7 [(1::Int8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int8),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int8),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-127,-128] + (take 7 [x, x-1 ..]) = [-123,-124,-125,-126,-127,-128] + (take 7 [x, (x+1) ..]) = [122,123,124,125,126,127] + (take 7 ([(1::Int8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int8) .. 1])) = [1] + (take 7 ([(1::Int8) .. 0])) = [] + (take 7 ([(5::Int8) .. 0])) = [] + (take 7 ([(maxBound-(5::Int8)) .. maxBound])) = [122,123,124,125,126,127] + (take 7 ([(minBound+(5::Int8)) .. minBound])) = [] + (take 7 [(5::Int8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int8),3..1]) = [5,3,1] + (take 7 [(5::Int8),3..2]) = [5,3] + (take 7 [(1::Int8),2..1]) = [1] + (take 7 [(2::Int8),1..2]) = [2] + (take 7 [(2::Int8),1..1]) = [2,1] + (take 7 [(2::Int8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [123,124,125,126,127] + (take 7 [x,(x-1)..minBound]) = [-123,-124,-125,-126,-127,-128] +Testing Enum Int16: + (succ (0::Int16)) = 1 + (succ (minBound::Int16)) = -32767 + (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound" + pred (1::Int16) = 0 + pred (maxBound::Int16) = 32766 + pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound" + (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767] + (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of bounds (-32768,32767)" + (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767] + (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767] + (take 7 [(1::Int16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int16),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int16),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-32767,-32768] + (take 7 [x, x-1 ..]) = [-32763,-32764,-32765,-32766,-32767,-32768] + (take 7 [x, (x+1) ..]) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(1::Int16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int16) .. 1])) = [1] + (take 7 ([(1::Int16) .. 0])) = [] + (take 7 ([(5::Int16) .. 0])) = [] + (take 7 ([(maxBound-(5::Int16)) .. maxBound])) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(minBound+(5::Int16)) .. minBound])) = [] + (take 7 [(5::Int16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int16),3..1]) = [5,3,1] + (take 7 [(5::Int16),3..2]) = [5,3] + (take 7 [(1::Int16),2..1]) = [1] + (take 7 [(2::Int16),1..2]) = [2] + (take 7 [(2::Int16),1..1]) = [2,1] + (take 7 [(2::Int16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [32763,32764,32765,32766,32767] + (take 7 [x,(x-1)..minBound]) = [-32763,-32764,-32765,-32766,-32767,-32768] +Testing Enum Int32: + (succ (0::Int32)) = 1 + (succ (minBound::Int32)) = -2147483647 + (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound" + pred (1::Int32) = 0 + pred (maxBound::Int32) = 2147483646 + pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound" + (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647] + (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of bounds (-2147483648,2147483647)" + (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647] + (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [(1::Int32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int32),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int32),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-2147483647,-2147483648] + (take 7 [x, x-1 ..]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] + (take 7 [x, (x+1) ..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(1::Int32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int32) .. 1])) = [1] + (take 7 ([(1::Int32) .. 0])) = [] + (take 7 ([(5::Int32) .. 0])) = [] + (take 7 ([(maxBound-(5::Int32)) .. maxBound])) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(minBound+(5::Int32)) .. minBound])) = [] + (take 7 [(5::Int32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int32),3..1]) = [5,3,1] + (take 7 [(5::Int32),3..2]) = [5,3] + (take 7 [(1::Int32),2..1]) = [1] + (take 7 [(2::Int32),1..2]) = [2] + (take 7 [(2::Int32),1..1]) = [2,1] + (take 7 [(2::Int32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [x,(x-1)..minBound]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] +Testing Enum Int64: + (succ (0::Int64)) = 1 + (succ (minBound::Int64)) = -9223372036854775807 + (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound" + pred (1::Int64) = 0 + pred (maxBound::Int64) = 9223372036854775806 + pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound" + (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,-9223372036854775808,9223372036854775807] + (toEnum (maxBound::Int))::Int64 = 9223372036854775807 + (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-9223372036854775808,9223372036854775807] + fromEnum (maxBound::Int64) = 9223372036854775807 + (take 7 [(1::Int64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int64)-5)..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [(1::Int64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int64),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int64),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-9223372036854775807,-9223372036854775808] + (take 7 [x, x-1 ..]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] + (take 7 [x, (x+1) ..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(1::Int64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int64) .. 1])) = [1] + (take 7 ([(1::Int64) .. 0])) = [] + (take 7 ([(5::Int64) .. 0])) = [] + (take 7 ([(maxBound-(5::Int64)) .. maxBound])) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(minBound+(5::Int64)) .. minBound])) = [] + (take 7 [(5::Int64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int64),3..1]) = [5,3,1] + (take 7 [(5::Int64),3..2]) = [5,3] + (take 7 [(1::Int64),2..1]) = [1] + (take 7 [(2::Int64),1..2]) = [2] + (take 7 [(2::Int64),1..1]) = [2,1] + (take 7 [(2::Int64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [x,(x-1)..minBound]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] diff --git a/testsuite/tests/lib/should_run/enum02.stdout-ws-64 b/testsuite/tests/lib/should_run/enum02.stdout-ws-64 new file mode 100644 index 0000000000..3177d541f4 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum02.stdout-ws-64 @@ -0,0 +1,141 @@ +Testing Enum Int8: + (succ (0::Int8)) = 1 + (succ (minBound::Int8)) = -127 + (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound" + pred (1::Int8) = 0 + pred (maxBound::Int8) = 126 + pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound" + (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127] + (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of bounds (-128,127)" + (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127] + (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127] + (take 7 [(1::Int8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int8),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int8),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-127,-128] + (take 7 [x, x-1 ..]) = [-123,-124,-125,-126,-127,-128] + (take 7 [x, (x+1) ..]) = [122,123,124,125,126,127] + (take 7 ([(1::Int8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int8) .. 1])) = [1] + (take 7 ([(1::Int8) .. 0])) = [] + (take 7 ([(5::Int8) .. 0])) = [] + (take 7 ([(maxBound-(5::Int8)) .. maxBound])) = [122,123,124,125,126,127] + (take 7 ([(minBound+(5::Int8)) .. minBound])) = [] + (take 7 [(5::Int8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int8),3..1]) = [5,3,1] + (take 7 [(5::Int8),3..2]) = [5,3] + (take 7 [(1::Int8),2..1]) = [1] + (take 7 [(2::Int8),1..2]) = [2] + (take 7 [(2::Int8),1..1]) = [2,1] + (take 7 [(2::Int8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [123,124,125,126,127] + (take 7 [x,(x-1)..minBound]) = [-123,-124,-125,-126,-127,-128] +Testing Enum Int16: + (succ (0::Int16)) = 1 + (succ (minBound::Int16)) = -32767 + (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound" + pred (1::Int16) = 0 + pred (maxBound::Int16) = 32766 + pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound" + (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767] + (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of bounds (-32768,32767)" + (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767] + (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767] + (take 7 [(1::Int16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int16),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int16),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-32767,-32768] + (take 7 [x, x-1 ..]) = [-32763,-32764,-32765,-32766,-32767,-32768] + (take 7 [x, (x+1) ..]) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(1::Int16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int16) .. 1])) = [1] + (take 7 ([(1::Int16) .. 0])) = [] + (take 7 ([(5::Int16) .. 0])) = [] + (take 7 ([(maxBound-(5::Int16)) .. maxBound])) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(minBound+(5::Int16)) .. minBound])) = [] + (take 7 [(5::Int16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int16),3..1]) = [5,3,1] + (take 7 [(5::Int16),3..2]) = [5,3] + (take 7 [(1::Int16),2..1]) = [1] + (take 7 [(2::Int16),1..2]) = [2] + (take 7 [(2::Int16),1..1]) = [2,1] + (take 7 [(2::Int16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [32763,32764,32765,32766,32767] + (take 7 [x,(x-1)..minBound]) = [-32763,-32764,-32765,-32766,-32767,-32768] +Testing Enum Int32: + (succ (0::Int32)) = 1 + (succ (minBound::Int32)) = -2147483647 + (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound" + pred (1::Int32) = 0 + pred (maxBound::Int32) = 2147483646 + pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound" + (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647] + (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of bounds (-2147483648,2147483647)" + (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647] + (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [(1::Int32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int32),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int32),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-2147483647,-2147483648] + (take 7 [x, x-1 ..]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] + (take 7 [x, (x+1) ..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(1::Int32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int32) .. 1])) = [1] + (take 7 ([(1::Int32) .. 0])) = [] + (take 7 ([(5::Int32) .. 0])) = [] + (take 7 ([(maxBound-(5::Int32)) .. maxBound])) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(minBound+(5::Int32)) .. minBound])) = [] + (take 7 [(5::Int32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int32),3..1]) = [5,3,1] + (take 7 [(5::Int32),3..2]) = [5,3] + (take 7 [(1::Int32),2..1]) = [1] + (take 7 [(2::Int32),1..2]) = [2] + (take 7 [(2::Int32),1..1]) = [2,1] + (take 7 [(2::Int32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [x,(x-1)..minBound]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] +Testing Enum Int64: + (succ (0::Int64)) = 1 + (succ (minBound::Int64)) = -9223372036854775807 + (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound" + pred (1::Int64) = 0 + pred (maxBound::Int64) = 9223372036854775806 + pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound" + (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,-9223372036854775808,9223372036854775807] + (toEnum (maxBound::Int))::Int64 = 9223372036854775807 + (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-9223372036854775808,9223372036854775807] + fromEnum (maxBound::Int64) = 9223372036854775807 + (take 7 [(1::Int64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int64)-5)..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [(1::Int64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int64),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int64),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-9223372036854775807,-9223372036854775808] + (take 7 [x, x-1 ..]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] + (take 7 [x, (x+1) ..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(1::Int64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int64) .. 1])) = [1] + (take 7 ([(1::Int64) .. 0])) = [] + (take 7 ([(5::Int64) .. 0])) = [] + (take 7 ([(maxBound-(5::Int64)) .. maxBound])) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(minBound+(5::Int64)) .. minBound])) = [] + (take 7 [(5::Int64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int64),3..1]) = [5,3,1] + (take 7 [(5::Int64),3..2]) = [5,3] + (take 7 [(1::Int64),2..1]) = [1] + (take 7 [(2::Int64),1..2]) = [2] + (take 7 [(2::Int64),1..1]) = [2,1] + (take 7 [(2::Int64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [x,(x-1)..minBound]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] diff --git a/testsuite/tests/lib/should_run/enum02.stdout-x86_64-unknown-openbsd b/testsuite/tests/lib/should_run/enum02.stdout-x86_64-unknown-openbsd new file mode 100644 index 0000000000..3177d541f4 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum02.stdout-x86_64-unknown-openbsd @@ -0,0 +1,141 @@ +Testing Enum Int8: + (succ (0::Int8)) = 1 + (succ (minBound::Int8)) = -127 + (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound" + pred (1::Int8) = 0 + pred (maxBound::Int8) = 126 + pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound" + (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127] + (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of bounds (-128,127)" + (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127] + (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127] + (take 7 [(1::Int8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int8),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int8),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-127,-128] + (take 7 [x, x-1 ..]) = [-123,-124,-125,-126,-127,-128] + (take 7 [x, (x+1) ..]) = [122,123,124,125,126,127] + (take 7 ([(1::Int8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int8) .. 1])) = [1] + (take 7 ([(1::Int8) .. 0])) = [] + (take 7 ([(5::Int8) .. 0])) = [] + (take 7 ([(maxBound-(5::Int8)) .. maxBound])) = [122,123,124,125,126,127] + (take 7 ([(minBound+(5::Int8)) .. minBound])) = [] + (take 7 [(5::Int8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int8),3..1]) = [5,3,1] + (take 7 [(5::Int8),3..2]) = [5,3] + (take 7 [(1::Int8),2..1]) = [1] + (take 7 [(2::Int8),1..2]) = [2] + (take 7 [(2::Int8),1..1]) = [2,1] + (take 7 [(2::Int8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [123,124,125,126,127] + (take 7 [x,(x-1)..minBound]) = [-123,-124,-125,-126,-127,-128] +Testing Enum Int16: + (succ (0::Int16)) = 1 + (succ (minBound::Int16)) = -32767 + (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound" + pred (1::Int16) = 0 + pred (maxBound::Int16) = 32766 + pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound" + (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767] + (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of bounds (-32768,32767)" + (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767] + (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767] + (take 7 [(1::Int16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int16),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int16),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-32767,-32768] + (take 7 [x, x-1 ..]) = [-32763,-32764,-32765,-32766,-32767,-32768] + (take 7 [x, (x+1) ..]) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(1::Int16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int16) .. 1])) = [1] + (take 7 ([(1::Int16) .. 0])) = [] + (take 7 ([(5::Int16) .. 0])) = [] + (take 7 ([(maxBound-(5::Int16)) .. maxBound])) = [32762,32763,32764,32765,32766,32767] + (take 7 ([(minBound+(5::Int16)) .. minBound])) = [] + (take 7 [(5::Int16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int16),3..1]) = [5,3,1] + (take 7 [(5::Int16),3..2]) = [5,3] + (take 7 [(1::Int16),2..1]) = [1] + (take 7 [(2::Int16),1..2]) = [2] + (take 7 [(2::Int16),1..1]) = [2,1] + (take 7 [(2::Int16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [32763,32764,32765,32766,32767] + (take 7 [x,(x-1)..minBound]) = [-32763,-32764,-32765,-32766,-32767,-32768] +Testing Enum Int32: + (succ (0::Int32)) = 1 + (succ (minBound::Int32)) = -2147483647 + (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound" + pred (1::Int32) = 0 + pred (maxBound::Int32) = 2147483646 + pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound" + (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647] + (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of bounds (-2147483648,2147483647)" + (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647] + (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [(1::Int32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int32),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int32),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-2147483647,-2147483648] + (take 7 [x, x-1 ..]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] + (take 7 [x, (x+1) ..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(1::Int32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int32) .. 1])) = [1] + (take 7 ([(1::Int32) .. 0])) = [] + (take 7 ([(5::Int32) .. 0])) = [] + (take 7 ([(maxBound-(5::Int32)) .. maxBound])) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 ([(minBound+(5::Int32)) .. minBound])) = [] + (take 7 [(5::Int32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int32),3..1]) = [5,3,1] + (take 7 [(5::Int32),3..2]) = [5,3] + (take 7 [(1::Int32),2..1]) = [1] + (take 7 [(2::Int32),1..2]) = [2] + (take 7 [(2::Int32),1..1]) = [2,1] + (take 7 [(2::Int32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [2147483643,2147483644,2147483645,2147483646,2147483647] + (take 7 [x,(x-1)..minBound]) = [-2147483643,-2147483644,-2147483645,-2147483646,-2147483647,-2147483648] +Testing Enum Int64: + (succ (0::Int64)) = 1 + (succ (minBound::Int64)) = -9223372036854775807 + (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound" + pred (1::Int64) = 0 + pred (maxBound::Int64) = 9223372036854775806 + pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound" + (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,-9223372036854775808,9223372036854775807] + (toEnum (maxBound::Int))::Int64 = 9223372036854775807 + (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-9223372036854775808,9223372036854775807] + fromEnum (maxBound::Int64) = 9223372036854775807 + (take 7 [(1::Int64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Int64)-5)..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [(1::Int64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Int64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Int64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Int64),0..]) = [1,0,-1,-2,-3,-4,-5] + (take 7 [(5::Int64),2..]) = [5,2,-1,-4,-7,-10,-13] + (take 7 [x, x-1 ..]) = [-9223372036854775807,-9223372036854775808] + (take 7 [x, x-1 ..]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] + (take 7 [x, (x+1) ..]) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(1::Int64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Int64) .. 1])) = [1] + (take 7 ([(1::Int64) .. 0])) = [] + (take 7 ([(5::Int64) .. 0])) = [] + (take 7 ([(maxBound-(5::Int64)) .. maxBound])) = [9223372036854775802,9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 ([(minBound+(5::Int64)) .. minBound])) = [] + (take 7 [(5::Int64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Int64),3..1]) = [5,3,1] + (take 7 [(5::Int64),3..2]) = [5,3] + (take 7 [(1::Int64),2..1]) = [1] + (take 7 [(2::Int64),1..2]) = [2] + (take 7 [(2::Int64),1..1]) = [2,1] + (take 7 [(2::Int64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [9223372036854775803,9223372036854775804,9223372036854775805,9223372036854775806,9223372036854775807] + (take 7 [x,(x-1)..minBound]) = [-9223372036854775803,-9223372036854775804,-9223372036854775805,-9223372036854775806,-9223372036854775807,-9223372036854775808] diff --git a/testsuite/tests/lib/should_run/enum03.hs b/testsuite/tests/lib/should_run/enum03.hs new file mode 100644 index 0000000000..908f3dd1a0 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum03.hs @@ -0,0 +1,266 @@ +-- !!! Testing the Word Enum instances. +module Main(main) where + +import Prelude hiding (catch) +import Control.Exception +import Data.Word +import Data.Int + +main = do + putStrLn "Testing Enum Word8:" + testEnumWord8 + putStrLn "Testing Enum Word16:" + testEnumWord16 + putStrLn "Testing Enum Word32:" + testEnumWord32 + putStrLn "Testing Enum Word64:" + testEnumWord64 + + +#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) }) + +testEnumWord8 :: IO () +testEnumWord8 = do + -- succ + printTest ((succ (0::Word8))) + printTest ((succ (minBound::Word8))) + mayBomb (printTest ((succ (maxBound::Word8)))) + + -- pred + printTest (pred (1::Word8)) + printTest (pred (maxBound::Word8)) + mayBomb (printTest (pred (minBound::Word8))) + + -- toEnum + printTest ((map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int])) + mayBomb (printTest ((toEnum (maxBound::Int))::Word8)) + + -- fromEnum + printTest ((map fromEnum [(1::Word8),minBound,maxBound])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Word8)..])) + printTest ((take 7 [((maxBound::Word8)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Word8),2..])) + printTest ((take 7 [(1::Word8),7..])) + printTest ((take 7 [(1::Word8),1..])) + printTest ((take 7 [(1::Word8),0..])) + printTest ((take 7 [(5::Word8),2..])) + let x = (minBound::Word8) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Word8) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Word8) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Word8) .. 5]))) + printTest ((take 4 ([(1::Word8) .. 1]))) + printTest ((take 7 ([(1::Word8) .. 0]))) + printTest ((take 7 ([(5::Word8) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Word8)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Word8)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Word8),4..1])) + printTest ((take 7 [(5::Word8),3..1])) + printTest ((take 7 [(5::Word8),3..2])) + printTest ((take 7 [(1::Word8),2..1])) + printTest ((take 7 [(2::Word8),1..2])) + printTest ((take 7 [(2::Word8),1..1])) + printTest ((take 7 [(2::Word8),3..1])) + + let x = (maxBound::Word8) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Word8) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + +testEnumWord16 :: IO () +testEnumWord16 = do + -- succ + printTest ((succ (0::Word16))) + printTest ((succ (minBound::Word16))) + mayBomb (printTest ((succ (maxBound::Word16)))) + + -- pred + printTest (pred (1::Word16)) + printTest (pred (maxBound::Word16)) + mayBomb (printTest (pred (minBound::Word16))) + + -- toEnum + printTest ((map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int])) + mayBomb (printTest ((toEnum (maxBound::Int))::Word16)) + + + -- fromEnum + printTest ((map fromEnum [(1::Word16),minBound,maxBound])) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Word16)..])) + printTest ((take 7 [((maxBound::Word16)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Word16),2..])) + printTest ((take 7 [(1::Word16),7..])) + printTest ((take 7 [(1::Word16),1..])) + printTest ((take 7 [(1::Word16),0..])) + printTest ((take 7 [(5::Word16),2..])) + let x = (minBound::Word16) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Word16) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Word16) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Word16) .. 5]))) + printTest ((take 4 ([(1::Word16) .. 1]))) + printTest ((take 7 ([(1::Word16) .. 0]))) + printTest ((take 7 ([(5::Word16) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Word16)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Word16)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Word16),4..1])) + printTest ((take 7 [(5::Word16),3..1])) + printTest ((take 7 [(5::Word16),3..2])) + printTest ((take 7 [(1::Word16),2..1])) + printTest ((take 7 [(2::Word16),1..2])) + printTest ((take 7 [(2::Word16),1..1])) + printTest ((take 7 [(2::Word16),3..1])) + + let x = (maxBound::Word16) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Word16) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + +testEnumWord32 :: IO () +testEnumWord32 = do + -- succ + printTest ((succ (0::Word32))) + printTest ((succ (minBound::Word32))) + mayBomb (printTest ((succ (maxBound::Word32)))) + + -- pred + printTest (pred (1::Word32)) + printTest (pred (maxBound::Word32)) + mayBomb (printTest (pred (minBound::Word32))) + + -- toEnum + printTest ((map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int])) + mayBomb (printTest ((toEnum (maxBound::Int))::Word32)) + + -- fromEnum + printTest ((map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)])) + mayBomb (printTest (fromEnum (maxBound::Word32))) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Word32)..])) + printTest ((take 7 [((maxBound::Word32)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Word32),2..])) + printTest ((take 7 [(1::Word32),7..])) + printTest ((take 7 [(1::Word32),1..])) + printTest ((take 7 [(1::Word32),0..])) + printTest ((take 7 [(5::Word32),2..])) + let x = (minBound::Word32) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Word32) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Word32) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Word32) .. 5]))) + printTest ((take 4 ([(1::Word32) .. 1]))) + printTest ((take 7 ([(1::Word32) .. 0]))) + printTest ((take 7 ([(5::Word32) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Word32)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Word32)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Word32),4..1])) + printTest ((take 7 [(5::Word32),3..1])) + printTest ((take 7 [(5::Word32),3..2])) + printTest ((take 7 [(1::Word32),2..1])) + printTest ((take 7 [(2::Word32),1..2])) + printTest ((take 7 [(2::Word32),1..1])) + printTest ((take 7 [(2::Word32),3..1])) + + let x = (maxBound::Word32) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Word32) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + +testEnumWord64 :: IO () +testEnumWord64 = do + -- succ + printTest ((succ (0::Word64))) + printTest ((succ (minBound::Word64))) + mayBomb (printTest ((succ (maxBound::Word64)))) + + -- pred + printTest (pred (1::Word64)) + printTest (pred (maxBound::Word64)) + mayBomb (printTest (pred (minBound::Word64))) + + -- toEnum + mayBomb (printTest ((map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]))) + mayBomb (printTest ((toEnum (maxBound::Int))::Word64)) + + -- fromEnum + printTest ((map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)])) + mayBomb (printTest (fromEnum (maxBound::Word64))) + + -- [x..] aka enumFrom + printTest ((take 7 [(1::Word64)..])) + printTest ((take 7 [((maxBound::Word64)-5)..])) -- just in case it doesn't catch the upper bound.. + + -- [x,y..] aka enumFromThen + printTest ((take 7 [(1::Word64),2..])) + printTest ((take 7 [(1::Word64),7..])) + printTest ((take 7 [(1::Word64),1..])) + printTest ((take 7 [(1::Word64),0..])) + printTest ((take 7 [(5::Word64),2..])) + let x = (minBound::Word64) + 1 + printTest ((take 7 [x, x-1 ..])) + let x = (minBound::Word64) + 5 + printTest ((take 7 [x, x-1 ..])) + let x = (maxBound::Word64) - 5 + printTest ((take 7 [x, (x+1) ..])) + + -- [x..y] aka enumFromTo + printTest ((take 7 ([(1::Word64) .. 5]))) + printTest ((take 4 ([(1::Word64) .. 1]))) + printTest ((take 7 ([(1::Word64) .. 0]))) + printTest ((take 7 ([(5::Word64) .. 0]))) + printTest ((take 7 ([(maxBound-(5::Word64)) .. maxBound]))) + printTest ((take 7 ([(minBound+(5::Word64)) .. minBound]))) + + -- [x,y..z] aka enumFromThenTo + printTest ((take 7 [(5::Word64),4..1])) + printTest ((take 7 [(5::Word64),3..1])) + printTest ((take 7 [(5::Word64),3..2])) + printTest ((take 7 [(1::Word64),2..1])) + printTest ((take 7 [(2::Word64),1..2])) + printTest ((take 7 [(2::Word64),1..1])) + printTest ((take 7 [(2::Word64),3..1])) + + let x = (maxBound::Word64) - 4 + printTest ((take 7 [x,(x+1)..maxBound])) + let x = (minBound::Word64) + 5 + printTest ((take 7 [x,(x-1)..minBound])) + + +-- +-- +-- Utils +-- +-- + + +mayBomb x = catch x (\(ErrorCall e) -> putStrLn ("error " ++ show e)) + `catch` (\e -> putStrLn ("Fail: " ++ show (e :: SomeException))) diff --git a/testsuite/tests/lib/should_run/enum03.stdout b/testsuite/tests/lib/should_run/enum03.stdout new file mode 100644 index 0000000000..d6db561a72 --- /dev/null +++ b/testsuite/tests/lib/should_run/enum03.stdout @@ -0,0 +1,142 @@ +Testing Enum Word8: + (succ (0::Word8)) = 1 + (succ (minBound::Word8)) = 1 + (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound" + pred (1::Word8) = 0 + pred (maxBound::Word8) = 254 + pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound" + (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255] + (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (2147483647) is outside of bounds (0,255)" + (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255] + (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255] + (take 7 [(1::Word8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word8),0..]) = [1,0] + (take 7 [(5::Word8),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [250,251,252,253,254,255] + (take 7 ([(1::Word8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word8) .. 1])) = [1] + (take 7 ([(1::Word8) .. 0])) = [] + (take 7 ([(5::Word8) .. 0])) = [] + (take 7 ([(maxBound-(5::Word8)) .. maxBound])) = [250,251,252,253,254,255] + (take 7 ([(minBound+(5::Word8)) .. minBound])) = [] + (take 7 [(5::Word8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word8),3..1]) = [5,3,1] + (take 7 [(5::Word8),3..2]) = [5,3] + (take 7 [(1::Word8),2..1]) = [1] + (take 7 [(2::Word8),1..2]) = [2] + (take 7 [(2::Word8),1..1]) = [2,1] + (take 7 [(2::Word8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [251,252,253,254,255] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word16: + (succ (0::Word16)) = 1 + (succ (minBound::Word16)) = 1 + (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound" + pred (1::Word16) = 0 + pred (maxBound::Word16) = 65534 + pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound" + (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535] + (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (2147483647) is outside of bounds (0,65535)" + (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535] + (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535] + (take 7 [(1::Word16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word16),0..]) = [1,0] + (take 7 [(5::Word16),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(1::Word16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word16) .. 1])) = [1] + (take 7 ([(1::Word16) .. 0])) = [] + (take 7 ([(5::Word16) .. 0])) = [] + (take 7 ([(maxBound-(5::Word16)) .. maxBound])) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(minBound+(5::Word16)) .. minBound])) = [] + (take 7 [(5::Word16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word16),3..1]) = [5,3,1] + (take 7 [(5::Word16),3..2]) = [5,3] + (take 7 [(1::Word16),2..1]) = [1] + (take 7 [(2::Word16),1..2]) = [2] + (take 7 [(2::Word16),1..1]) = [2,1] + (take 7 [(2::Word16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [65531,65532,65533,65534,65535] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word32: + (succ (0::Word32)) = 1 + (succ (minBound::Word32)) = 1 + (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound" + pred (1::Word32) = 0 + pred (maxBound::Word32) = 4294967294 + pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound" + (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647] + (toEnum (maxBound::Int))::Word32 = 2147483647 + (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,2147483647] + fromEnum (maxBound::Word32) = error "Enum.fromEnum{Word32}: value (4294967295) is outside of Int's bounds (-2147483648,2147483647)" + (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word32)-5)..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [(1::Word32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word32),0..]) = [1,0] + (take 7 [(5::Word32),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(1::Word32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word32) .. 1])) = [1] + (take 7 ([(1::Word32) .. 0])) = [] + (take 7 ([(5::Word32) .. 0])) = [] + (take 7 ([(maxBound-(5::Word32)) .. maxBound])) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(minBound+(5::Word32)) .. minBound])) = [] + (take 7 [(5::Word32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word32),3..1]) = [5,3,1] + (take 7 [(5::Word32),3..2]) = [5,3] + (take 7 [(1::Word32),2..1]) = [1] + (take 7 [(2::Word32),1..2]) = [2] + (take 7 [(2::Word32),1..1]) = [2,1] + (take 7 [(2::Word32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word64: + (succ (0::Word64)) = 1 + (succ (minBound::Word64)) = 1 + (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound" + pred (1::Word64) = 0 + pred (maxBound::Word64) = 18446744073709551614 + pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound" + (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,2147483647] + (toEnum (maxBound::Int))::Word64 = 2147483647 + (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,2147483647] + fromEnum (maxBound::Word64) = error "Enum.fromEnum{Word64}: value (18446744073709551615) is outside of Int's bounds (-2147483648,2147483647)" + (take 7 [(1::Word64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word64)-5)..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [(1::Word64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word64),0..]) = [1,0] + (take 7 [(5::Word64),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(1::Word64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word64) .. 1])) = [1] + (take 7 ([(1::Word64) .. 0])) = [] + (take 7 ([(5::Word64) .. 0])) = [] + (take 7 ([(maxBound-(5::Word64)) .. maxBound])) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(minBound+(5::Word64)) .. minBound])) = [] + (take 7 [(5::Word64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word64),3..1]) = [5,3,1] + (take 7 [(5::Word64),3..2]) = [5,3] + (take 7 [(1::Word64),2..1]) = [1] + (take 7 [(2::Word64),1..2]) = [2] + (take 7 [(2::Word64),1..1]) = [2,1] + (take 7 [(2::Word64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] diff --git a/testsuite/tests/lib/should_run/enum03.stdout-alpha-dec-osf3 b/testsuite/tests/lib/should_run/enum03.stdout-alpha-dec-osf3 new file mode 100644 index 0000000000..716782c46a --- /dev/null +++ b/testsuite/tests/lib/should_run/enum03.stdout-alpha-dec-osf3 @@ -0,0 +1,142 @@ +Testing Enum Word8: + (succ (0::Word8)) = 1 + (succ (minBound::Word8)) = 1 + (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound" + pred (1::Word8) = 0 + pred (maxBound::Word8) = 254 + pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound" + (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255] + (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of bounds (0,255)" + (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255] + (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255] + (take 7 [(1::Word8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word8),0..]) = [1,0] + (take 7 [(5::Word8),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [250,251,252,253,254,255] + (take 7 ([(1::Word8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word8) .. 1])) = [1] + (take 7 ([(1::Word8) .. 0])) = [] + (take 7 ([(5::Word8) .. 0])) = [] + (take 7 ([(maxBound-(5::Word8)) .. maxBound])) = [250,251,252,253,254,255] + (take 7 ([(minBound+(5::Word8)) .. minBound])) = [] + (take 7 [(5::Word8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word8),3..1]) = [5,3,1] + (take 7 [(5::Word8),3..2]) = [5,3] + (take 7 [(1::Word8),2..1]) = [1] + (take 7 [(2::Word8),1..2]) = [2] + (take 7 [(2::Word8),1..1]) = [2,1] + (take 7 [(2::Word8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [251,252,253,254,255] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word16: + (succ (0::Word16)) = 1 + (succ (minBound::Word16)) = 1 + (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound" + pred (1::Word16) = 0 + pred (maxBound::Word16) = 65534 + pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound" + (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535] + (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of bounds (0,65535)" + (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535] + (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535] + (take 7 [(1::Word16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word16),0..]) = [1,0] + (take 7 [(5::Word16),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(1::Word16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word16) .. 1])) = [1] + (take 7 ([(1::Word16) .. 0])) = [] + (take 7 ([(5::Word16) .. 0])) = [] + (take 7 ([(maxBound-(5::Word16)) .. maxBound])) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(minBound+(5::Word16)) .. minBound])) = [] + (take 7 [(5::Word16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word16),3..1]) = [5,3,1] + (take 7 [(5::Word16),3..2]) = [5,3] + (take 7 [(1::Word16),2..1]) = [1] + (take 7 [(2::Word16),1..2]) = [2] + (take 7 [(2::Word16),1..1]) = [2,1] + (take 7 [(2::Word16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [65531,65532,65533,65534,65535] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word32: + (succ (0::Word32)) = 1 + (succ (minBound::Word32)) = 1 + (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound" + pred (1::Word32) = 0 + pred (maxBound::Word32) = 4294967294 + pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound" + (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647] + (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of bounds (0,4294967295)" + (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,4294967295] + fromEnum (maxBound::Word32) = 4294967295 + (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word32)-5)..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [(1::Word32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word32),0..]) = [1,0] + (take 7 [(5::Word32),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(1::Word32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word32) .. 1])) = [1] + (take 7 ([(1::Word32) .. 0])) = [] + (take 7 ([(5::Word32) .. 0])) = [] + (take 7 ([(maxBound-(5::Word32)) .. maxBound])) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(minBound+(5::Word32)) .. minBound])) = [] + (take 7 [(5::Word32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word32),3..1]) = [5,3,1] + (take 7 [(5::Word32),3..2]) = [5,3] + (take 7 [(1::Word32),2..1]) = [1] + (take 7 [(2::Word32),1..2]) = [2] + (take 7 [(2::Word32),1..1]) = [2,1] + (take 7 [(2::Word32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word64: + (succ (0::Word64)) = 1 + (succ (minBound::Word64)) = 1 + (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound" + pred (1::Word64) = 0 + pred (maxBound::Word64) = 18446744073709551614 + pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound" + (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,9223372036854775807] + (toEnum (maxBound::Int))::Word64 = 9223372036854775807 + (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,9223372036854775807] + fromEnum (maxBound::Word64) = error "Enum.fromEnum{Word64}: value (18446744073709551615) is outside of Int's bounds (-9223372036854775808,9223372036854775807)" + (take 7 [(1::Word64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word64)-5)..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [(1::Word64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word64),0..]) = [1,0] + (take 7 [(5::Word64),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(1::Word64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word64) .. 1])) = [1] + (take 7 ([(1::Word64) .. 0])) = [] + (take 7 ([(5::Word64) .. 0])) = [] + (take 7 ([(maxBound-(5::Word64)) .. maxBound])) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(minBound+(5::Word64)) .. minBound])) = [] + (take 7 [(5::Word64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word64),3..1]) = [5,3,1] + (take 7 [(5::Word64),3..2]) = [5,3] + (take 7 [(1::Word64),2..1]) = [1] + (take 7 [(2::Word64),1..2]) = [2] + (take 7 [(2::Word64),1..1]) = [2,1] + (take 7 [(2::Word64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] diff --git a/testsuite/tests/lib/should_run/enum03.stdout-hugs b/testsuite/tests/lib/should_run/enum03.stdout-hugs new file mode 100644 index 0000000000..babc1c2e9e --- /dev/null +++ b/testsuite/tests/lib/should_run/enum03.stdout-hugs @@ -0,0 +1,142 @@ +Testing Enum Word8: + (succ (0::Word8)) = 1 + (succ (minBound::Word8)) = 1 + (succ (maxBound::Word8)) = error "succ: applied to maxBound" + pred (1::Word8) = 0 + pred (maxBound::Word8) = 254 + pred (minBound::Word8) = error "pred: applied to minBound" + (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255] + (toEnum (maxBound::Int))::Word8 = 255 + (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255] + (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255] + (take 7 [(1::Word8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word8),0..]) = [1,0] + (take 7 [(5::Word8),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [250,251,252,253,254,255] + (take 7 ([(1::Word8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word8) .. 1])) = [1] + (take 7 ([(1::Word8) .. 0])) = [] + (take 7 ([(5::Word8) .. 0])) = [] + (take 7 ([(maxBound-(5::Word8)) .. maxBound])) = [250,251,252,253,254,255] + (take 7 ([(minBound+(5::Word8)) .. minBound])) = [] + (take 7 [(5::Word8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word8),3..1]) = [5,3,1] + (take 7 [(5::Word8),3..2]) = [5,3] + (take 7 [(1::Word8),2..1]) = [1] + (take 7 [(2::Word8),1..2]) = [2] + (take 7 [(2::Word8),1..1]) = [2,1] + (take 7 [(2::Word8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [251,252,253,254,255] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word16: + (succ (0::Word16)) = 1 + (succ (minBound::Word16)) = 1 + (succ (maxBound::Word16)) = error "succ: applied to maxBound" + pred (1::Word16) = 0 + pred (maxBound::Word16) = 65534 + pred (minBound::Word16) = error "pred: applied to minBound" + (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535] + (toEnum (maxBound::Int))::Word16 = 65535 + (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535] + (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535] + (take 7 [(1::Word16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word16),0..]) = [1,0] + (take 7 [(5::Word16),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(1::Word16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word16) .. 1])) = [1] + (take 7 ([(1::Word16) .. 0])) = [] + (take 7 ([(5::Word16) .. 0])) = [] + (take 7 ([(maxBound-(5::Word16)) .. maxBound])) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(minBound+(5::Word16)) .. minBound])) = [] + (take 7 [(5::Word16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word16),3..1]) = [5,3,1] + (take 7 [(5::Word16),3..2]) = [5,3] + (take 7 [(1::Word16),2..1]) = [1] + (take 7 [(2::Word16),1..2]) = [2] + (take 7 [(2::Word16),1..1]) = [2,1] + (take 7 [(2::Word16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [65531,65532,65533,65534,65535] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word32: + (succ (0::Word32)) = 1 + (succ (minBound::Word32)) = 1 + (succ (maxBound::Word32)) = error "succ: applied to maxBound" + pred (1::Word32) = 0 + pred (maxBound::Word32) = 4294967294 + pred (minBound::Word32) = error "pred: applied to minBound" + (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647] + (toEnum (maxBound::Int))::Word32 = 2147483647 + (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,2147483647] + fromEnum (maxBound::Word32) = -1 + (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word32)-5)..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [(1::Word32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word32),0..]) = [1,0] + (take 7 [(5::Word32),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(1::Word32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word32) .. 1])) = [1] + (take 7 ([(1::Word32) .. 0])) = [] + (take 7 ([(5::Word32) .. 0])) = [] + (take 7 ([(maxBound-(5::Word32)) .. maxBound])) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(minBound+(5::Word32)) .. minBound])) = [] + (take 7 [(5::Word32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word32),3..1]) = [5,3,1] + (take 7 [(5::Word32),3..2]) = [5,3] + (take 7 [(1::Word32),2..1]) = [1] + (take 7 [(2::Word32),1..2]) = [2] + (take 7 [(2::Word32),1..1]) = [2,1] + (take 7 [(2::Word32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word64: + (succ (0::Word64)) = 1 + (succ (minBound::Word64)) = 1 + (succ (maxBound::Word64)) = error "succ: applied to maxBound" + pred (1::Word64) = 0 + pred (maxBound::Word64) = 18446744073709551614 + pred (minBound::Word64) = error "pred: applied to minBound" + (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,2147483647] + (toEnum (maxBound::Int))::Word64 = 2147483647 + (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,2147483647] + fromEnum (maxBound::Word64) = Fail: arithmetic overflow + (take 7 [(1::Word64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word64)-5)..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [(1::Word64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word64),0..]) = [1,0] + (take 7 [(5::Word64),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(1::Word64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word64) .. 1])) = [1] + (take 7 ([(1::Word64) .. 0])) = [] + (take 7 ([(5::Word64) .. 0])) = [] + (take 7 ([(maxBound-(5::Word64)) .. maxBound])) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(minBound+(5::Word64)) .. minBound])) = [] + (take 7 [(5::Word64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word64),3..1]) = [5,3,1] + (take 7 [(5::Word64),3..2]) = [5,3] + (take 7 [(1::Word64),2..1]) = [1] + (take 7 [(2::Word64),1..2]) = [2] + (take 7 [(2::Word64),1..1]) = [2,1] + (take 7 [(2::Word64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] diff --git a/testsuite/tests/lib/should_run/enum03.stdout-mips-sgi-irix b/testsuite/tests/lib/should_run/enum03.stdout-mips-sgi-irix new file mode 100644 index 0000000000..716782c46a --- /dev/null +++ b/testsuite/tests/lib/should_run/enum03.stdout-mips-sgi-irix @@ -0,0 +1,142 @@ +Testing Enum Word8: + (succ (0::Word8)) = 1 + (succ (minBound::Word8)) = 1 + (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound" + pred (1::Word8) = 0 + pred (maxBound::Word8) = 254 + pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound" + (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255] + (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of bounds (0,255)" + (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255] + (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255] + (take 7 [(1::Word8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word8),0..]) = [1,0] + (take 7 [(5::Word8),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [250,251,252,253,254,255] + (take 7 ([(1::Word8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word8) .. 1])) = [1] + (take 7 ([(1::Word8) .. 0])) = [] + (take 7 ([(5::Word8) .. 0])) = [] + (take 7 ([(maxBound-(5::Word8)) .. maxBound])) = [250,251,252,253,254,255] + (take 7 ([(minBound+(5::Word8)) .. minBound])) = [] + (take 7 [(5::Word8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word8),3..1]) = [5,3,1] + (take 7 [(5::Word8),3..2]) = [5,3] + (take 7 [(1::Word8),2..1]) = [1] + (take 7 [(2::Word8),1..2]) = [2] + (take 7 [(2::Word8),1..1]) = [2,1] + (take 7 [(2::Word8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [251,252,253,254,255] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word16: + (succ (0::Word16)) = 1 + (succ (minBound::Word16)) = 1 + (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound" + pred (1::Word16) = 0 + pred (maxBound::Word16) = 65534 + pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound" + (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535] + (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of bounds (0,65535)" + (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535] + (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535] + (take 7 [(1::Word16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word16),0..]) = [1,0] + (take 7 [(5::Word16),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(1::Word16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word16) .. 1])) = [1] + (take 7 ([(1::Word16) .. 0])) = [] + (take 7 ([(5::Word16) .. 0])) = [] + (take 7 ([(maxBound-(5::Word16)) .. maxBound])) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(minBound+(5::Word16)) .. minBound])) = [] + (take 7 [(5::Word16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word16),3..1]) = [5,3,1] + (take 7 [(5::Word16),3..2]) = [5,3] + (take 7 [(1::Word16),2..1]) = [1] + (take 7 [(2::Word16),1..2]) = [2] + (take 7 [(2::Word16),1..1]) = [2,1] + (take 7 [(2::Word16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [65531,65532,65533,65534,65535] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word32: + (succ (0::Word32)) = 1 + (succ (minBound::Word32)) = 1 + (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound" + pred (1::Word32) = 0 + pred (maxBound::Word32) = 4294967294 + pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound" + (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647] + (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of bounds (0,4294967295)" + (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,4294967295] + fromEnum (maxBound::Word32) = 4294967295 + (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word32)-5)..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [(1::Word32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word32),0..]) = [1,0] + (take 7 [(5::Word32),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(1::Word32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word32) .. 1])) = [1] + (take 7 ([(1::Word32) .. 0])) = [] + (take 7 ([(5::Word32) .. 0])) = [] + (take 7 ([(maxBound-(5::Word32)) .. maxBound])) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(minBound+(5::Word32)) .. minBound])) = [] + (take 7 [(5::Word32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word32),3..1]) = [5,3,1] + (take 7 [(5::Word32),3..2]) = [5,3] + (take 7 [(1::Word32),2..1]) = [1] + (take 7 [(2::Word32),1..2]) = [2] + (take 7 [(2::Word32),1..1]) = [2,1] + (take 7 [(2::Word32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word64: + (succ (0::Word64)) = 1 + (succ (minBound::Word64)) = 1 + (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound" + pred (1::Word64) = 0 + pred (maxBound::Word64) = 18446744073709551614 + pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound" + (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,9223372036854775807] + (toEnum (maxBound::Int))::Word64 = 9223372036854775807 + (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,9223372036854775807] + fromEnum (maxBound::Word64) = error "Enum.fromEnum{Word64}: value (18446744073709551615) is outside of Int's bounds (-9223372036854775808,9223372036854775807)" + (take 7 [(1::Word64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word64)-5)..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [(1::Word64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word64),0..]) = [1,0] + (take 7 [(5::Word64),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(1::Word64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word64) .. 1])) = [1] + (take 7 ([(1::Word64) .. 0])) = [] + (take 7 ([(5::Word64) .. 0])) = [] + (take 7 ([(maxBound-(5::Word64)) .. maxBound])) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(minBound+(5::Word64)) .. minBound])) = [] + (take 7 [(5::Word64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word64),3..1]) = [5,3,1] + (take 7 [(5::Word64),3..2]) = [5,3] + (take 7 [(1::Word64),2..1]) = [1] + (take 7 [(2::Word64),1..2]) = [2] + (take 7 [(2::Word64),1..1]) = [2,1] + (take 7 [(2::Word64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] diff --git a/testsuite/tests/lib/should_run/enum03.stdout-ws-64 b/testsuite/tests/lib/should_run/enum03.stdout-ws-64 new file mode 100644 index 0000000000..716782c46a --- /dev/null +++ b/testsuite/tests/lib/should_run/enum03.stdout-ws-64 @@ -0,0 +1,142 @@ +Testing Enum Word8: + (succ (0::Word8)) = 1 + (succ (minBound::Word8)) = 1 + (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound" + pred (1::Word8) = 0 + pred (maxBound::Word8) = 254 + pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound" + (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255] + (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of bounds (0,255)" + (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255] + (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255] + (take 7 [(1::Word8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word8),0..]) = [1,0] + (take 7 [(5::Word8),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [250,251,252,253,254,255] + (take 7 ([(1::Word8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word8) .. 1])) = [1] + (take 7 ([(1::Word8) .. 0])) = [] + (take 7 ([(5::Word8) .. 0])) = [] + (take 7 ([(maxBound-(5::Word8)) .. maxBound])) = [250,251,252,253,254,255] + (take 7 ([(minBound+(5::Word8)) .. minBound])) = [] + (take 7 [(5::Word8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word8),3..1]) = [5,3,1] + (take 7 [(5::Word8),3..2]) = [5,3] + (take 7 [(1::Word8),2..1]) = [1] + (take 7 [(2::Word8),1..2]) = [2] + (take 7 [(2::Word8),1..1]) = [2,1] + (take 7 [(2::Word8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [251,252,253,254,255] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word16: + (succ (0::Word16)) = 1 + (succ (minBound::Word16)) = 1 + (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound" + pred (1::Word16) = 0 + pred (maxBound::Word16) = 65534 + pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound" + (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535] + (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of bounds (0,65535)" + (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535] + (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535] + (take 7 [(1::Word16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word16),0..]) = [1,0] + (take 7 [(5::Word16),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(1::Word16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word16) .. 1])) = [1] + (take 7 ([(1::Word16) .. 0])) = [] + (take 7 ([(5::Word16) .. 0])) = [] + (take 7 ([(maxBound-(5::Word16)) .. maxBound])) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(minBound+(5::Word16)) .. minBound])) = [] + (take 7 [(5::Word16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word16),3..1]) = [5,3,1] + (take 7 [(5::Word16),3..2]) = [5,3] + (take 7 [(1::Word16),2..1]) = [1] + (take 7 [(2::Word16),1..2]) = [2] + (take 7 [(2::Word16),1..1]) = [2,1] + (take 7 [(2::Word16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [65531,65532,65533,65534,65535] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word32: + (succ (0::Word32)) = 1 + (succ (minBound::Word32)) = 1 + (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound" + pred (1::Word32) = 0 + pred (maxBound::Word32) = 4294967294 + pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound" + (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647] + (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of bounds (0,4294967295)" + (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,4294967295] + fromEnum (maxBound::Word32) = 4294967295 + (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word32)-5)..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [(1::Word32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word32),0..]) = [1,0] + (take 7 [(5::Word32),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(1::Word32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word32) .. 1])) = [1] + (take 7 ([(1::Word32) .. 0])) = [] + (take 7 ([(5::Word32) .. 0])) = [] + (take 7 ([(maxBound-(5::Word32)) .. maxBound])) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(minBound+(5::Word32)) .. minBound])) = [] + (take 7 [(5::Word32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word32),3..1]) = [5,3,1] + (take 7 [(5::Word32),3..2]) = [5,3] + (take 7 [(1::Word32),2..1]) = [1] + (take 7 [(2::Word32),1..2]) = [2] + (take 7 [(2::Word32),1..1]) = [2,1] + (take 7 [(2::Word32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word64: + (succ (0::Word64)) = 1 + (succ (minBound::Word64)) = 1 + (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound" + pred (1::Word64) = 0 + pred (maxBound::Word64) = 18446744073709551614 + pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound" + (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,9223372036854775807] + (toEnum (maxBound::Int))::Word64 = 9223372036854775807 + (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,9223372036854775807] + fromEnum (maxBound::Word64) = error "Enum.fromEnum{Word64}: value (18446744073709551615) is outside of Int's bounds (-9223372036854775808,9223372036854775807)" + (take 7 [(1::Word64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word64)-5)..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [(1::Word64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word64),0..]) = [1,0] + (take 7 [(5::Word64),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(1::Word64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word64) .. 1])) = [1] + (take 7 ([(1::Word64) .. 0])) = [] + (take 7 ([(5::Word64) .. 0])) = [] + (take 7 ([(maxBound-(5::Word64)) .. maxBound])) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(minBound+(5::Word64)) .. minBound])) = [] + (take 7 [(5::Word64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word64),3..1]) = [5,3,1] + (take 7 [(5::Word64),3..2]) = [5,3] + (take 7 [(1::Word64),2..1]) = [1] + (take 7 [(2::Word64),1..2]) = [2] + (take 7 [(2::Word64),1..1]) = [2,1] + (take 7 [(2::Word64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] diff --git a/testsuite/tests/lib/should_run/enum03.stdout-x86_64-unknown-openbsd b/testsuite/tests/lib/should_run/enum03.stdout-x86_64-unknown-openbsd new file mode 100644 index 0000000000..716782c46a --- /dev/null +++ b/testsuite/tests/lib/should_run/enum03.stdout-x86_64-unknown-openbsd @@ -0,0 +1,142 @@ +Testing Enum Word8: + (succ (0::Word8)) = 1 + (succ (minBound::Word8)) = 1 + (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound" + pred (1::Word8) = 0 + pred (maxBound::Word8) = 254 + pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound" + (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255] + (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of bounds (0,255)" + (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255] + (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255] + (take 7 [(1::Word8),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word8),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word8),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word8),0..]) = [1,0] + (take 7 [(5::Word8),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [250,251,252,253,254,255] + (take 7 ([(1::Word8) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word8) .. 1])) = [1] + (take 7 ([(1::Word8) .. 0])) = [] + (take 7 ([(5::Word8) .. 0])) = [] + (take 7 ([(maxBound-(5::Word8)) .. maxBound])) = [250,251,252,253,254,255] + (take 7 ([(minBound+(5::Word8)) .. minBound])) = [] + (take 7 [(5::Word8),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word8),3..1]) = [5,3,1] + (take 7 [(5::Word8),3..2]) = [5,3] + (take 7 [(1::Word8),2..1]) = [1] + (take 7 [(2::Word8),1..2]) = [2] + (take 7 [(2::Word8),1..1]) = [2,1] + (take 7 [(2::Word8),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [251,252,253,254,255] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word16: + (succ (0::Word16)) = 1 + (succ (minBound::Word16)) = 1 + (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound" + pred (1::Word16) = 0 + pred (maxBound::Word16) = 65534 + pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound" + (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535] + (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of bounds (0,65535)" + (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535] + (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535] + (take 7 [(1::Word16),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word16),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word16),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word16),0..]) = [1,0] + (take 7 [(5::Word16),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(1::Word16) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word16) .. 1])) = [1] + (take 7 ([(1::Word16) .. 0])) = [] + (take 7 ([(5::Word16) .. 0])) = [] + (take 7 ([(maxBound-(5::Word16)) .. maxBound])) = [65530,65531,65532,65533,65534,65535] + (take 7 ([(minBound+(5::Word16)) .. minBound])) = [] + (take 7 [(5::Word16),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word16),3..1]) = [5,3,1] + (take 7 [(5::Word16),3..2]) = [5,3] + (take 7 [(1::Word16),2..1]) = [1] + (take 7 [(2::Word16),1..2]) = [2] + (take 7 [(2::Word16),1..1]) = [2,1] + (take 7 [(2::Word16),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [65531,65532,65533,65534,65535] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word32: + (succ (0::Word32)) = 1 + (succ (minBound::Word32)) = 1 + (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound" + pred (1::Word32) = 0 + pred (maxBound::Word32) = 4294967294 + pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound" + (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647] + (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of bounds (0,4294967295)" + (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,4294967295] + fromEnum (maxBound::Word32) = 4294967295 + (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word32)-5)..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [(1::Word32),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word32),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word32),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word32),0..]) = [1,0] + (take 7 [(5::Word32),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(1::Word32) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word32) .. 1])) = [1] + (take 7 ([(1::Word32) .. 0])) = [] + (take 7 ([(5::Word32) .. 0])) = [] + (take 7 ([(maxBound-(5::Word32)) .. maxBound])) = [4294967290,4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 ([(minBound+(5::Word32)) .. minBound])) = [] + (take 7 [(5::Word32),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word32),3..1]) = [5,3,1] + (take 7 [(5::Word32),3..2]) = [5,3] + (take 7 [(1::Word32),2..1]) = [1] + (take 7 [(2::Word32),1..2]) = [2] + (take 7 [(2::Word32),1..1]) = [2,1] + (take 7 [(2::Word32),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [4294967291,4294967292,4294967293,4294967294,4294967295] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] +Testing Enum Word64: + (succ (0::Word64)) = 1 + (succ (minBound::Word64)) = 1 + (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound" + pred (1::Word64) = 0 + pred (maxBound::Word64) = 18446744073709551614 + pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound" + (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,9223372036854775807] + (toEnum (maxBound::Int))::Word64 = 9223372036854775807 + (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,9223372036854775807] + fromEnum (maxBound::Word64) = error "Enum.fromEnum{Word64}: value (18446744073709551615) is outside of Int's bounds (-9223372036854775808,9223372036854775807)" + (take 7 [(1::Word64)..]) = [1,2,3,4,5,6,7] + (take 7 [((maxBound::Word64)-5)..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [(1::Word64),2..]) = [1,2,3,4,5,6,7] + (take 7 [(1::Word64),7..]) = [1,7,13,19,25,31,37] + (take 7 [(1::Word64),1..]) = [1,1,1,1,1,1,1] + (take 7 [(1::Word64),0..]) = [1,0] + (take 7 [(5::Word64),2..]) = [5,2] + (take 7 [x, x-1 ..]) = [1,0] + (take 7 [x, x-1 ..]) = [5,4,3,2,1,0] + (take 7 [x, (x+1) ..]) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(1::Word64) .. 5])) = [1,2,3,4,5] + (take 4 ([(1::Word64) .. 1])) = [1] + (take 7 ([(1::Word64) .. 0])) = [] + (take 7 ([(5::Word64) .. 0])) = [] + (take 7 ([(maxBound-(5::Word64)) .. maxBound])) = [18446744073709551610,18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 ([(minBound+(5::Word64)) .. minBound])) = [] + (take 7 [(5::Word64),4..1]) = [5,4,3,2,1] + (take 7 [(5::Word64),3..1]) = [5,3,1] + (take 7 [(5::Word64),3..2]) = [5,3] + (take 7 [(1::Word64),2..1]) = [1] + (take 7 [(2::Word64),1..2]) = [2] + (take 7 [(2::Word64),1..1]) = [2,1] + (take 7 [(2::Word64),3..1]) = [] + (take 7 [x,(x+1)..maxBound]) = [18446744073709551611,18446744073709551612,18446744073709551613,18446744073709551614,18446744073709551615] + (take 7 [x,(x-1)..minBound]) = [5,4,3,2,1,0] diff --git a/testsuite/tests/lib/should_run/enum04.hs b/testsuite/tests/lib/should_run/enum04.hs new file mode 100644 index 0000000000..fed9e8c4ef --- /dev/null +++ b/testsuite/tests/lib/should_run/enum04.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE ScopedTypeVariables #-} +import Control.Exception +import Prelude hiding (catch) + +-- enumFrom on basic numeric types should be strict +-- (possibly a bug in the Haskell Report: it specifies that +-- these ops should be strict in the section on Enum, but the +-- sample code in the Prelude doesn't agree, at least for +-- Float and Double). + +main = do + catch (evaluate [error "" :: Int ..] >> return ()) (\(e::SomeException) -> putStrLn "ok1") + catch (evaluate [error "" :: Integer ..] >> return ()) (\(e::SomeException) -> putStrLn "ok2") + catch (evaluate [error "" :: Float ..] >> return ()) (\(e::SomeException) -> putStrLn "ok3") + catch (evaluate [error "" :: Double ..] >> return ()) (\(e::SomeException) -> putStrLn "ok4") diff --git a/testsuite/tests/lib/should_run/enum04.stdout b/testsuite/tests/lib/should_run/enum04.stdout new file mode 100644 index 0000000000..c8a3e21e6d --- /dev/null +++ b/testsuite/tests/lib/should_run/enum04.stdout @@ -0,0 +1,4 @@ +ok1 +ok2 +ok3 +ok4 diff --git a/testsuite/tests/lib/should_run/exceptionsrun001.hs b/testsuite/tests/lib/should_run/exceptionsrun001.hs new file mode 100644 index 0000000000..9c6febc049 --- /dev/null +++ b/testsuite/tests/lib/should_run/exceptionsrun001.hs @@ -0,0 +1,56 @@ +module Main where + +import Prelude hiding (catch) +import Control.OldException + +main = do + ioTest + errorTest + noMethodTest + patMatchTest + guardTest + dynTest + +ioTest :: IO () +ioTest = catchJust userErrors (ioError (userError "wibble")) + (\ex -> putStr "user exception caught\n") + +errorTest :: IO () +errorTest = try (evaluate (1 + error "call to 'error'")) >>= \r -> + case r of + Left exception -> putStr "error call caught\n" + Right _ -> error "help!" + +instance (Show a, Eq a) => Num (Maybe a) where {} + +noMethodTest :: IO () +noMethodTest = try (evaluate (Just () + Just ())) >>= \ r -> + case r of + Left (NoMethodError err) -> putStr "no method error\n" + Right _ -> error "help!" + +patMatchTest :: IO () +patMatchTest = catch (case test1 [1..10] of () -> return ()) + (\ex -> case ex of + PatternMatchFail err -> putStr err + other -> error "help!") + +test1 [] = () + +guardTest = catch (case test2 of () -> return ()) + (\ex -> case ex of + PatternMatchFail 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/testsuite/tests/lib/should_run/exceptionsrun001.stdout b/testsuite/tests/lib/should_run/exceptionsrun001.stdout new file mode 100644 index 0000000000..2d1930f8c9 --- /dev/null +++ b/testsuite/tests/lib/should_run/exceptionsrun001.stdout @@ -0,0 +1,6 @@ +user exception caught +error call caught +no method error +exceptionsrun001.hs:38:1-13: Non-exhaustive patterns in function test1 +exceptionsrun001.hs:45:1-26: Non-exhaustive patterns in function test2 +43
\ No newline at end of file diff --git a/testsuite/tests/lib/should_run/exceptionsrun002.hs b/testsuite/tests/lib/should_run/exceptionsrun002.hs new file mode 100644 index 0000000000..13b642a3ab --- /dev/null +++ b/testsuite/tests/lib/should_run/exceptionsrun002.hs @@ -0,0 +1,105 @@ +module Main where + { + import qualified Control.OldException as Exception; + import Data.IORef; + import Prelude; + + safeCatch :: IO () -> IO (); + safeCatch f = Exception.catch f (\_ -> return ()); + + type Thrower = IO Bool; + + type Catcher = IO Bool -> IO () -> IO (); + + checkCatch :: Catcher -> Thrower -> IO Bool; + checkCatch catcher thrower = do + { + ref <- newIORef False; + safeCatch (catcher thrower (writeIORef ref True)); + readIORef ref; + }; + + data Named a = MkNamed String a; + + checkNamedCatch :: Named Catcher -> Named Thrower -> IO (); + checkNamedCatch (MkNamed cname catcher) (MkNamed tname thrower) = do + { + didCatch <- checkCatch catcher thrower; + putStrLn (cname ++ (if didCatch then " CAUGHT " else " MISSED ") ++ tname); + }; + + checkNamedCatches :: [Named Catcher] -> [Named Thrower] -> IO (); + checkNamedCatches [] _ = return (); + checkNamedCatches _ [] = return (); + checkNamedCatches [c] (t:tr) = do + { + checkNamedCatch c t; + checkNamedCatches [c] tr; + }; + checkNamedCatches (c:cr) ts = do + { + checkNamedCatches [c] ts; + checkNamedCatches cr ts + }; + + + -- throwers + + returnThrower :: Named Thrower; + returnThrower = MkNamed "return" (return True); + + returnUndefinedThrower :: Named Thrower; + returnUndefinedThrower = MkNamed "return undefined" (return undefined); + + returnErrorThrower :: Named Thrower; + returnErrorThrower = MkNamed "return error" (return (error "some error")); + + undefinedThrower :: Named Thrower; + undefinedThrower = MkNamed "undefined" undefined; + + failThrower :: Named Thrower; + failThrower = MkNamed "fail" (fail "some failure"); + + errorThrower :: Named Thrower; + errorThrower = MkNamed "error" (error "some error"); + + throwThrower :: Named Thrower; + throwThrower = MkNamed "Exception.throw" + (Exception.throw (Exception.ErrorCall "throw error")); + + ioErrorErrorCallThrower :: Named Thrower; + ioErrorErrorCallThrower = MkNamed "ioError ErrorCall" + (Exception.throwIO (Exception.ErrorCall "throw error")); + + ioErrorIOExceptionThrower :: Named Thrower; + ioErrorIOExceptionThrower = MkNamed "ioError IOException" + (Exception.throwIO (Exception.IOException undefined)); + + returnThrowThrower :: Named Thrower; + returnThrowThrower = MkNamed "return Exception.throw" + (return (Exception.throw (Exception.ErrorCall "throw error"))); + + + -- catchers + + bindCatcher :: Named Catcher; + bindCatcher = MkNamed ">>" (>>); + + preludeCatchCatcher :: Named Catcher; + preludeCatchCatcher = MkNamed "Prelude.catch" + (\f cc -> Prelude.catch (f >> (return ())) (const cc)); + + ceCatchCatcher :: Named Catcher; + ceCatchCatcher = MkNamed "Exception.catch" + (\f cc -> Exception.catch (f >> (return ())) (const cc)); + + finallyCatcher :: Named Catcher; + finallyCatcher = MkNamed "Exception.finally" + (\f cc -> Exception.finally (f >> (return ())) cc); + + main = checkNamedCatches + [bindCatcher,preludeCatchCatcher,ceCatchCatcher,finallyCatcher] + [returnThrower,returnUndefinedThrower,returnThrowThrower,returnErrorThrower,failThrower, + errorThrower,throwThrower,ioErrorErrorCallThrower,ioErrorIOExceptionThrower,undefinedThrower]; + + } diff --git a/testsuite/tests/lib/should_run/exceptionsrun002.stdout b/testsuite/tests/lib/should_run/exceptionsrun002.stdout new file mode 100644 index 0000000000..e15116f5c0 --- /dev/null +++ b/testsuite/tests/lib/should_run/exceptionsrun002.stdout @@ -0,0 +1,40 @@ +>> CAUGHT return +>> CAUGHT return undefined +>> CAUGHT return Exception.throw +>> CAUGHT return error +>> MISSED fail +>> MISSED error +>> MISSED Exception.throw +>> MISSED ioError ErrorCall +>> MISSED ioError IOException +>> MISSED undefined +Prelude.catch MISSED return +Prelude.catch MISSED return undefined +Prelude.catch MISSED return Exception.throw +Prelude.catch MISSED return error +Prelude.catch CAUGHT fail +Prelude.catch MISSED error +Prelude.catch MISSED Exception.throw +Prelude.catch MISSED ioError ErrorCall +Prelude.catch CAUGHT ioError IOException +Prelude.catch MISSED undefined +Exception.catch MISSED return +Exception.catch MISSED return undefined +Exception.catch MISSED return Exception.throw +Exception.catch MISSED return error +Exception.catch CAUGHT fail +Exception.catch CAUGHT error +Exception.catch CAUGHT Exception.throw +Exception.catch CAUGHT ioError ErrorCall +Exception.catch CAUGHT ioError IOException +Exception.catch CAUGHT undefined +Exception.finally CAUGHT return +Exception.finally CAUGHT return undefined +Exception.finally CAUGHT return Exception.throw +Exception.finally CAUGHT return error +Exception.finally CAUGHT fail +Exception.finally CAUGHT error +Exception.finally CAUGHT Exception.throw +Exception.finally CAUGHT ioError ErrorCall +Exception.finally CAUGHT ioError IOException +Exception.finally CAUGHT undefined diff --git a/testsuite/tests/lib/should_run/length001.hs b/testsuite/tests/lib/should_run/length001.hs new file mode 100644 index 0000000000..321a1b9dfc --- /dev/null +++ b/testsuite/tests/lib/should_run/length001.hs @@ -0,0 +1,8 @@ + +module Main (main) where + +import Data.List + +main :: IO () +main = do print (genericLength [1..10000000] :: Int) + print (genericLength [1..10000000] :: Integer) diff --git a/testsuite/tests/lib/should_run/length001.stdout b/testsuite/tests/lib/should_run/length001.stdout new file mode 100644 index 0000000000..4e65c4e0d2 --- /dev/null +++ b/testsuite/tests/lib/should_run/length001.stdout @@ -0,0 +1,2 @@ +10000000 +10000000 diff --git a/testsuite/tests/lib/should_run/list001.hs b/testsuite/tests/lib/should_run/list001.hs new file mode 100644 index 0000000000..c0a1eced27 --- /dev/null +++ b/testsuite/tests/lib/should_run/list001.hs @@ -0,0 +1,152 @@ +module Main where + +import Data.List +import Control.Exception +import Prelude hiding (catch) + +-- This module briefly tests all the functions in PrelList and a few +-- from List. + +-- ToDo: test strictness properties. + +main = do + + -- head + print (head [1,2,3,4], head "a") + catch (print (head [] :: String)) (\(ErrorCall _) -> putStr "head []\n") + + -- tail + print (tail [1,2,3,4], tail "a") + catch (print (tail [] :: String)) (\(ErrorCall _) -> putStr "tail []\n") + + -- init + print (init [1,2,3,4], init "a") + catch (print (init [] :: String)) (\(ErrorCall _) -> putStr "init []\n") + + -- last + print (last [1,2,3,4], last "a") + catch (print (last [] :: String)) (\(ErrorCall _) -> putStr "last []\n") + + -- null + print [null [], null "abc"] + + -- length + print (length [1..10]) + + -- foldl + print (foldl (+) 1 [1..10]) + + -- foldl1 + print (foldl1 (+) [1..10]) + catch (print (foldl1 (+) [] :: Int)) (\(ErrorCall _) -> putStr "foldl1 []\n") + + -- scanl + print (scanl (+) 1 [1..10]) + + -- scanl1 + print (scanl1 (+) [1..10]) + print (scanl1 (+) [] :: [Int]) + + -- foldr1 + print (foldr1 (+) [1..10]) + catch (print (foldr1 (+) [] :: Int)) (\(ErrorCall _) -> putStr "foldr1 []\n") + + -- scanr + print (scanr (+) 1 [1..10]) + + -- scanr1 + print (scanr1 (+) [1..10]) + print (scanr1 (+) [] :: [Int]) + + -- iterate + print (take 10 (cycle (take 4 (iterate (+1) 1)))) + + -- take + print (take 4 (repeat "x"), take 0 (repeat "x"), take 5 [1..4]) + catch (print (take (-1) [1..10])) (\(ErrorCall _) -> 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]] + catch (print (drop (-1) [1..10])) (\(ErrorCall _) -> putStr "drop (-1)\n") + + -- splitAt + print [splitAt 5 [1..10], splitAt 5 [1..4]] + catch (print (splitAt (-1) [1..10])) (\(ErrorCall _) -> putStr "splitAt (-1)\n") + + -- scan + print (span (<5) [1..10]) + + -- break + print (break (<5) [1..10]) + + -- reverse + print [reverse [1..10], reverse []] + + -- and + print [and [], and [True], and [False]] + + -- or + print [or [], or [True], or [False]] + + -- elem + print [elem 5 [1..10], elem 0 [1..10], elem 1 []] + + -- notElem + print [notElem 5 [1..10], notElem 0 [1..10], notElem 1 []] + + -- lookkup + print (lookup 4 (zip [1..10] (reverse [1..10]))) + + -- sum + print [sum [1..10], sum []] + + -- product + print [product [1..10], product []] + + -- maximum + print (maximum [1..10]) + catch (print (maximum [] :: Int)) (\(ErrorCall _) -> putStr "maximum []\n") + + -- minimum + print (minimum [1..10]) + catch (print (minimum [] :: Int)) (\(ErrorCall _) -> putStr "minimum []\n") + + -- concatMap + print (concatMap (:[]) [(1::Int)..10]) + + -- zip + print [zip [1] [2], zip [1] [], zip [] [2], zip [1..5] [2..6]] + + -- zip3 + print (zip3 [1,2] [3,4] [5,6]) + + -- zipWith + print [zipWith (+) [1,2] [3,4], zipWith (+) [1] [], zipWith (+) [] []] + + -- unzip + print [unzip [(1,2),(3,4)], unzip []] + + -- unzip3 + print [unzip3 [(1,2,3),(3,4,5)], unzip3 []] + + -- unlines + print (unlines (lines "a\nb\nc\n"), lines "", unlines []) + + -- words + print (unwords (words "a b c d"), words "", unwords []) + + -- deleteBy + print [deleteBy (==) 1 [0,1,1,2,3,4], + deleteBy (==) (error "deleteBy") []] + + -- delete + print [delete 1 [0,1,1,2,3,4], + delete (error "delete") []] + + -- \\ + print [ [0,1,1,2,3,4] \\ [3,2,1], + [1,2,3,4] \\ [], + [] \\ [error "\\\\"] ] diff --git a/testsuite/tests/lib/should_run/list001.stdout b/testsuite/tests/lib/should_run/list001.stdout new file mode 100644 index 0000000000..b8254f066e --- /dev/null +++ b/testsuite/tests/lib/should_run/list001.stdout @@ -0,0 +1,54 @@ +(1,'a') +"head [] +([2,3,4],"") +"tail [] +([1,2,3],"") +"init [] +(4,'a') +"last [] +[True,False] +10 +56 +55 +foldl1 [] +[1,2,4,7,11,16,22,29,37,46,56] +[1,3,6,10,15,21,28,36,45,55] +[] +55 +foldr1 [] +[56,55,53,50,46,41,35,28,20,11,1] +[55,54,52,49,45,40,34,27,19,10] +[] +[1,2,3,4,1,2,3,4,1,2] +(["x","x","x","x"],[],[1,2,3,4]) +[] +[["abc","abc"],[],["","",""]] +[[6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10],[]] +[1,2,3,4,5,6,7,8,9,10] +[([1,2,3,4,5],[6,7,8,9,10]),([1,2,3,4],[])] +([],[1,2,3,4,5,6,7,8,9,10]) +([1,2,3,4],[5,6,7,8,9,10]) +([],[1,2,3,4,5,6,7,8,9,10]) +[[10,9,8,7,6,5,4,3,2,1],[]] +[True,True,False] +[False,True,False] +[True,False,False] +[False,True,True] +Just 7 +[55,0] +[3628800,1] +10 +maximum [] +1 +minimum [] +[1,2,3,4,5,6,7,8,9,10] +[[(1,2)],[],[],[(1,2),(2,3),(3,4),(4,5),(5,6)]] +[(1,3,5),(2,4,6)] +[[4,6],[],[]] +[([1,3],[2,4]),([],[])] +[([1,3],[2,4],[3,5]),([],[],[])] +("a\nb\nc\n",[],"") +("a b c d",[],"") +[[0,1,2,3,4],[]] +[[0,1,2,3,4],[]] +[[0,1,4],[1,2,3,4],[]] diff --git a/testsuite/tests/lib/should_run/list001.stdout-ghc b/testsuite/tests/lib/should_run/list001.stdout-ghc new file mode 100644 index 0000000000..16e780ac7b --- /dev/null +++ b/testsuite/tests/lib/should_run/list001.stdout-ghc @@ -0,0 +1,54 @@ +(1,'a') +head [] +([2,3,4],"") +tail [] +([1,2,3],"") +init [] +(4,'a') +last [] +[True,False] +10 +56 +55 +foldl1 [] +[1,2,4,7,11,16,22,29,37,46,56] +[1,3,6,10,15,21,28,36,45,55] +[] +55 +foldr1 [] +[56,55,53,50,46,41,35,28,20,11,1] +[55,54,52,49,45,40,34,27,19,10] +[] +[1,2,3,4,1,2,3,4,1,2] +(["x","x","x","x"],[],[1,2,3,4]) +[] +[["abc","abc"],[],["","",""]] +[[6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10],[]] +[1,2,3,4,5,6,7,8,9,10] +[([1,2,3,4,5],[6,7,8,9,10]),([1,2,3,4],[])] +([],[1,2,3,4,5,6,7,8,9,10]) +([1,2,3,4],[5,6,7,8,9,10]) +([],[1,2,3,4,5,6,7,8,9,10]) +[[10,9,8,7,6,5,4,3,2,1],[]] +[True,True,False] +[False,True,False] +[True,False,False] +[False,True,True] +Just 7 +[55,0] +[3628800,1] +10 +maximum [] +1 +minimum [] +[1,2,3,4,5,6,7,8,9,10] +[[(1,2)],[],[],[(1,2),(2,3),(3,4),(4,5),(5,6)]] +[(1,3,5),(2,4,6)] +[[4,6],[],[]] +[([1,3],[2,4]),([],[])] +[([1,3],[2,4],[3,5]),([],[],[])] +("a\nb\nc\n",[],"") +("a b c d",[],"") +[[0,1,2,3,4],[]] +[[0,1,2,3,4],[]] +[[0,1,4],[1,2,3,4],[]] diff --git a/testsuite/tests/lib/should_run/list002.hs b/testsuite/tests/lib/should_run/list002.hs new file mode 100644 index 0000000000..188ff8953d --- /dev/null +++ b/testsuite/tests/lib/should_run/list002.hs @@ -0,0 +1,6 @@ +-- !!! Test that List.sortBy is stable. + +import Data.List + +main = print (sortBy (\(a,b) (a',b')->compare a a') + ([1,1,1,1,1,1,1,1,1,1]`zip`[1..10])) diff --git a/testsuite/tests/lib/should_run/list002.stdout b/testsuite/tests/lib/should_run/list002.stdout new file mode 100644 index 0000000000..18e1fcad8a --- /dev/null +++ b/testsuite/tests/lib/should_run/list002.stdout @@ -0,0 +1 @@ +[(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10)] diff --git a/testsuite/tests/lib/should_run/list003.hs b/testsuite/tests/lib/should_run/list003.hs new file mode 100644 index 0000000000..a792094438 --- /dev/null +++ b/testsuite/tests/lib/should_run/list003.hs @@ -0,0 +1,7 @@ +-- !!! Test that length doesn't give a stack overflow + +module Main (main) where + +main :: IO () +main = print $ length $ filter odd [0 .. 9999999] + diff --git a/testsuite/tests/lib/should_run/list003.stdout b/testsuite/tests/lib/should_run/list003.stdout new file mode 100644 index 0000000000..447a331b1b --- /dev/null +++ b/testsuite/tests/lib/should_run/list003.stdout @@ -0,0 +1 @@ +5000000 diff --git a/testsuite/tests/lib/should_run/memo001.hs b/testsuite/tests/lib/should_run/memo001.hs new file mode 100644 index 0000000000..551bcd8cf4 --- /dev/null +++ b/testsuite/tests/lib/should_run/memo001.hs @@ -0,0 +1,19 @@ +module Main(main) where + +import Memo1 + +testMemo = do + let keys = [ [1..n] | n <- [1..1000] ] + keys2 = [ [n,n-1..1] | n <- [1..1000] ] + mlength = memo length + putStr (show (map mlength (keys ++ keys ++ keys2 ++ keys2))) + putStr (show (mlength [1..100000])) + +-- mlength will memoize itself over each element of 'keys', returning +-- the memoized result the second time around. Then we move onto +-- keys2, and while we're doing this the first lot of memo table +-- entries can be purged. Finally, we do a a large computation +-- (length [1..10000]) to allow time for the memo table to be fully +-- purged. + +main = testMemo diff --git a/testsuite/tests/lib/should_run/memo001.stdout b/testsuite/tests/lib/should_run/memo001.stdout new file mode 100644 index 0000000000..0e1bce9647 --- /dev/null +++ b/testsuite/tests/lib/should_run/memo001.stdout @@ -0,0 +1 @@ +[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000]100000
\ No newline at end of file diff --git a/testsuite/tests/lib/should_run/memo002.hs b/testsuite/tests/lib/should_run/memo002.hs new file mode 100644 index 0000000000..aa0a1d27c9 --- /dev/null +++ b/testsuite/tests/lib/should_run/memo002.hs @@ -0,0 +1,30 @@ +module Main where + +import Memo2 ( memo ) +import Data.List ( genericLength, genericReplicate ) +import System.Environment ( getArgs ) + +main :: IO () +main = do (arg:_) <- getArgs + mapM_ printTriple [ (i,fib i,mfib i) | i <- [10..read arg] ] + where printTriple (i,fi,mfi) = do print i + print fi + print mfi + putStrLn "" + +-- There is not much point in memoising Integers, so we use unary "numbers" instead +mfib :: Integer -> Integer +mfib = genericLength . mfib' . flip genericReplicate () + +mfib' :: [()] -> [()] +mfib' = memo ufib + +ufib :: [()] -> [()] +ufib [] = [()] +ufib [()] = [()] +ufib (():n1@(():n2)) = mfib' n1 ++ mfib' n2 + +fib :: Integer -> Integer +fib 0 = 1 +fib 1 = 1 +fib n = fib (n-1) + fib (n-2) diff --git a/testsuite/tests/lib/should_run/memo002.stdout b/testsuite/tests/lib/should_run/memo002.stdout new file mode 100644 index 0000000000..7369b408ef --- /dev/null +++ b/testsuite/tests/lib/should_run/memo002.stdout @@ -0,0 +1,44 @@ +10 +89 +89 + +11 +144 +144 + +12 +233 +233 + +13 +377 +377 + +14 +610 +610 + +15 +987 +987 + +16 +1597 +1597 + +17 +2584 +2584 + +18 +4181 +4181 + +19 +6765 +6765 + +20 +10946 +10946 + diff --git a/testsuite/tests/lib/should_run/packedstring001.hs b/testsuite/tests/lib/should_run/packedstring001.hs new file mode 100644 index 0000000000..9ee24e232c --- /dev/null +++ b/testsuite/tests/lib/should_run/packedstring001.hs @@ -0,0 +1,11 @@ + +module Main (main) where + +import Char (isSpace) +import Data.PackedString + +-- Bug in PackedString.lhs (fixed in rev 1.5) + +foo = packString "this is a test" +main = print (filterPS (not.isSpace) foo) + diff --git a/testsuite/tests/lib/should_run/packedstring001.stdout b/testsuite/tests/lib/should_run/packedstring001.stdout new file mode 100644 index 0000000000..fbd5abc3a0 --- /dev/null +++ b/testsuite/tests/lib/should_run/packedstring001.stdout @@ -0,0 +1 @@ +"thisisatest" diff --git a/testsuite/tests/lib/should_run/rand001.hs b/testsuite/tests/lib/should_run/rand001.hs new file mode 100644 index 0000000000..3567ae0dd8 --- /dev/null +++ b/testsuite/tests/lib/should_run/rand001.hs @@ -0,0 +1,22 @@ +module Main(main) where + +import System.Random + +tstRnd rng = checkRange rng (genRnd 50 rng) + +genRnd n rng = take n (randomRs rng (mkStdGen 2)) + +checkRange (lo,hi) = all pred + where + pred + | lo <= hi = \ x -> x >= lo && x <= hi + | otherwise = \ x -> x >= hi && x <= lo + +main :: IO () +main = do + print (tstRnd (1,5::Double)) + print (tstRnd (1,5::Int)) + print (tstRnd (10,54::Integer)) + print (tstRnd ((-6),2::Int)) + print (tstRnd (2,(-6)::Int)) + diff --git a/testsuite/tests/lib/should_run/rand001.stdout b/testsuite/tests/lib/should_run/rand001.stdout new file mode 100644 index 0000000000..2e883c51de --- /dev/null +++ b/testsuite/tests/lib/should_run/rand001.stdout @@ -0,0 +1,5 @@ +True +True +True +True +True diff --git a/testsuite/tests/lib/should_run/ratio001.hs b/testsuite/tests/lib/should_run/ratio001.hs new file mode 100644 index 0000000000..4d65dfbccf --- /dev/null +++ b/testsuite/tests/lib/should_run/ratio001.hs @@ -0,0 +1,4 @@ +import Data.Ratio + +-- !!! Test that (%) has the right fixity +main = print (2^3%5) diff --git a/testsuite/tests/lib/should_run/ratio001.stdout b/testsuite/tests/lib/should_run/ratio001.stdout new file mode 100644 index 0000000000..f7355f9a4a --- /dev/null +++ b/testsuite/tests/lib/should_run/ratio001.stdout @@ -0,0 +1 @@ +8 % 5 diff --git a/testsuite/tests/lib/should_run/ratio001.stdout-ghc b/testsuite/tests/lib/should_run/ratio001.stdout-ghc new file mode 100644 index 0000000000..f7355f9a4a --- /dev/null +++ b/testsuite/tests/lib/should_run/ratio001.stdout-ghc @@ -0,0 +1 @@ +8 % 5 diff --git a/testsuite/tests/lib/should_run/reads001.hs b/testsuite/tests/lib/should_run/reads001.hs new file mode 100644 index 0000000000..318367e7f4 --- /dev/null +++ b/testsuite/tests/lib/should_run/reads001.hs @@ -0,0 +1,10 @@ +-- Test the classic "\SOH" ambiguity + +module Main(main) where + +main = do { print soh ; print (length (fst (head soh))) ; + print so ; print (length (fst (head so))) } + where + so, soh :: [(String,String)] + soh = reads "\"\\SOH\"" -- Should read \SOH + so = reads "\"\\SOx\"" -- Should read \SO followed by x diff --git a/testsuite/tests/lib/should_run/reads001.stdout b/testsuite/tests/lib/should_run/reads001.stdout new file mode 100644 index 0000000000..23639933e8 --- /dev/null +++ b/testsuite/tests/lib/should_run/reads001.stdout @@ -0,0 +1,4 @@ +[("\SOH","")] +1 +[("\SOx","")] +2 diff --git a/testsuite/tests/lib/should_run/show001.hs b/testsuite/tests/lib/should_run/show001.hs new file mode 100644 index 0000000000..69c27d01ea --- /dev/null +++ b/testsuite/tests/lib/should_run/show001.hs @@ -0,0 +1,24 @@ +-- !!! Testing Show on Maybes and Eithers +module Main(main) where + +x :: Maybe () +x = Nothing + +main :: IO () +main = do + print x + print (Just ()) + print ((Just (Just ())) :: Maybe (Maybe ())) + print (Just x) + print ((Left 'a') :: Either Char Int) + print ((Right 'b') :: Either Int Char) + print ((Right x) :: Either Int (Maybe ())) + print ((Right (Just 'c')) :: Either Int (Maybe Char)) + print ((Right (Right 'd')) :: Either Int (Either Char Char)) + print ((Right (Left 'e')) :: Either Int (Either Char Int)) + print ((Left 'f') :: Either Char Int) + print ((Left x) :: Either (Maybe ()) Char) + print ((Left (Just 'g')) :: Either (Maybe Char) ()) + print ((Left (Right 'h')) :: Either (Either Int Char) Char) + print ((Left (Right 'i')) :: Either (Either Int Char) ()) + diff --git a/testsuite/tests/lib/should_run/show001.stdout b/testsuite/tests/lib/should_run/show001.stdout new file mode 100644 index 0000000000..3be0062e87 --- /dev/null +++ b/testsuite/tests/lib/should_run/show001.stdout @@ -0,0 +1,15 @@ +Nothing +Just () +Just (Just ()) +Just Nothing +Left 'a' +Right 'b' +Right Nothing +Right (Just 'c') +Right (Right 'd') +Right (Left 'e') +Left 'f' +Left Nothing +Left (Just 'g') +Left (Right 'h') +Left (Right 'i') diff --git a/testsuite/tests/lib/should_run/stableptr001.hs b/testsuite/tests/lib/should_run/stableptr001.hs new file mode 100644 index 0000000000..1bc857aba6 --- /dev/null +++ b/testsuite/tests/lib/should_run/stableptr001.hs @@ -0,0 +1,19 @@ + +module Main where + +import Foreign + +-- simple test for building/dereferencing stable ptrs + +main + = do l <- mapM newStablePtr [1..100000] + sum <- stable_sum l + print sum + +stable_sum :: [StablePtr Integer] -> IO Integer +stable_sum [] = return 0 +stable_sum (x:xs) + = do x' <- deRefStablePtr x + freeStablePtr x + xs' <- stable_sum xs + return (x' + xs') diff --git a/testsuite/tests/lib/should_run/stableptr001.stdout b/testsuite/tests/lib/should_run/stableptr001.stdout new file mode 100644 index 0000000000..90ee71a089 --- /dev/null +++ b/testsuite/tests/lib/should_run/stableptr001.stdout @@ -0,0 +1 @@ +5000050000 diff --git a/testsuite/tests/lib/should_run/stableptr003.hs b/testsuite/tests/lib/should_run/stableptr003.hs new file mode 100644 index 0000000000..77f4e3c9dc --- /dev/null +++ b/testsuite/tests/lib/should_run/stableptr003.hs @@ -0,0 +1,16 @@ +module Main where + +import Control.Monad +import System.Mem.StableName +import Control.Exception + +main = do + mapM_ evaluate list + stable_list1 <- mapM makeStableName list + stable_list2 <- mapM makeStableName list + unless (stable_list1 == stable_list2) $ do + let l1 = map hashStableName stable_list1 + let l2 = map hashStableName stable_list2 + print $ zip l1 l2 + +list = [1..10000] :: [Integer] diff --git a/testsuite/tests/lib/should_run/stableptr004.hs b/testsuite/tests/lib/should_run/stableptr004.hs new file mode 100644 index 0000000000..2d6f567cae --- /dev/null +++ b/testsuite/tests/lib/should_run/stableptr004.hs @@ -0,0 +1,12 @@ +import Foreign.StablePtr + +-- compile without optimisation. +-- run with +RTS -D256 to see the stable pointer being garbage collected. + +main = do + let xs = [ 1 .. 50000 ] + let ys = [ 1 .. 60000 ] + s1 <- newStablePtr xs + print (sum xs) + freeStablePtr s1 + print (sum ys) diff --git a/testsuite/tests/lib/should_run/stableptr004.stdout b/testsuite/tests/lib/should_run/stableptr004.stdout new file mode 100644 index 0000000000..30e717b5bd --- /dev/null +++ b/testsuite/tests/lib/should_run/stableptr004.stdout @@ -0,0 +1,2 @@ +1250025000 +1800030000 diff --git a/testsuite/tests/lib/should_run/stableptr005.hs b/testsuite/tests/lib/should_run/stableptr005.hs new file mode 100644 index 0000000000..dc4928ab6c --- /dev/null +++ b/testsuite/tests/lib/should_run/stableptr005.hs @@ -0,0 +1,22 @@ +-- !!! triggered a temporary bug in freeStablePtr around 20020424 + +module Main where +import Foreign.StablePtr (newStablePtr, freeStablePtr) + +data Foo = A | B | C | D + +main :: IO () +main = do aSPtr <- newStablePtr A + bSPtr <- newStablePtr B + cSPtr <- newStablePtr C + cSPtr' <- newStablePtr C + freeStablePtr aSPtr + freeStablePtr bSPtr + freeStablePtr cSPtr + freeStablePtr cSPtr' + aSPtr <- newStablePtr A + bSPtr <- newStablePtr B + cSPtr <- newStablePtr C + dSPtr <- newStablePtr D + print "Hello World" + diff --git a/testsuite/tests/lib/should_run/stableptr005.stdout b/testsuite/tests/lib/should_run/stableptr005.stdout new file mode 100644 index 0000000000..06ae699f22 --- /dev/null +++ b/testsuite/tests/lib/should_run/stableptr005.stdout @@ -0,0 +1 @@ +"Hello World" diff --git a/testsuite/tests/lib/should_run/text001.hs b/testsuite/tests/lib/should_run/text001.hs new file mode 100644 index 0000000000..18aab82dd9 --- /dev/null +++ b/testsuite/tests/lib/should_run/text001.hs @@ -0,0 +1,15 @@ +{- Bug report 28 May 99 + +When compiled with ghc-4.02, everything's fine, it outputs "Value 7" as +expected. But compiled with ghc-pre-4.03 it yields this error message. + + Fail: Prelude.read: no parse +-} + +module Main where + +data Msg = Value Int | Inc deriving (Show, Read) + +main = do let v = read "Value 7"::Msg + print v + diff --git a/testsuite/tests/lib/should_run/text001.stdout b/testsuite/tests/lib/should_run/text001.stdout new file mode 100644 index 0000000000..a0c782242e --- /dev/null +++ b/testsuite/tests/lib/should_run/text001.stdout @@ -0,0 +1 @@ +Value 7 diff --git a/testsuite/tests/lib/should_run/tup001.hs b/testsuite/tests/lib/should_run/tup001.hs new file mode 100644 index 0000000000..a70e09027a --- /dev/null +++ b/testsuite/tests/lib/should_run/tup001.hs @@ -0,0 +1,33 @@ +-- Test instances for tuples up to 15 +-- For Read, Show, Eq, Ord, Bounded + +module Main where + +data T = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O + deriving( Eq, Ord, Show, Read, Bounded ) + +t15 = (A,B,C,D,E,F,G,H,I,J,K,L,M,N,O) +t14 = (A,B,C,D,E,F,G,H,I,J,K,L,M,N) +t13 = (A,B,C,D,E,F,G,H,I,J,K,L,M) +t12 = (A,B,C,D,E,F,G,H,I,J,K,L) +t11 = (A,B,C,D,E,F,G,H,I,J,K) +t10 = (A,B,C,D,E,F,G,H,I,J) +t9 = (A,B,C,D,E,F,G,H,I) +t8 = (A,B,C,D,E,F,G,H) +t7 = (A,B,C,D,E,F,G) +t6 = (A,B,C,D,E,F) +t5 = (A,B,C,D,E) +t4 = (A,B,C,D) +t3 = (A,B,C) +t2 = (A,B) +t0 = () + +big = (t0,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15) + +main = do print big + print (read (show big) `asTypeOf` big) + print (big == big) + print (big < big) + print (big > big) + print (minBound `asTypeOf` big) + print (maxBound `asTypeOf` big)
\ No newline at end of file diff --git a/testsuite/tests/lib/should_run/tup001.stdout b/testsuite/tests/lib/should_run/tup001.stdout new file mode 100644 index 0000000000..540340b816 --- /dev/null +++ b/testsuite/tests/lib/should_run/tup001.stdout @@ -0,0 +1,7 @@ +((),(A,B),(A,B,C),(A,B,C,D),(A,B,C,D,E),(A,B,C,D,E,F),(A,B,C,D,E,F,G),(A,B,C,D,E,F,G,H),(A,B,C,D,E,F,G,H,I),(A,B,C,D,E,F,G,H,I,J),(A,B,C,D,E,F,G,H,I,J,K),(A,B,C,D,E,F,G,H,I,J,K,L),(A,B,C,D,E,F,G,H,I,J,K,L,M),(A,B,C,D,E,F,G,H,I,J,K,L,M,N),(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O)) +((),(A,B),(A,B,C),(A,B,C,D),(A,B,C,D,E),(A,B,C,D,E,F),(A,B,C,D,E,F,G),(A,B,C,D,E,F,G,H),(A,B,C,D,E,F,G,H,I),(A,B,C,D,E,F,G,H,I,J),(A,B,C,D,E,F,G,H,I,J,K),(A,B,C,D,E,F,G,H,I,J,K,L),(A,B,C,D,E,F,G,H,I,J,K,L,M),(A,B,C,D,E,F,G,H,I,J,K,L,M,N),(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O)) +True +False +False +((),(A,A),(A,A,A),(A,A,A,A),(A,A,A,A,A),(A,A,A,A,A,A),(A,A,A,A,A,A,A),(A,A,A,A,A,A,A,A),(A,A,A,A,A,A,A,A,A),(A,A,A,A,A,A,A,A,A,A),(A,A,A,A,A,A,A,A,A,A,A),(A,A,A,A,A,A,A,A,A,A,A,A),(A,A,A,A,A,A,A,A,A,A,A,A,A),(A,A,A,A,A,A,A,A,A,A,A,A,A,A),(A,A,A,A,A,A,A,A,A,A,A,A,A,A,A)) +((),(O,O),(O,O,O),(O,O,O,O),(O,O,O,O,O),(O,O,O,O,O,O),(O,O,O,O,O,O,O),(O,O,O,O,O,O,O,O),(O,O,O,O,O,O,O,O,O),(O,O,O,O,O,O,O,O,O,O),(O,O,O,O,O,O,O,O,O,O,O),(O,O,O,O,O,O,O,O,O,O,O,O),(O,O,O,O,O,O,O,O,O,O,O,O,O),(O,O,O,O,O,O,O,O,O,O,O,O,O,O),(O,O,O,O,O,O,O,O,O,O,O,O,O,O,O)) diff --git a/testsuite/tests/lib/should_run/weak001.hs b/testsuite/tests/lib/should_run/weak001.hs new file mode 100644 index 0000000000..60dc9c4a12 --- /dev/null +++ b/testsuite/tests/lib/should_run/weak001.hs @@ -0,0 +1,12 @@ +import Foreign +import System.Mem.Weak + +kill:: Ptr a -> IO () +kill a = do + w <- mkWeakPtr a Nothing + addFinalizer a $ + deRefWeak w >> return () + +main:: IO () +main = sequence_ . take 10000 . repeat $ + mallocBytes 100 >>= kill >> return () |