From 680d318352d0c740992a7e1d6ee5bac766487bbf Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 9 Sep 2015 11:38:25 +0200 Subject: Add unit tests for bug #981: valid and invalid usage of ternary operator --- failtest/CMakeLists.txt | 3 +++ failtest/ternary_1.cpp | 13 +++++++++++++ failtest/ternary_2.cpp | 13 +++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 failtest/ternary_1.cpp create mode 100644 failtest/ternary_2.cpp (limited to 'failtest') diff --git a/failtest/CMakeLists.txt b/failtest/CMakeLists.txt index 8df0a7631..1a73f05e6 100644 --- a/failtest/CMakeLists.txt +++ b/failtest/CMakeLists.txt @@ -41,6 +41,9 @@ ei_add_failtest("ref_5") ei_add_failtest("swap_1") ei_add_failtest("swap_2") +ei_add_failtest("ternary_1") +ei_add_failtest("ternary_2") + ei_add_failtest("sparse_ref_1") ei_add_failtest("sparse_ref_2") ei_add_failtest("sparse_ref_3") diff --git a/failtest/ternary_1.cpp b/failtest/ternary_1.cpp new file mode 100644 index 000000000..b40bcb0cc --- /dev/null +++ b/failtest/ternary_1.cpp @@ -0,0 +1,13 @@ +#include "../Eigen/Core" + +using namespace Eigen; + +int main(int argc,char **) +{ + VectorXf a(10), b(10); +#ifdef EIGEN_SHOULD_FAIL_TO_BUILD + b = argc>1 ? 2*a : -a; +#else + b = argc>1 ? 2*a : VectorXf(-a); +#endif +} diff --git a/failtest/ternary_2.cpp b/failtest/ternary_2.cpp new file mode 100644 index 000000000..a46b12b2b --- /dev/null +++ b/failtest/ternary_2.cpp @@ -0,0 +1,13 @@ +#include "../Eigen/Core" + +using namespace Eigen; + +int main(int argc,char **) +{ + VectorXf a(10), b(10); +#ifdef EIGEN_SHOULD_FAIL_TO_BUILD + b = argc>1 ? 2*a : a+a; +#else + b = argc>1 ? VectorXf(2*a) : VectorXf(a+a); +#endif +} -- cgit v1.2.3