[commit: ghc] master: testsuite: Add a TypeRep test (2e6433a)

git at git.haskell.org git at git.haskell.org
Thu May 19 19:31:44 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/2e6433af56a97ad9c501648afa5e1d8c6c17f82a/ghc

>---------------------------------------------------------------

commit 2e6433af56a97ad9c501648afa5e1d8c6c17f82a
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Thu May 19 21:05:22 2016 +0200

    testsuite: Add a TypeRep test
    
    Test Plan: Validate
    
    Reviewers: goldfire, austin
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2239
    
    GHC Trac Issues: #12082, #11120


>---------------------------------------------------------------

2e6433af56a97ad9c501648afa5e1d8c6c17f82a
 testsuite/tests/typecheck/should_run/TypeRep.hs    | 48 ++++++++++++++++++++++
 .../should_run/{TypeOf.stdout => TypeRep.stdout}   |  5 ++-
 testsuite/tests/typecheck/should_run/all.T         |  3 +-
 3 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/testsuite/tests/typecheck/should_run/TypeRep.hs b/testsuite/tests/typecheck/should_run/TypeRep.hs
new file mode 100644
index 0000000..3ae9577
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/TypeRep.hs
@@ -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/TypeOf.stdout b/testsuite/tests/typecheck/should_run/TypeRep.stdout
similarity index 87%
copy from testsuite/tests/typecheck/should_run/TypeOf.stdout
copy to testsuite/tests/typecheck/should_run/TypeRep.stdout
index 6f160f5..de00864 100644
--- a/testsuite/tests/typecheck/should_run/TypeOf.stdout
+++ b/testsuite/tests/typecheck/should_run/TypeRep.stdout
@@ -4,8 +4,9 @@ Int
 Word
 Double
 IO ()
+IO
+"hi"
 (Char,Int,[Char])
-TypeRep
 Bool
 Ordering
 Int -> Int
@@ -20,4 +21,4 @@ Proxy Constraint Constraint
 Proxy Constraint Constraint
 Proxy Constraint Constraint
 Proxy RuntimeRep 'PtrRepLifted
-Proxy (Constraint -> Constraint -> Constraint) ~~
+RealWorld
diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T
index ca3753d..74d8f84 100755
--- a/testsuite/tests/typecheck/should_run/all.T
+++ b/testsuite/tests/typecheck/should_run/all.T
@@ -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'])



More information about the ghc-commits mailing list