From ddd5ceaca37d60fbb52bb46b0b744e5880d36bf5 Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Fri, 11 Nov 2016 18:25:16 -0600 Subject: [PATCH] Move all compile-only test code to a standalone compile test. --- sketch.cpp | 789 +----------------- test/CMakeLists.txt | 12 + test/compile_const_term.cpp | 75 ++ test/compile_placeholders.cpp | 40 + test/compile_term_plus_expr.cpp | 314 +++++++ test/compile_term_plus_term.cpp | 217 +++++ test/compile_term_plus_x.cpp | 170 ++++ ...compile_term_plus_x_this_ref_overloads.cpp | 170 ++++ test/compile_tests_main.cpp | 3 + 9 files changed, 1002 insertions(+), 788 deletions(-) create mode 100644 test/compile_const_term.cpp create mode 100644 test/compile_placeholders.cpp create mode 100644 test/compile_term_plus_expr.cpp create mode 100644 test/compile_term_plus_term.cpp create mode 100644 test/compile_term_plus_x.cpp create mode 100644 test/compile_term_plus_x_this_ref_overloads.cpp create mode 100644 test/compile_tests_main.cpp diff --git a/sketch.cpp b/sketch.cpp index b61784a..af61bf0 100644 --- a/sketch.cpp +++ b/sketch.cpp @@ -1,4 +1,3 @@ -#define BOOST_PROTO17_CONVERSION_OPERATOR_TEMPLATE #include "expression.hpp" #include @@ -14,7 +13,6 @@ using namespace std::string_literals; void x_plus_term () { -#if 0 // char const * string { term unity{1.0}; @@ -164,795 +162,10 @@ void x_plus_term () term > unevaluated_expr = std::move(i) + unity; } -#endif } -void term_plus_x () -{ - // char const * string - { - term unity{1.0}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + "3"; - } - - // std::string temporary - { - term unity{1.0}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + "3"s; - } - - // arrays - { - term unity{1.0}; - int ints[] = {1, 2}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + ints; - } - - { - term unity{1.0}; - int const ints[] = {1, 2}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + ints; - } - - { - term unity{1.0}; - int ints[] = {1, 2}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(ints); - } - - // pointers - { - term unity{1.0}; - int ints[] = {1, 2}; - int * int_ptr = ints; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + int_ptr; - } - - { - term unity{1.0}; - int const ints[] = {1, 2}; - int const * int_ptr = ints; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + int_ptr; - } - - { - term unity{1.0}; - int ints[] = {1, 2}; - int * int_ptr = ints; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(int_ptr); - } - - // const pointers - { - term unity{1.0}; - int ints[] = {1, 2}; - int * const int_ptr = ints; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + int_ptr; - } - - { - term unity{1.0}; - int const ints[] = {1, 2}; - int const * const int_ptr = ints; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + int_ptr; - } - - { - term unity{1.0}; - int ints[] = {1, 2}; - int * const int_ptr = ints; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(int_ptr); - } - - // values - { - term unity{1.0}; - int i = 1; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term unity{1.0}; - int const i = 1; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term unity{1.0}; - int i = 1; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(i); - } -} - -void term_plus_x_this_ref_overloads() -{ - { - term unity{1.0}; - int i = 1; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term const unity{1.0}; - int i = 1; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term unity{1.0}; - int i = 1; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = std::move(unity) + i; - } -} - -void term_plus_term () -{ - // char const * string - { - term unity{1.0}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + term{"3"}; - } - - // std::string temporary - { - term unity{1.0}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + term{"3"s}; - } - - // pointers - { - term unity{1.0}; - int ints_[] = {1, 2}; - term ints = {ints_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + ints; - } - - { - term unity{1.0}; - int const ints_[] = {1, 2}; - term ints = {ints_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + ints; - } - - { - term unity{1.0}; - int ints_[] = {1, 2}; - term ints = {ints_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(ints); - } - - // const pointers - { - term unity{1.0}; - int ints[] = {1, 2}; - term int_ptr = {ints}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + int_ptr; - } - - { - term unity{1.0}; - int const ints[] = {1, 2}; - term int_ptr = {ints}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + int_ptr; - } - - { - term unity{1.0}; - int ints[] = {1, 2}; - term int_ptr = {ints}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(int_ptr); - } - - // values - { - term unity{1.0}; - term i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term unity{1.0}; - term i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term unity{1.0}; - term i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(i); - } - - // const value terminals - { - term unity{1.0}; - term const i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term unity{1.0}; - term const i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - // lvalue refs - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + i; - } - - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(i); - } - - // rvalue refs - { - term unity{1.0}; - int i_ = 1; - term i{std::move(i_)}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(i); - } - - { - term unity{1.0}; - int i_ = 1; - term i{std::move(i_)}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > unevaluated_expr = unity + std::move(i); - } -} - -void term_plus_expr () -{ - // values - { - term unity{1.0}; - term i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + i; - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + expr; - } - - { - term unity{1.0}; - term i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + i; - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + expr; - } - - { - term unity{1.0}; - term i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + expr; - } - - // const value terminals/expressions - { - term unity{1.0}; - term const i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > const expr = unity + i; - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + expr; - } - - { - term unity{1.0}; - term i = {1}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > const expr = unity + i; - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + expr; - } - - // lvalue refs - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + i; - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + expr; - } - - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + i; - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + expr; - } - - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + expr; - } - - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + i; - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } - - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + i; - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } - - { - term unity{1.0}; - int i_ = 1; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } - - // rvalue refs - { - term unity{1.0}; - int i_ = 1; - term i{std::move(i_)}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } - - { - term unity{1.0}; - int i_ = 1; - term i{std::move(i_)}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } - - { - term unity{1.0}; - int i_ = 1; - term i{std::move(i_)}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } - - { - term unity{1.0}; - int i_ = 1; - term i{std::move(i_)}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } -} - -void placeholders () -{ - using namespace boost::proto17::literals; - - { - bp17::placeholder<0> p0 = 0_p; - } - - { - bp17::placeholder<0> p0 = 0_p; - term unity{1.0}; - bp17::expression< - bp17::expr_kind::plus, - bp17::placeholder<0>, - term - > expr = p0 + unity; - } - - { - bp17::placeholder<0> p0 = 0_p; - bp17::expression< - bp17::expr_kind::plus, - bp17::placeholder<0>, - bp17::placeholder<1> - > expr = p0 + 1_p; - } -} - -void const_term_expr () -{ - { - term unity{1.0}; - int i_ = 42; - term i{std::move(i_)}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } - - { - term const unity{1.0}; - int i_ = 42; - term i{std::move(i_)}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } - - { - term unity{1.0}; - int i_ = 42; - term i{i_}; - bp17::expression< - bp17::expr_kind::plus, - term, - term - > const expr = unity + std::move(i); - bp17::expression< - bp17::expr_kind::plus, - term, - bp17::expression< - bp17::expr_kind::plus, - term, - term - > - > unevaluated_expr = unity + std::move(expr); - } -} int main () { - term_plus_x(); - term_plus_x_this_ref_overloads(); - term_plus_term(); - term_plus_expr(); - placeholders(); - - const_term_expr(); + x_plus_term(); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fae7e08..954ca8e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,3 +25,15 @@ add_test_executable(placeholder_eval) add_test_executable(call_expr) add_test_executable(reference_returns) add_test_executable(depth_stress_test) + +add_executable( + compile_tests + compile_tests_main.cpp + compile_const_term.cpp + compile_placeholders.cpp + compile_term_plus_expr.cpp + compile_term_plus_term.cpp + compile_term_plus_x.cpp + compile_term_plus_x_this_ref_overloads.cpp + compile_const_term.cpp +) diff --git a/test/compile_const_term.cpp b/test/compile_const_term.cpp new file mode 100644 index 0000000..9bc2cda --- /dev/null +++ b/test/compile_const_term.cpp @@ -0,0 +1,75 @@ +#define BOOST_PROTO17_CONVERSION_OPERATOR_TEMPLATE +#include "expression.hpp" + +template +using term = boost::proto17::terminal; + +namespace bp17 = boost::proto17; + + +namespace { + +void compile() +{ + { + term unity{1.0}; + int i_ = 42; + term i{std::move(i_)}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } + + { + term const unity{1.0}; + int i_ = 42; + term i{std::move(i_)}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } + + { + term unity{1.0}; + int i_ = 42; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > const expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } +} + +} diff --git a/test/compile_placeholders.cpp b/test/compile_placeholders.cpp new file mode 100644 index 0000000..afd92d6 --- /dev/null +++ b/test/compile_placeholders.cpp @@ -0,0 +1,40 @@ +#define BOOST_PROTO17_CONVERSION_OPERATOR_TEMPLATE +#include "expression.hpp" + +template +using term = boost::proto17::terminal; + +namespace bp17 = boost::proto17; + + +namespace { + +void compile() +{ + using namespace boost::proto17::literals; + + { + bp17::placeholder<0> p0 = 0_p; + } + + { + bp17::placeholder<0> p0 = 0_p; + term unity{1.0}; + bp17::expression< + bp17::expr_kind::plus, + bp17::placeholder<0>, + term + > expr = p0 + unity; + } + + { + bp17::placeholder<0> p0 = 0_p; + bp17::expression< + bp17::expr_kind::plus, + bp17::placeholder<0>, + bp17::placeholder<1> + > expr = p0 + 1_p; + } +} + +} diff --git a/test/compile_term_plus_expr.cpp b/test/compile_term_plus_expr.cpp new file mode 100644 index 0000000..fa649a9 --- /dev/null +++ b/test/compile_term_plus_expr.cpp @@ -0,0 +1,314 @@ +#define BOOST_PROTO17_CONVERSION_OPERATOR_TEMPLATE +#include "expression.hpp" + +template +using term = boost::proto17::terminal; + +namespace bp17 = boost::proto17; + + +namespace { + +void compile () +{ + // values + { + term unity{1.0}; + term i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + i; + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + expr; + } + + { + term unity{1.0}; + term i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + i; + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + expr; + } + + { + term unity{1.0}; + term i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + expr; + } + + // const value terminals/expressions + { + term unity{1.0}; + term const i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > const expr = unity + i; + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + expr; + } + + { + term unity{1.0}; + term i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > const expr = unity + i; + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + expr; + } + + // lvalue refs + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + i; + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + expr; + } + + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + i; + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + expr; + } + + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + expr; + } + + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + i; + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } + + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + i; + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } + + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } + + // rvalue refs + { + term unity{1.0}; + int i_ = 1; + term i{std::move(i_)}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } + + { + term unity{1.0}; + int i_ = 1; + term i{std::move(i_)}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } + + { + term unity{1.0}; + int i_ = 1; + term i{std::move(i_)}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } + + { + term unity{1.0}; + int i_ = 1; + term i{std::move(i_)}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > expr = unity + std::move(i); + bp17::expression< + bp17::expr_kind::plus, + term, + bp17::expression< + bp17::expr_kind::plus, + term, + term + > + > unevaluated_expr = unity + std::move(expr); + } +} + +} diff --git a/test/compile_term_plus_term.cpp b/test/compile_term_plus_term.cpp new file mode 100644 index 0000000..2fe0646 --- /dev/null +++ b/test/compile_term_plus_term.cpp @@ -0,0 +1,217 @@ +#define BOOST_PROTO17_CONVERSION_OPERATOR_TEMPLATE +#include "expression.hpp" + +#include + + +template +using term = boost::proto17::terminal; + +namespace bp17 = boost::proto17; + + +namespace { + +void compile () +{ + using namespace std::literals; + + // char const * string + { + term unity{1.0}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + term{"3"}; + } + + // std::string temporary + { + term unity{1.0}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + term{"3"s}; + } + + // pointers + { + term unity{1.0}; + int ints_[] = {1, 2}; + term ints = {ints_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + ints; + } + + { + term unity{1.0}; + int const ints_[] = {1, 2}; + term ints = {ints_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + ints; + } + + { + term unity{1.0}; + int ints_[] = {1, 2}; + term ints = {ints_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(ints); + } + + // const pointers + { + term unity{1.0}; + int ints[] = {1, 2}; + term int_ptr = {ints}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int const ints[] = {1, 2}; + term int_ptr = {ints}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int ints[] = {1, 2}; + term int_ptr = {ints}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(int_ptr); + } + + // values + { + term unity{1.0}; + term i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + term i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + term i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(i); + } + + // const value terminals + { + term unity{1.0}; + term const i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + term const i = {1}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + // lvalue refs + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + int i_ = 1; + term i{i_}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(i); + } + + // rvalue refs + { + term unity{1.0}; + int i_ = 1; + term i{std::move(i_)}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(i); + } + + { + term unity{1.0}; + int i_ = 1; + term i{std::move(i_)}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(i); + } +} + +} diff --git a/test/compile_term_plus_x.cpp b/test/compile_term_plus_x.cpp new file mode 100644 index 0000000..556e9d4 --- /dev/null +++ b/test/compile_term_plus_x.cpp @@ -0,0 +1,170 @@ +#define BOOST_PROTO17_CONVERSION_OPERATOR_TEMPLATE +#include "expression.hpp" + +#include + + +template +using term = boost::proto17::terminal; + +namespace bp17 = boost::proto17; + + +namespace { + +void compile () +{ + using namespace std::literals; + + // char const * string + { + term unity{1.0}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + "3"; + } + + // std::string temporary + { + term unity{1.0}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + "3"s; + } + + // arrays + { + term unity{1.0}; + int ints[] = {1, 2}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + ints; + } + + { + term unity{1.0}; + int const ints[] = {1, 2}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + ints; + } + + { + term unity{1.0}; + int ints[] = {1, 2}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(ints); + } + + // pointers + { + term unity{1.0}; + int ints[] = {1, 2}; + int * int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int const ints[] = {1, 2}; + int const * int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int ints[] = {1, 2}; + int * int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(int_ptr); + } + + // const pointers + { + term unity{1.0}; + int ints[] = {1, 2}; + int * const int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int const ints[] = {1, 2}; + int const * const int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int ints[] = {1, 2}; + int * const int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(int_ptr); + } + + // values + { + term unity{1.0}; + int i = 1; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + int const i = 1; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + int i = 1; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(i); + } +} + +} diff --git a/test/compile_term_plus_x_this_ref_overloads.cpp b/test/compile_term_plus_x_this_ref_overloads.cpp new file mode 100644 index 0000000..556e9d4 --- /dev/null +++ b/test/compile_term_plus_x_this_ref_overloads.cpp @@ -0,0 +1,170 @@ +#define BOOST_PROTO17_CONVERSION_OPERATOR_TEMPLATE +#include "expression.hpp" + +#include + + +template +using term = boost::proto17::terminal; + +namespace bp17 = boost::proto17; + + +namespace { + +void compile () +{ + using namespace std::literals; + + // char const * string + { + term unity{1.0}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + "3"; + } + + // std::string temporary + { + term unity{1.0}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + "3"s; + } + + // arrays + { + term unity{1.0}; + int ints[] = {1, 2}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + ints; + } + + { + term unity{1.0}; + int const ints[] = {1, 2}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + ints; + } + + { + term unity{1.0}; + int ints[] = {1, 2}; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(ints); + } + + // pointers + { + term unity{1.0}; + int ints[] = {1, 2}; + int * int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int const ints[] = {1, 2}; + int const * int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int ints[] = {1, 2}; + int * int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(int_ptr); + } + + // const pointers + { + term unity{1.0}; + int ints[] = {1, 2}; + int * const int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int const ints[] = {1, 2}; + int const * const int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + int_ptr; + } + + { + term unity{1.0}; + int ints[] = {1, 2}; + int * const int_ptr = ints; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(int_ptr); + } + + // values + { + term unity{1.0}; + int i = 1; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + int const i = 1; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + i; + } + + { + term unity{1.0}; + int i = 1; + bp17::expression< + bp17::expr_kind::plus, + term, + term + > unevaluated_expr = unity + std::move(i); + } +} + +} diff --git a/test/compile_tests_main.cpp b/test/compile_tests_main.cpp new file mode 100644 index 0000000..bbfe069 --- /dev/null +++ b/test/compile_tests_main.cpp @@ -0,0 +1,3 @@ +int main () +{ +}