testsuite: Add a TypeRep test
authorBen Gamari <bgamari.foss@gmail.com>
Thu, 19 May 2016 19:05:22 +0000 (21:05 +0200)
committerBen Gamari <ben@smart-cactus.org>
Thu, 19 May 2016 19:34:44 +0000 (21:34 +0200)
Test Plan: Validate

Reviewers: goldfire, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2239

GHC Trac Issues: #12082, #11120

testsuite/tests/typecheck/should_run/TypeRep.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/TypeRep.stdout [new file with mode: 0644]
testsuite/tests/typecheck/should_run/all.T

diff --git a/testsuite/tests/typecheck/should_run/TypeRep.hs b/testsuite/tests/typecheck/should_run/TypeRep.hs
new file mode 100644 (file)
index 0000000..3ae9577
--- /dev/null
@@ -0,0 +1,48 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE TypeInType #-}
+{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE AllowAmbiguousTypes #-}
+{-# LANGUAGE TypeOperators #-}
+
+import Data.Typeable
+import Data.Kind
+import GHC.Exts
+
+-- Test that Typeable works for various wired-in types.
+-- See, for instance, #11120.
+
+rep :: forall a. Typeable a => TypeRep
+rep = typeRep (Proxy :: Proxy a)
+
+main :: IO ()
+main = do
+  -- the basics
+  print $ rep @String
+  print $ rep @Char
+  print $ rep @Int
+  print $ rep @Word
+  print $ rep @Double
+  print $ rep @(IO ())
+  print $ rep @IO
+  print $ rep @"hi"
+  print $ rep @(Char, Int, String)
+  print $ rep @Bool
+  print $ rep @Ordering
+  print $ rep @(Int -> Int)
+
+  -- Various instantiations of a kind-polymorphic type
+  print $ rep @(Proxy (Eq Int))
+  print $ rep @(Proxy (Int, Int))
+  print $ rep @(Proxy "hello world")
+  print $ rep @(Proxy 1)
+  print $ rep @(Proxy [1,2,3])
+  print $ rep @(Proxy 'EQ)
+  print $ rep @(Proxy TYPE)
+  print $ rep @(Proxy (TYPE 'PtrRepLifted))
+  print $ rep @(Proxy *)
+  print $ rep @(Proxy ★)
+  print $ rep @(Proxy 'PtrRepLifted)
+
+  -- Something lifted and primitive
+  print $ rep @RealWorld
diff --git a/testsuite/tests/typecheck/should_run/TypeRep.stdout b/testsuite/tests/typecheck/should_run/TypeRep.stdout
new file mode 100644 (file)
index 0000000..de00864
--- /dev/null
@@ -0,0 +1,24 @@
+[Char]
+Char
+Int
+Word
+Double
+IO ()
+IO
+"hi"
+(Char,Int,[Char])
+Bool
+Ordering
+Int -> Int
+Proxy Constraint (Eq Int)
+Proxy Constraint (Int,Int)
+Proxy Symbol "hello world"
+Proxy Nat 1
+Proxy [Nat] (': Nat 1 (': Nat 2 (': Nat 3 '[])))
+Proxy Ordering 'EQ
+Proxy (RuntimeRep -> Constraint) TYPE
+Proxy Constraint Constraint
+Proxy Constraint Constraint
+Proxy Constraint Constraint
+Proxy RuntimeRep 'PtrRepLifted
+RealWorld
index ca3753d..74d8f84 100755 (executable)
@@ -114,5 +114,6 @@ test('T10284', exit_code(1), compile_and_run, [''])
 test('T11049', exit_code(1), compile_and_run, [''])
 test('T11230', normal, compile_and_run, [''])
 test('TypeOf', normal, compile_and_run, [''])
-test('T11120', normal, compile_and_run, [''])
+test('TypeRep', normal, compile_and_run, [''])
+test('T11120', expect_broken(12082), compile_and_run, [''])
 test('KindInvariant', normal, ghci_script, ['KindInvariant.script'])