Commit aba7b11e authored by ian@well-typed.com's avatar ian@well-typed.com

Add a test for CAPI wrapper functions

parent eb1c829b
module Main (main) where
import T4012_A
import T4012_B
main :: IO ()
main = do a
b
Double: 1.500000
Int: 4
Int: 9
{-# 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 ()
{-# 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 ()
......@@ -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', ''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment