Update preproc_constants* testcases
The changes for supporting more type deduction included a change to
stop treating `long double` and `float` literals as having type
`double`. This requires updates the preproc_constants_c and
preproc_constants testcases which had a baked in assumption that
float literals were treated as double literals.
diff --git a/CHANGES.current b/CHANGES.current
index c770089..48680b0 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -8,6 +8,15 @@
===========================
2023-05-25: olly
+ SWIG now discriminates between long double, double and float
+ constants. For example, this means that for target languages which
+ support a separate float type (such as C# and D) this will now
+ create a float constant instead of a double constant in the target
+ language:
+
+ #define PI_ISH 3.1414f
+
+2023-05-25: olly
C++11 `auto` variables and `decltype()` can now deduce the
type of some expressions which involve literals of built-in types.
Currently int is not supported due to the parser misusing T_INT
diff --git a/Examples/test-suite/csharp/preproc_constants_c_runme.cs b/Examples/test-suite/csharp/preproc_constants_c_runme.cs
index 8cdb705..3bc9e68 100644
--- a/Examples/test-suite/csharp/preproc_constants_c_runme.cs
+++ b/Examples/test-suite/csharp/preproc_constants_c_runme.cs
@@ -27,8 +27,8 @@
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE2.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE3.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE4.GetType() );
- assert( typeof(double) == preproc_constants_c.CONST_DOUBLE5.GetType() );
- assert( typeof(double) == preproc_constants_c.CONST_DOUBLE6.GetType() );
+ assert( typeof(float) == preproc_constants_c.CONST_FLOAT1.GetType() );
+ assert( typeof(float) == preproc_constants_c.CONST_FLOAT2.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_BOOL1.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_BOOL2.GetType() );
assert( typeof(char) == preproc_constants_c.CONST_CHAR.GetType() );
diff --git a/Examples/test-suite/csharp/preproc_constants_runme.cs b/Examples/test-suite/csharp/preproc_constants_runme.cs
index d79e2c3..050bcff 100644
--- a/Examples/test-suite/csharp/preproc_constants_runme.cs
+++ b/Examples/test-suite/csharp/preproc_constants_runme.cs
@@ -26,8 +26,8 @@
assert( typeof(double) == preproc_constants.CONST_DOUBLE2.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE3.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE4.GetType() );
- assert( typeof(double) == preproc_constants.CONST_DOUBLE5.GetType() );
- assert( typeof(double) == preproc_constants.CONST_DOUBLE6.GetType() );
+ assert( typeof(float) == preproc_constants.CONST_FLOAT1.GetType() );
+ assert( typeof(float) == preproc_constants.CONST_FLOAT2.GetType() );
assert( typeof(bool) == preproc_constants.CONST_BOOL1.GetType() );
assert( typeof(bool) == preproc_constants.CONST_BOOL2.GetType() );
assert( typeof(char) == preproc_constants.CONST_CHAR.GetType() );
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.2.d b/Examples/test-suite/d/preproc_constants_c_runme.2.d
index caf3029..136a897 100644
--- a/Examples/test-suite/d/preproc_constants_c_runme.2.d
+++ b/Examples/test-suite/d/preproc_constants_c_runme.2.d
@@ -27,8 +27,8 @@
static assert(is(double == typeof(CONST_DOUBLE2())));
static assert(is(double == typeof(CONST_DOUBLE3())));
static assert(is(double == typeof(CONST_DOUBLE4())));
- static assert(is(double == typeof(CONST_DOUBLE5())));
- static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(float == typeof(CONST_FLOAT1())));
+ static assert(is(float == typeof(CONST_FLOAT2())));
static assert(is(int == typeof(CONST_BOOL1())));
static assert(is(int == typeof(CONST_BOOL2())));
static assert(is(char == typeof(CONST_CHAR())));
diff --git a/Examples/test-suite/d/preproc_constants_runme.2.d b/Examples/test-suite/d/preproc_constants_runme.2.d
index 416384a..b4ccef2 100644
--- a/Examples/test-suite/d/preproc_constants_runme.2.d
+++ b/Examples/test-suite/d/preproc_constants_runme.2.d
@@ -26,8 +26,8 @@
static assert(is(double == typeof(CONST_DOUBLE2())));
static assert(is(double == typeof(CONST_DOUBLE3())));
static assert(is(double == typeof(CONST_DOUBLE4())));
- static assert(is(double == typeof(CONST_DOUBLE5())));
- static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(float == typeof(CONST_FLOAT1())));
+ static assert(is(float == typeof(CONST_FLOAT2())));
static assert(is(bool == typeof(CONST_BOOL1())));
static assert(is(bool == typeof(CONST_BOOL2())));
static assert(is(char == typeof(CONST_CHAR())));
diff --git a/Examples/test-suite/php/preproc_constants_c_runme.php b/Examples/test-suite/php/preproc_constants_c_runme.php
index 688da52..47a2fc3 100644
--- a/Examples/test-suite/php/preproc_constants_c_runme.php
+++ b/Examples/test-suite/php/preproc_constants_c_runme.php
@@ -26,8 +26,10 @@
check::equal(gettype(preproc_constants_c::CONST_DOUBLE2), "double", "preproc_constants.CONST_DOUBLE2 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_DOUBLE3), "double", "preproc_constants.CONST_DOUBLE3 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_DOUBLE4), "double", "preproc_constants.CONST_DOUBLE4 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_DOUBLE5), "double", "preproc_constants.CONST_DOUBLE5 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_DOUBLE6), "double", "preproc_constants.CONST_DOUBLE6 has unexpected type");
+# C/C++ `float` constants are wrapped as PHP `double` as PHP doesn't have a
+# `float` type.
+check::equal(gettype(preproc_constants_c::CONST_FLOAT1), "double", "preproc_constants.CONST_FLOAT1 has unexpected type");
+check::equal(gettype(preproc_constants_c::CONST_FLOAT2), "double", "preproc_constants.CONST_FLOAT2 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_BOOL1), "integer", "preproc_constants.CONST_BOOL1 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_BOOL2), "integer", "preproc_constants.CONST_BOOL2 has unexpected type");
check::equal(gettype(preproc_constants_c::CONST_CHAR), "string", "preproc_constants.CONST_CHAR has unexpected type");
diff --git a/Examples/test-suite/php/preproc_constants_runme.php b/Examples/test-suite/php/preproc_constants_runme.php
index 80f1a9a..38a038f 100644
--- a/Examples/test-suite/php/preproc_constants_runme.php
+++ b/Examples/test-suite/php/preproc_constants_runme.php
@@ -25,8 +25,10 @@
check::equal(gettype(preproc_constants::CONST_DOUBLE2), "double", "preproc_constants.CONST_DOUBLE2 has unexpected type");
check::equal(gettype(preproc_constants::CONST_DOUBLE3), "double", "preproc_constants.CONST_DOUBLE3 has unexpected type");
check::equal(gettype(preproc_constants::CONST_DOUBLE4), "double", "preproc_constants.CONST_DOUBLE4 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_DOUBLE5), "double", "preproc_constants.CONST_DOUBLE5 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_DOUBLE6), "double", "preproc_constants.CONST_DOUBLE6 has unexpected type");
+# C/C++ `float` constants are wrapped as PHP `double` as PHP doesn't have a
+# `float` type.
+check::equal(gettype(preproc_constants::CONST_FLOAT1), "double", "preproc_constants.CONST_FLOAT1 has unexpected type");
+check::equal(gettype(preproc_constants::CONST_FLOAT2), "double", "preproc_constants.CONST_FLOAT2 has unexpected type");
check::equal(gettype(preproc_constants::CONST_BOOL1), "boolean", "preproc_constants.CONST_BOOL1 has unexpected type");
check::equal(gettype(preproc_constants::CONST_BOOL2), "boolean", "preproc_constants.CONST_BOOL2 has unexpected type");
check::equal(gettype(preproc_constants::CONST_CHAR), "string", "preproc_constants.CONST_CHAR has unexpected type");
diff --git a/Examples/test-suite/preproc_constants.i b/Examples/test-suite/preproc_constants.i
index 3873d26..2a20c64 100644
--- a/Examples/test-suite/preproc_constants.i
+++ b/Examples/test-suite/preproc_constants.i
@@ -37,8 +37,9 @@
#define CONST_DOUBLE2 10E1
#define CONST_DOUBLE3 12.3
#define CONST_DOUBLE4 12.
-#define CONST_DOUBLE5 12.3f
-#define CONST_DOUBLE6 12.3F
+
+#define CONST_FLOAT1 12.3f
+#define CONST_FLOAT2 12.3F
#define CONST_BOOL1 true
#define CONST_BOOL2 false