aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/constant_expr.i
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/constant_expr.i')
-rw-r--r--Examples/test-suite/constant_expr.i36
1 files changed, 31 insertions, 5 deletions
diff --git a/Examples/test-suite/constant_expr.i b/Examples/test-suite/constant_expr.i
index 8e5c8aee6..a5ba5c6dd 100644
--- a/Examples/test-suite/constant_expr.i
+++ b/Examples/test-suite/constant_expr.i
@@ -1,11 +1,37 @@
%module constant_expr;
-/* Tests of constant expressions. */
+/* Tests of constant expressions (C++ version). */
+
+%include "constant_expr_c.i"
%inline %{
-/* % didn't work in SWIG 1.3.40 and earlier. */
-const int X = 123%7;
-#define FOO 12 % 9
-double d_array[12 % 9];
+// Testcase from https://sourceforge.net/p/swig/bugs/1139/
+template<typename Tp>
+struct SizeInfo {
+enum {
+isLarge = (sizeof(Tp)>sizeof(void*)),
+isPointer = false
+};
+};
+
+/* Regression test for #300, fixed in 4.1.0.
+ *
+ * Now `a%b` without a space after the `%` is handled as a modulus operator,
+ * but it gave a cryptic `Syntax error in input(1)` before SWIG 3.0.4, and from
+ * SWIG 3.0.4 until 4.1.0, `Unknown directive '%a'`.
+ */
+int a;
+int test2(int b = 9%a) { return b; }
+
+/* Example from manual, adapted to avoid C++11 requirement. */
+namespace fakestd {
+ template<typename T, unsigned N>
+ class array {
+ T a[N];
+ public:
+ array() {}
+ };
+}
+void bar(fakestd::array<int, (1<2? 100 : 50)> *x) { }
%}