aboutsummaryrefslogtreecommitdiff
path: root/tests/cc/preprocessed/testscript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cc/preprocessed/testscript')
-rw-r--r--tests/cc/preprocessed/testscript125
1 files changed, 125 insertions, 0 deletions
diff --git a/tests/cc/preprocessed/testscript b/tests/cc/preprocessed/testscript
new file mode 100644
index 0000000..cbc179e
--- /dev/null
+++ b/tests/cc/preprocessed/testscript
@@ -0,0 +1,125 @@
+# file : tests/cc/preprocessed/testscript
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+crosstest = false
+test.arguments = config.cxx="$recall($cxx.path)" update clean #@@ TMP clean
+
+.include ../../common.test
+
+# Trace filter.
+#
+# trace: cxx::compile::extract_(header|modules): target: .../obje{(test).o...}
+#
+filter = sed -n -e \
+ \''s/^trace: cxx::compile::extract_([^:]+): target:[^{]+\{([^.]+).*/\1 \2/p'\'
+
++cat <<EOI >=build/root.build
+cxx.std = latest
+
+using cxx
+
+hxx{*}: extension = hxx
+cxx{*}: extension = cxx
+
+cxx.poptions =+ "-I$src_root"
+EOI
+
+: none
+:
+: Include a header (makes sure headers are handled) which defines the
+: TEST_VALUE macro. Import a non-existent module unless this macro is
+: defined (makes sure modules are extracted from preprocessed source).
+: Use the macro (makes sure compilation happens on preprocessed source).
+:
+cat <<EOI >=test.hxx;
+ #define TEST_VALUE 0
+ EOI
+cat <<EOI >=test.cxx;
+ #include <none/test.hxx>
+
+ #ifndef TEST_VALUE
+ import foo;
+ #endif
+
+ int main () {return TEST_VALUE;}
+ EOI
+$* --verbose 5 <<EOI 2>&1 | $filter >>EOO #@@ &test*
+ exe{test}: cxx{test}
+ EOI
+ headers test
+ modules test
+ EOO
+
+: includes
+:
+cat <<EOI >=test.cxx;
+ #ifndef TEST_VALUE
+ import foo;
+ #endif
+
+ int main () {return TEST_VALUE;}
+ EOI
+$* --verbose 5 <<EOI 2>&1 | $filter >>EOO #@@ &test*
+ cc.preprocessed = includes
+ cc.poptions += -DTEST_VALUE=0
+ exe{test}: cxx{test}
+ EOI
+ modules test
+ EOO
+
+: modules
+:
+: Define and use macro to test that compilation inclused the preprocessor.
+:
+cat <<EOI >=test.cxx;
+ int main () {return TEST_VALUE;}
+ EOI
+$* --verbose 5 <<EOI 2>&1 | $filter >>EOO #@@ &test*
+ cc.preprocessed = modules
+ cc.poptions += -DTEST_VALUE=0
+ exe{test}: cxx{test}
+ EOI
+ modules test
+ EOO
+
+: modules-extract
+:
+: Define macro that would have disabled the module import (makes sure
+: modules are extracted directly from source).
+:
+cat <<EOI >=test.cxx;
+ #define TEST_VALUE
+ #ifndef TEST_VALUE
+ import foo;
+ #endif
+ EOI
+$* <<EOI 2>>EOE != 0 ;#@@ &test*
+ cc.preprocessed = modules
+ exe{test}: cxx{test}
+ EOI
+ error: module support not yet implemented
+ EOE
+rm -f test.o.d test.exe.obj.d #@@ TMP
+
+: all
+:
+: Test handling of comments and line continuations. Define macro on the
+: command line that would have affected the result.
+:
+cat <<EOI >=test.cxx;
+ // C++ comment
+ /*
+ C comment
+ */
+
+ int ma\
+ in () {}
+ EOI
+$* --verbose 5 <<EOI 2>&1 | $filter >>EOO #@@ &test*
+ cc.preprocessed = all
+ cc.poptions += -Dmain=foo
+ exe{test}: cxx{test}
+ EOI
+ modules test
+ EOO