summaryrefslogtreecommitdiff
path: root/libraries/base/tests/dynamic004.hs
diff options
context:
space:
mode:
authorPaolo Capriotti <p.capriotti@gmail.com>2012-03-09 11:42:24 +0000
committerPaolo Capriotti <p.capriotti@gmail.com>2012-03-09 13:04:46 +0000
commit7e84795cdd797cc3718dfce730e8a7c6a2a31b63 (patch)
tree4035924f4671336aa57028a42b4e3abca7673235 /libraries/base/tests/dynamic004.hs
parentba85754a049791ee795ba887e698523f1885d3f3 (diff)
downloadhaskell-7e84795cdd797cc3718dfce730e8a7c6a2a31b63.tar.gz
Copy tests from GHC testsuite; part of #1161.
Diffstat (limited to 'libraries/base/tests/dynamic004.hs')
-rw-r--r--libraries/base/tests/dynamic004.hs36
1 files changed, 36 insertions, 0 deletions
diff --git a/libraries/base/tests/dynamic004.hs b/libraries/base/tests/dynamic004.hs
new file mode 100644
index 0000000000..e6b7a82bfd
--- /dev/null
+++ b/libraries/base/tests/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
+-}