[project @ 1999-07-08 13:51:17 by sof]
authorsof <unknown>
Thu, 8 Jul 1999 13:51:17 +0000 (13:51 +0000)
committersof <unknown>
Thu, 8 Jul 1999 13:51:17 +0000 (13:51 +0000)
foreign export regression test

ghc/tests/programs/fexport/For.hs [new file with mode: 0644]
ghc/tests/programs/fexport/Makefile [new file with mode: 0644]
ghc/tests/programs/fexport/fexport.stdout [new file with mode: 0644]
ghc/tests/programs/fexport/test.c [new file with mode: 0644]

diff --git a/ghc/tests/programs/fexport/For.hs b/ghc/tests/programs/fexport/For.hs
new file mode 100644 (file)
index 0000000..306c3a9
--- /dev/null
@@ -0,0 +1,25 @@
+module For where
+
+{-
+import IOExts
+import Addr
+--y = putChar
+
+count :: IORef Int -> IO Int
+count ref = do
+  x <- readIORef ref
+  writeIORef ref (x+1)
+  return x
+
+createCounter :: IO Addr
+createCounter = do
+  ref <- newIORef 0
+  mkCounter (count ref)
+
+foreign import "sin" msin :: Double -> IO Double
+-}
+
+foreign export "putChar" putChar :: Char -> IO ()
+
+--foreign export "createCounter" createCounter :: IO Addr
+--foreign export dynamic mkCounter :: (IO Int) -> IO Addr
diff --git a/ghc/tests/programs/fexport/Makefile b/ghc/tests/programs/fexport/Makefile
new file mode 100644 (file)
index 0000000..d1dd144
--- /dev/null
@@ -0,0 +1,10 @@
+TOP = ..
+include $(TOP)/mk/boilerplate.mk
+
+SRC_HC_OPTS += -fglasgow-exts -no-hs-main
+
+CC = $(HC)
+
+all :: runtest
+
+include $(TOP)/mk/target.mk
diff --git a/ghc/tests/programs/fexport/fexport.stdout b/ghc/tests/programs/fexport/fexport.stdout
new file mode 100644 (file)
index 0000000..a5c1966
--- /dev/null
@@ -0,0 +1 @@
+Hello, world
diff --git a/ghc/tests/programs/fexport/test.c b/ghc/tests/programs/fexport/test.c
new file mode 100644 (file)
index 0000000..3712493
--- /dev/null
@@ -0,0 +1,15 @@
+#include "For_stub.h"
+
+int
+main(int argc, char *argv[])
+{
+  int i;
+  char msg[] = "Hello, world\n";
+
+  startupHaskell(argc,argv);
+
+  for (i=0; i < sizeof(msg) - 1; i++) {
+     putChar(msg[i]);
+  }
+  shutdownHaskell();
+}