Commit ee7949b5 authored by Simon Marlow's avatar Simon Marlow
Browse files

fix up existing Dynamic/Typeable tests and add a few more

parent 0f15c505
......@@ -21,9 +21,12 @@ test('text001', normal, compile_and_run, [''])
test('tup001', normal, compile_and_run, [''])
test('addr001', normal, compile_and_run, [''])
test('dynamic001', skip_if_fast, compile_and_run, [''])
test('dynamic002', [skip_if_fast,reqlib('packedstring')], compile_and_run, ['-package packedstring'])
test('enum01', skip_if_fast, compile_and_run, ['-cpp'])
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, [''])
......
*** Testing: toDyn ***
[ <<GHC.Types.Int>>
, <<GHC.Types.Char>>
, <<GHC.Types.Bool>>
, <<GHC.Types.Float>>
, <<GHC.Types.Double>>
, <<GHC.Integer.Type.Integer>>
, <<GHC.Types.IO ()>>
, <<[Data.Dynamic.Dynamic]>>
, <<[GHC.Types.Int]>>
, <<Data.Maybe.Maybe GHC.Types.Int>>
, <<Data.Maybe.Maybe GHC.Types.Int>>
, <<Data.Maybe.Maybe GHC.Types.Int>>
, <<Data.Either.Either GHC.Types.Int GHC.Types.Bool>>
, <<Data.Either.Either GHC.Types.Char GHC.Types.Int>>
[ <<Int>>
, <<Char>>
, <<Bool>>
, <<Float>>
, <<Double>>
, <<Integer>>
, <<IO ()>>
, <<[Dynamic]>>
, <<[Int]>>
, <<Maybe Int>>
, <<Maybe Int>>
, <<Maybe Int>>
, <<Either Int Bool>>
, <<Either Char Int>>
, <<()>>
, <<GHC.Ordering.Ordering>>
, <<((),GHC.Types.Int)>>
, <<((),GHC.Types.Int,GHC.Types.Char)>>
, <<((),GHC.Types.Int,GHC.Types.Char,GHC.Types.Double)>>
, <<((),GHC.Types.Int,GHC.Types.Char,GHC.Types.Double,(Data.Maybe.Maybe GHC.Types.Bool))>>
, <<GHC.Types.Int -> GHC.Types.Int -> GHC.Types.Int>>
, <<GHC.Integer.Type.Integer -> GHC.Integer.Type.Integer -> GHC.Integer.Type.Integer>>
, <<[GHC.Types.Char] -> [GHC.Types.Char] -> [GHC.Types.Char]>>
, <<Ordering>>
, <<((),Int)>>
, <<((),Int,Char)>>
, <<((),Int,Char,Double)>>
, <<((),Int,Char,Double,(Maybe Bool))>>
, <<Int -> Int -> Int>>
, <<Integer -> Integer -> Integer>>
, <<[Char] -> [Char] -> [Char]>>
]
*** Testing: fromDyn ***
1
......
......@@ -8,7 +8,6 @@ import Data.Array.ST
import Data.Array.IO
import Data.Array.Unboxed
import Data.Complex
import Data.PackedString
import Data.Int
import Data.Word
import Data.IORef
......@@ -63,7 +62,6 @@ main = do
print (typeOf (undefined :: AsyncException))
print (typeOf (undefined :: (IOArray () ())))
print (typeOf (undefined :: (IOUArray () ())))
print (typeOf (undefined :: PackedString))
print (typeOf (undefined :: (STArray () () ())))
print (typeOf (undefined :: (STUArray () () ())))
print (typeOf (undefined :: (StableName ())))
......@@ -84,7 +82,6 @@ main = do
print (typeOf (undefined :: CULLong))
print (typeOf (undefined :: CFloat))
print (typeOf (undefined :: CDouble))
print (typeOf (undefined :: CLDouble))
print (typeOf (undefined :: CPtrdiff))
print (typeOf (undefined :: CSize))
......
......@@ -33,11 +33,10 @@ Word8
Word16
Word32
Word64
GHC.Exception.ArithException
GHC.IOBase.AsyncException
ArithException
AsyncException
IOArray () ()
IOUArray () ()
PackedString
STArray () () ()
STUArray () () ()
StableName ()
......@@ -57,7 +56,6 @@ CLLong
CULLong
CFloat
CDouble
CLDouble
CPtrdiff
CSize
CWchar
......
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 ())
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
-}
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 ]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment