From: sof Date: Thu, 8 Jul 1999 13:51:17 +0000 (+0000) Subject: [project @ 1999-07-08 13:51:17 by sof] X-Git-Tag: Approximately_9120_patches~6007 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;ds=sidebyside;h=2e1efd5786d05b32290a33070221c64326dcb47c;p=ghc-hetmet.git [project @ 1999-07-08 13:51:17 by sof] foreign export regression test --- diff --git a/ghc/tests/programs/fexport/For.hs b/ghc/tests/programs/fexport/For.hs new file mode 100644 index 0000000..306c3a9 --- /dev/null +++ b/ghc/tests/programs/fexport/For.hs @@ -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 index 0000000..d1dd144 --- /dev/null +++ b/ghc/tests/programs/fexport/Makefile @@ -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 index 0000000..a5c1966 --- /dev/null +++ b/ghc/tests/programs/fexport/fexport.stdout @@ -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 index 0000000..3712493 --- /dev/null +++ b/ghc/tests/programs/fexport/test.c @@ -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(); +}