diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-11-02 12:20:09 +0000 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-11-02 12:20:09 +0000 |
commit | aba7b11e98ae3d1de66cabd9cd90ee6c2268e45a (patch) | |
tree | e6f8e1fe2613068b12a6ea918c6e6c5bb8c491db /testsuite/tests/ffi | |
parent | eb1c829b6006b02b42705787114aa905046b7743 (diff) | |
download | haskell-aba7b11e98ae3d1de66cabd9cd90ee6c2268e45a.tar.gz |
Add a test for CAPI wrapper functions
Diffstat (limited to 'testsuite/tests/ffi')
-rw-r--r-- | testsuite/tests/ffi/should_run/T4012.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/ffi/should_run/T4012.stdout | 3 | ||||
-rw-r--r-- | testsuite/tests/ffi/should_run/T4012_A.hs | 14 | ||||
-rw-r--r-- | testsuite/tests/ffi/should_run/T4012_B.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/ffi/should_run/all.T | 7 |
5 files changed, 45 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_run/T4012.hs b/testsuite/tests/ffi/should_run/T4012.hs new file mode 100644 index 0000000000..d22b3c354b --- /dev/null +++ b/testsuite/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/testsuite/tests/ffi/should_run/T4012.stdout b/testsuite/tests/ffi/should_run/T4012.stdout new file mode 100644 index 0000000000..f54f2349ba --- /dev/null +++ b/testsuite/tests/ffi/should_run/T4012.stdout @@ -0,0 +1,3 @@ +Double: 1.500000 +Int: 4 +Int: 9 diff --git a/testsuite/tests/ffi/should_run/T4012_A.hs b/testsuite/tests/ffi/should_run/T4012_A.hs new file mode 100644 index 0000000000..f750c6c4bb --- /dev/null +++ b/testsuite/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/testsuite/tests/ffi/should_run/T4012_B.hs b/testsuite/tests/ffi/should_run/T4012_B.hs new file mode 100644 index 0000000000..a68c18d635 --- /dev/null +++ b/testsuite/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/testsuite/tests/ffi/should_run/all.T b/testsuite/tests/ffi/should_run/all.T index b448905f68..e170db0dba 100644 --- a/testsuite/tests/ffi/should_run/all.T +++ b/testsuite/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', '']) + |