Add a test for CAPI value imports
authorIan Lynagh <igloo@earth.li>
Sun, 26 Feb 2012 00:38:05 +0000 (00:38 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 26 Feb 2012 00:38:05 +0000 (00:38 +0000)
testsuite/tests/ffi/should_run/all.T
testsuite/tests/ffi/should_run/capi_value.hs [new file with mode: 0644]
testsuite/tests/ffi/should_run/capi_value.stdout [new file with mode: 0644]
testsuite/tests/ffi/should_run/capi_value_c.c [new file with mode: 0644]
testsuite/tests/ffi/should_run/capi_value_c.h [new file with mode: 0644]

index a8c3553..30eba8e 100644 (file)
@@ -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 (file)
index 0000000..131e97a
--- /dev/null
@@ -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 (file)
index 0000000..e120905
--- /dev/null
@@ -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 (file)
index 0000000..45db07c
--- /dev/null
@@ -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 (file)
index 0000000..d8ef814
--- /dev/null
@@ -0,0 +1,3 @@
+
+const int i;
+#define j 24