Repository : ssh://darcs.haskell.org//srv/darcs/testsuite On branch : master
http://hackage.haskell.org/trac/ghc/changeset/c78e7523f3ff3a832d426d34dc5bf1ba2362c1a3 >--------------------------------------------------------------- commit c78e7523f3ff3a832d426d34dc5bf1ba2362c1a3 Author: Ian Lynagh <[email protected]> Date: Sun Feb 26 00:38:05 2012 +0000 Add a test for CAPI value imports >--------------------------------------------------------------- tests/ffi/should_run/all.T | 5 +++++ tests/ffi/should_run/capi_value.hs | 14 ++++++++++++++ tests/ffi/should_run/capi_value.stdout | 2 ++ tests/ffi/should_run/capi_value_c.c | 4 ++++ tests/ffi/should_run/capi_value_c.h | 3 +++ 5 files changed, 28 insertions(+), 0 deletions(-) diff --git a/tests/ffi/should_run/all.T b/tests/ffi/should_run/all.T index a8c3553..30eba8e 100644 --- a/tests/ffi/should_run/all.T +++ b/tests/ffi/should_run/all.T @@ -206,3 +206,8 @@ test('ffi_parsing_001', compile_and_run, ['ffi_parsing_001_c.c']) +test('capi_value', + extra_clean(['capi_value_c.o']), + compile_and_run, + ['capi_value_c.c']) + diff --git a/tests/ffi/should_run/capi_value.hs b/tests/ffi/should_run/capi_value.hs new file mode 100644 index 0000000..131e97a --- /dev/null +++ b/tests/ffi/should_run/capi_value.hs @@ -0,0 +1,14 @@ + +{-# LANGUAGE CApiFFI #-} + +module Main (main) where + +import Foreign.C + +main :: IO () +main = do print i + print j + +foreign import capi "capi_value_c.h value i" i :: CInt +foreign import capi "capi_value_c.h value j" j :: CInt + diff --git a/tests/ffi/should_run/capi_value.stdout b/tests/ffi/should_run/capi_value.stdout new file mode 100644 index 0000000..e120905 --- /dev/null +++ b/tests/ffi/should_run/capi_value.stdout @@ -0,0 +1,2 @@ +23 +24 diff --git a/tests/ffi/should_run/capi_value_c.c b/tests/ffi/should_run/capi_value_c.c new file mode 100644 index 0000000..45db07c --- /dev/null +++ b/tests/ffi/should_run/capi_value_c.c @@ -0,0 +1,4 @@ + +#include "capi_value_c.h" + +const int i = 23; diff --git a/tests/ffi/should_run/capi_value_c.h b/tests/ffi/should_run/capi_value_c.h new file mode 100644 index 0000000..d8ef814 --- /dev/null +++ b/tests/ffi/should_run/capi_value_c.h @@ -0,0 +1,3 @@ + +const int i; +#define j 24 _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
