summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonmar <unknown>2000-09-05 12:38:27 +0000
committersimonmar <unknown>2000-09-05 12:38:27 +0000
commit040b7deab8dceb8cc98a596c38fdb207c10636f1 (patch)
tree4d4c87f830902398d103e7ff8333a321f6a80baa
parente64ce004cba48698381494d386b4132eb9a1c71a (diff)
downloadhaskell-040b7deab8dceb8cc98a596c38fdb207c10636f1.tar.gz
[project @ 2000-09-05 12:38:26 by simonmar]
Add tests for newtypes in foreign declarations.
-rw-r--r--ghc/tests/ccall/should_compile/Makefile1
-rw-r--r--ghc/tests/ccall/should_compile/cc008.hs8
-rw-r--r--ghc/tests/ccall/should_compile/cc009.hs8
-rw-r--r--ghc/tests/ccall/should_fail/cc005.hs11
-rw-r--r--ghc/tests/ccall/should_fail/cc005.stderr13
5 files changed, 41 insertions, 0 deletions
diff --git a/ghc/tests/ccall/should_compile/Makefile b/ghc/tests/ccall/should_compile/Makefile
index a56869f13d..c6acaf680b 100644
--- a/ghc/tests/ccall/should_compile/Makefile
+++ b/ghc/tests/ccall/should_compile/Makefile
@@ -7,6 +7,7 @@ SRC_HC_OPTS += -dcore-lint -fglasgow-exts
# Note that these tests are still in a state of flux... don't believe errors
# they report. In fact, these aren't really very good tests at all...
+cc004_HC_OPTS = -fvia-C
cc005_HC_OPTS = -fvia-C
cc006_HC_OPTS = -fvia-C -fno-prune-tydecls
diff --git a/ghc/tests/ccall/should_compile/cc008.hs b/ghc/tests/ccall/should_compile/cc008.hs
new file mode 100644
index 0000000000..6e141f49b5
--- /dev/null
+++ b/ghc/tests/ccall/should_compile/cc008.hs
@@ -0,0 +1,8 @@
+-- !!! cc008 -- foreign export dynamic returning newtype of Addr
+module Test where
+
+import Addr
+
+newtype Ptr a = Ptr Addr
+
+foreign export dynamic mkFoo :: IO () -> IO (Ptr Int)
diff --git a/ghc/tests/ccall/should_compile/cc009.hs b/ghc/tests/ccall/should_compile/cc009.hs
new file mode 100644
index 0000000000..959ebea9a2
--- /dev/null
+++ b/ghc/tests/ccall/should_compile/cc009.hs
@@ -0,0 +1,8 @@
+-- !!! cc009 -- foreign label returning newtype of Addr
+module Test where
+
+import Addr
+
+newtype Ptr a = Ptr Addr
+
+foreign label foo :: Ptr Int
diff --git a/ghc/tests/ccall/should_fail/cc005.hs b/ghc/tests/ccall/should_fail/cc005.hs
new file mode 100644
index 0000000000..f04b155aa3
--- /dev/null
+++ b/ghc/tests/ccall/should_fail/cc005.hs
@@ -0,0 +1,11 @@
+-- !!! illegal types in foreign export delarations
+
+module ShouldFail where
+
+import PrelGHC
+
+foreign export foo :: Int# -> IO ()
+foo i | i ==# 0# = return ()
+
+foreign export bar :: Int -> Int#
+bar _ = 42#
diff --git a/ghc/tests/ccall/should_fail/cc005.stderr b/ghc/tests/ccall/should_fail/cc005.stderr
new file mode 100644
index 0000000000..7c5c5485c6
--- /dev/null
+++ b/ghc/tests/ccall/should_fail/cc005.stderr
@@ -0,0 +1,13 @@
+
+cc005.hs:7:
+ Unacceptable argument type in foreign declaration: Int#
+ When checking declaration:
+ foreign export _ccall "foo" foo :: Int# -> IO ()
+
+cc005.hs:10:
+ Unacceptable result type in foreign declaration: Int#
+ When checking declaration:
+ foreign export _ccall "bar" bar :: Int -> Int#
+
+Compilation had errors
+