summaryrefslogtreecommitdiff
path: root/testsuite/tests/ffi
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-09-30 17:22:41 +0100
committerIan Lynagh <igloo@earth.li>2011-09-30 23:52:55 +0100
commit9d11154316ce4185cb4df81b85c1cb622de02cbc (patch)
tree92243b7caddc38d3d7cf4582c6bd9feab5f28610 /testsuite/tests/ffi
parente54ec3bc806b9675a6efed9ed10c5fa7f898eb68 (diff)
downloadhaskell-9d11154316ce4185cb4df81b85c1cb622de02cbc.tar.gz
Add some tests for handling of FFI types
Diffstat (limited to 'testsuite/tests/ffi')
-rw-r--r--testsuite/tests/ffi/should_compile/all.T1
-rw-r--r--testsuite/tests/ffi/should_compile/cc015.hs31
2 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_compile/all.T b/testsuite/tests/ffi/should_compile/all.T
index ff8bc64b5d..0c97827a7c 100644
--- a/testsuite/tests/ffi/should_compile/all.T
+++ b/testsuite/tests/ffi/should_compile/all.T
@@ -36,3 +36,4 @@ test('ffi-deriv1', normal, compile, [''])
test('1357', normal, compile, [''])
test('3624', normal, compile, [''])
test('3742', normal, compile, [''])
+test('cc015', normal, compile, [''])
diff --git a/testsuite/tests/ffi/should_compile/cc015.hs b/testsuite/tests/ffi/should_compile/cc015.hs
new file mode 100644
index 0000000000..df724e0637
--- /dev/null
+++ b/testsuite/tests/ffi/should_compile/cc015.hs
@@ -0,0 +1,31 @@
+
+{-# LANGUAGE TypeFamilies #-}
+
+module Cc015 where
+
+type S a = a
+type IOS a = IO a
+
+type family F a
+type instance F Int = Int
+type instance F Bool = G2
+
+newtype G1 = G1 Int
+newtype G1F = G1F (F (S Int))
+newtype G2 = G2 Char
+newtype G3 = G3 (IO Int)
+newtype G4 = G4 G3
+
+-- Type synonyms should be transparent to the typechecker
+foreign import ccall f1 :: S Int -> IOS Int
+foreign export ccall "g1" f1 :: S Int -> IOS Int
+-- As should type functions
+foreign import ccall f2 :: F Int -> IO (F Int)
+foreign export ccall "g2" f2 :: F Int -> IO (F Int)
+-- And newtype
+foreign import ccall f3 :: G1 -> G2 -> G4
+foreign export ccall "g3" f3 :: G1 -> G2 -> G4
+-- And a combination
+foreign import ccall f4 :: G1F -> F Bool -> S G4
+foreign export ccall "g4" f4 :: G1F -> F Bool -> S G4
+