[commit: testsuite] master: Add a test for CAPI wrapper functions (4a118b7)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/4a118b7b8cfb35cdb1bcf85b45fe21fb7af7ad87

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

commit 4a118b7b8cfb35cdb1bcf85b45fe21fb7af7ad87
Author: Ian Lynagh <[email protected]>
Date:   Fri Nov 2 12:20:09 2012 +0000

    Add a test for CAPI wrapper functions

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

 tests/ffi/should_run/T4012.hs     |   10 ++++++++++
 tests/ffi/should_run/T4012.stdout |    3 +++
 tests/ffi/should_run/T4012_A.hs   |   14 ++++++++++++++
 tests/ffi/should_run/T4012_B.hs   |   11 +++++++++++
 tests/ffi/should_run/all.T        |    7 +++++++
 5 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/tests/ffi/should_run/T4012.hs b/tests/ffi/should_run/T4012.hs
new file mode 100644
index 0000000..d22b3c3
--- /dev/null
+++ b/tests/ffi/should_run/T4012.hs
@@ -0,0 +1,10 @@
+
+module Main (main) where
+
+import T4012_A
+import T4012_B
+
+main :: IO ()
+main = do a
+          b
+
diff --git a/tests/ffi/should_run/T4012.stdout b/tests/ffi/should_run/T4012.stdout
new file mode 100644
index 0000000..f54f234
--- /dev/null
+++ b/tests/ffi/should_run/T4012.stdout
@@ -0,0 +1,3 @@
+Double: 1.500000
+Int: 4
+Int: 9
diff --git a/tests/ffi/should_run/T4012_A.hs b/tests/ffi/should_run/T4012_A.hs
new file mode 100644
index 0000000..f750c6c
--- /dev/null
+++ b/tests/ffi/should_run/T4012_A.hs
@@ -0,0 +1,14 @@
+
+{-# LANGUAGE CApiFFI #-}
+
+module T4012_A where
+
+import Foreign.C
+
+a :: IO ()
+a = do withCString "Double: %f\n" $ \fstr -> printfa1 fstr 1.5
+       withCString "Int: %d\n"    $ \fstr -> printfa2 fstr 4
+
+foreign import capi "stdio.h printf" printfa1 :: CString -> CDouble -> IO ()
+foreign import capi "stdio.h printf" printfa2 :: CString -> CInt -> IO ()
+
diff --git a/tests/ffi/should_run/T4012_B.hs b/tests/ffi/should_run/T4012_B.hs
new file mode 100644
index 0000000..a68c18d
--- /dev/null
+++ b/tests/ffi/should_run/T4012_B.hs
@@ -0,0 +1,11 @@
+
+{-# LANGUAGE CApiFFI #-}
+
+module T4012_B where
+
+import Foreign.C
+
+b :: IO ()
+b = withCString "Int: %d\n" $ \fstr -> printfb fstr 9
+
+foreign import capi "stdio.h printf" printfb :: CString -> CInt -> IO ()
diff --git a/tests/ffi/should_run/all.T b/tests/ffi/should_run/all.T
index b448905..e170db0 100644
--- a/tests/ffi/should_run/all.T
+++ b/tests/ffi/should_run/all.T
@@ -212,3 +212,10 @@ test('capi_value',
      ['capi_value_c.c'])
 
 test('7170', exit_code(1), compile_and_run, [''])
+
+test('T4012',
+     [extra_clean(['T4012_A.hi', 'T4012_A.o', 'T4012_B.hi', 'T4012_B.o']),
+      expect_broken_for(7388, ['ghci'])],
+     multimod_compile_and_run,
+     ['T4012', ''])
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.