mirror of https://github.com/swig/swig
Run C++14 and C++17 tests with appropriate compiler
Previously these testcases had C++98 fallback versions of the testcase code to feed to the compiler if it didn't set __cplusplus to a value which indicated support for the required C++ version, as well as the C++14 or C++17 code which was fed to SWIG, and also to the compiler if it was new enough. This approach allowed some testing of such features with an older compiler, but it complicates the testcases and not all new C++ features can be tested in this way (indeed some of the existing testcases don't fully exercise the feature being tested currently). C++14 and C++17 support are also much more widespread than they were 3.5 years ago when this approach was first implemented, so it makes more sense to switch C++14 and C++17 testcases to require a suitable compiler, like how C++11 testing always has.
This commit is contained in:
parent
07f0b732ba
commit
3140acd748
|
@ -168,11 +168,6 @@ CPP_TEST_CASES += \
|
|||
cpp_parameters \
|
||||
cpp_static \
|
||||
cpp_typedef \
|
||||
cpp14_binary_integer_literals \
|
||||
cpp17_hex_floating_literals \
|
||||
cpp17_nested_namespaces \
|
||||
cpp17_nspace_nested_namespaces \
|
||||
cpp17_u8_char_literals \
|
||||
curiously_recurring_template_pattern \
|
||||
default_args \
|
||||
default_arg_expressions \
|
||||
|
@ -637,12 +632,17 @@ CPP11_TEST_BROKEN = \
|
|||
|
||||
# C++14 test cases.
|
||||
CPP14_TEST_CASES += \
|
||||
cpp14_binary_integer_literals \
|
||||
|
||||
# Broken C++14 test cases.
|
||||
CPP14_TEST_BROKEN = \
|
||||
|
||||
# C++17 test cases.
|
||||
CPP17_TEST_CASES += \
|
||||
cpp17_hex_floating_literals \
|
||||
cpp17_nested_namespaces \
|
||||
cpp17_nspace_nested_namespaces \
|
||||
cpp17_u8_char_literals \
|
||||
|
||||
# Broken C++17 test cases.
|
||||
CPP17_TEST_BROKEN = \
|
||||
|
|
|
@ -1,31 +1,9 @@
|
|||
%module cpp14_binary_integer_literals
|
||||
|
||||
// Tests are designed so that code compiles with C++98 compilers
|
||||
|
||||
%{
|
||||
#if __cplusplus >= 201402L
|
||||
#define CPP14 1
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
int b1 = 0b1;
|
||||
int b2 = 0b10;
|
||||
long b3 = 0b11l;
|
||||
unsigned long b4 = 0b100ul;
|
||||
unsigned long b5 = 0B101UL;
|
||||
|
||||
%{
|
||||
#if defined(CPP14)
|
||||
int b1 = 0b1;
|
||||
int b2 = 0b10;
|
||||
long b3 = 0b11l;
|
||||
unsigned long b4 = 0b100ul;
|
||||
unsigned long b5 = 0B101UL;
|
||||
#else
|
||||
int b1 = 1;
|
||||
int b2 = 2;
|
||||
long b3 = 3;
|
||||
unsigned long b4 = 4;
|
||||
unsigned long b5 = 5;
|
||||
#endif
|
||||
%}
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
%module cpp17_hex_floating_literals
|
||||
|
||||
// Tests are designed so that code compiles with C++98 compilers
|
||||
|
||||
%{
|
||||
#if __cplusplus >= 201703L
|
||||
#define CPP17 1
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
double f1 = 0x.0p1;
|
||||
double f2 = 0x0.p1;
|
||||
double f3 = 0x0.0p-1;
|
||||
|
@ -17,27 +10,4 @@ double f6 = 0x0.10P+10;
|
|||
double f7 = 0xb2F.p2;
|
||||
float f8 = 0x1234AP1F;
|
||||
float f9 = 0x45A1.D1A2p+10f;
|
||||
|
||||
%{
|
||||
#if defined(CPP17)
|
||||
double f1 = 0x.0p1;
|
||||
double f2 = 0x0.p1;
|
||||
double f3 = 0x0.0p-1;
|
||||
double f4 = 0xf.p-1;
|
||||
double f5 = 0xA.0p1;
|
||||
double f6 = 0x0.10P+10;
|
||||
double f7 = 0xb2F.p2;
|
||||
float f8 = 0x1234AP1F;
|
||||
float f9 = 0x45A1.D1A2p+10f;
|
||||
#else
|
||||
double f1 = 0.;
|
||||
double f2 = 0.;
|
||||
double f3 = 0.;
|
||||
double f4 = 7.5;
|
||||
double f5 = 20.;
|
||||
double f6 = 64.;
|
||||
double f7 = 11452.;
|
||||
float f8 = 149140.f;
|
||||
float f9 = 18253638.f;
|
||||
#endif
|
||||
%}
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
%module cpp17_nested_namespaces
|
||||
// Tests c++17 style nested namespaces
|
||||
// Tests are designed so that code compiles with C++98 compilers
|
||||
|
||||
#define CPP17 1
|
||||
%{
|
||||
#if __cplusplus >= 201703L
|
||||
#define CPP17 1
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
// Tests with namespaces already defined using C++98 style (non-nested) namespaces
|
||||
|
@ -21,20 +13,10 @@ namespace A1 {
|
|||
};
|
||||
}
|
||||
}
|
||||
#if defined(CPP17)
|
||||
namespace A1::B1 {
|
||||
#else
|
||||
namespace A1 {
|
||||
namespace B1 {
|
||||
#endif
|
||||
A1Struct createA1Struct() { return ::A1::A1Struct(); }
|
||||
B1Struct createB1Struct() { return ::A1::B1::B1Struct(); }
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace A1 {
|
||||
namespace B1 {
|
||||
|
@ -46,154 +28,54 @@ namespace A1 {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(CPP17)
|
||||
namespace A1::B1::C1 {
|
||||
#else
|
||||
namespace A1 {
|
||||
namespace B1 {
|
||||
namespace C1 {
|
||||
#endif
|
||||
C1Struct createC1Struct() { return ::A1::B1::C1::C1Struct(); }
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
// Tests with namespaces already defined using C++17 style (nested) namespaces
|
||||
#if defined(CPP17)
|
||||
namespace A2::B2 {
|
||||
#else
|
||||
namespace A2 {
|
||||
namespace B2 {
|
||||
#endif
|
||||
struct B2Struct {
|
||||
void B2Method() {}
|
||||
};
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPP17)
|
||||
namespace A2::B2 {
|
||||
#else
|
||||
namespace A2 {
|
||||
namespace B2 {
|
||||
#endif
|
||||
B2Struct createB2Struct() { return ::A2::B2::B2Struct(); }
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPP17)
|
||||
namespace A2::B2::C2 {
|
||||
#else
|
||||
namespace A2 {
|
||||
namespace B2 {
|
||||
namespace C2 {
|
||||
#endif
|
||||
struct C2Struct {
|
||||
void C2Method() {}
|
||||
};
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPP17)
|
||||
namespace A2::B2::C2 {
|
||||
#else
|
||||
namespace A2 {
|
||||
namespace B2 {
|
||||
namespace C2 {
|
||||
#endif
|
||||
C2Struct createC2Struct() { return ::A2::B2::C2::C2Struct(); }
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
||||
%inline %{
|
||||
// Tests with namespaces already defined using C++17 style (nested) namespaces to 3 levels
|
||||
#if defined(CPP17)
|
||||
namespace A3::B3::C3 {
|
||||
#else
|
||||
namespace A3 {
|
||||
namespace B3 {
|
||||
namespace C3 {
|
||||
#endif
|
||||
struct C3Struct {
|
||||
void C3Method() {}
|
||||
};
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPP17)
|
||||
namespace A3::B3::C3 {
|
||||
#else
|
||||
namespace A3 {
|
||||
namespace B3 {
|
||||
namespace C3 {
|
||||
#endif
|
||||
C3Struct createC3Struct() { return ::A3::B3::C3::C3Struct(); }
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPP17)
|
||||
namespace A3::B3 {
|
||||
#else
|
||||
namespace A3 {
|
||||
namespace B3 {
|
||||
#endif
|
||||
struct B3Struct {
|
||||
void B3Method() {}
|
||||
};
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPP17)
|
||||
namespace A3::B3 {
|
||||
#else
|
||||
namespace A3 {
|
||||
namespace B3 {
|
||||
#endif
|
||||
B3Struct createB3Struct() { return ::A3::B3::B3Struct(); }
|
||||
#if !defined(CPP17)
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
%}
|
||||
|
|
|
@ -1,27 +1,9 @@
|
|||
%module cpp17_u8_char_literals
|
||||
|
||||
// Tests are designed so that code compiles with C++98 compilers
|
||||
|
||||
%{
|
||||
#if __cplusplus >= 201703L
|
||||
#define CPP17 1
|
||||
#endif
|
||||
%}
|
||||
|
||||
// UTF-8 character literals are type `char` in C++17 but `char8_t` in C++20,
|
||||
// but the latter can be assigned to `char`.
|
||||
%inline %{
|
||||
char a = u8'a';
|
||||
char u = u8'u';
|
||||
char u8 = u8'8';
|
||||
|
||||
%{
|
||||
#if defined(CPP17)
|
||||
char a = u8'a';
|
||||
char u = u8'u';
|
||||
char u8 = u8'8';
|
||||
#else
|
||||
char a = 'a';
|
||||
char u = 'u';
|
||||
char u8 = '8';
|
||||
#endif
|
||||
%}
|
||||
|
|
Loading…
Reference in New Issue