summaryrefslogtreecommitdiff
path: root/testsuite/tests/ffi/should_run
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2012-02-26 00:38:05 +0000
committerIan Lynagh <igloo@earth.li>2012-02-26 00:38:05 +0000
commitaedcb2184d9c4195e6c1775456a88e593c42211b (patch)
tree77a3a30b7d5e9e2c2e1d588dc8cc4d9b6cd0ada8 /testsuite/tests/ffi/should_run
parent9a3c87407a9f6296890e8a73c7c0f5e5555698df (diff)
downloadhaskell-aedcb2184d9c4195e6c1775456a88e593c42211b.tar.gz
Add a test for CAPI value imports
Diffstat (limited to 'testsuite/tests/ffi/should_run')
-rw-r--r--testsuite/tests/ffi/should_run/all.T5
-rw-r--r--testsuite/tests/ffi/should_run/capi_value.hs14
-rw-r--r--testsuite/tests/ffi/should_run/capi_value.stdout2
-rw-r--r--testsuite/tests/ffi/should_run/capi_value_c.c4
-rw-r--r--testsuite/tests/ffi/should_run/capi_value_c.h3
5 files changed, 28 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_run/all.T b/testsuite/tests/ffi/should_run/all.T
index a8c3553735..30eba8ee0e 100644
--- a/testsuite/tests/ffi/should_run/all.T
+++ b/testsuite/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/testsuite/tests/ffi/should_run/capi_value.hs b/testsuite/tests/ffi/should_run/capi_value.hs
new file mode 100644
index 0000000000..131e97ae26
--- /dev/null
+++ b/testsuite/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/testsuite/tests/ffi/should_run/capi_value.stdout b/testsuite/tests/ffi/should_run/capi_value.stdout
new file mode 100644
index 0000000000..e120905029
--- /dev/null
+++ b/testsuite/tests/ffi/should_run/capi_value.stdout
@@ -0,0 +1,2 @@
+23
+24
diff --git a/testsuite/tests/ffi/should_run/capi_value_c.c b/testsuite/tests/ffi/should_run/capi_value_c.c
new file mode 100644
index 0000000000..45db07c6a0
--- /dev/null
+++ b/testsuite/tests/ffi/should_run/capi_value_c.c
@@ -0,0 +1,4 @@
+
+#include "capi_value_c.h"
+
+const int i = 23;
diff --git a/testsuite/tests/ffi/should_run/capi_value_c.h b/testsuite/tests/ffi/should_run/capi_value_c.h
new file mode 100644
index 0000000000..d8ef814216
--- /dev/null
+++ b/testsuite/tests/ffi/should_run/capi_value_c.h
@@ -0,0 +1,3 @@
+
+const int i;
+#define j 24