summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/yap/test/default_eval.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/yap/test/default_eval.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/yap/test/default_eval.cpp')
-rw-r--r--src/boost/libs/yap/test/default_eval.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/boost/libs/yap/test/default_eval.cpp b/src/boost/libs/yap/test/default_eval.cpp
new file mode 100644
index 000000000..27087f953
--- /dev/null
+++ b/src/boost/libs/yap/test/default_eval.cpp
@@ -0,0 +1,103 @@
+// Copyright (C) 2016-2018 T. Zachary Laine
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+#include <boost/yap/expression.hpp>
+
+#include <boost/test/minimal.hpp>
+
+
+template<typename T>
+using term = boost::yap::terminal<boost::yap::expression, T>;
+
+template<typename T>
+using ref = boost::yap::expression_ref<boost::yap::expression, T>;
+
+namespace yap = boost::yap;
+namespace bh = boost::hana;
+
+
+int test_main(int, char * [])
+{
+ {
+ term<double> unity{1.0};
+ int i_ = 42;
+ term<int &&> i{std::move(i_)};
+ yap::expression<
+ yap::expr_kind::minus,
+ bh::tuple<ref<term<double> &>, term<int &&>>>
+ expr = unity - std::move(i);
+ yap::expression<
+ yap::expr_kind::plus,
+ bh::tuple<
+ ref<term<double> &>,
+ yap::expression<
+ yap::expr_kind::minus,
+ bh::tuple<ref<term<double> &>, term<int &&>>>>>
+ unevaluated_expr_1 = unity + std::move(expr);
+
+ yap::expression<
+ yap::expr_kind::plus,
+ bh::tuple<ref<term<double> &>, ref<term<double> &>>>
+ unevaluated_expr_2 = unity + unity;
+
+ term<double> const const_unity{1.0};
+ yap::expression<
+ yap::expr_kind::plus,
+ bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
+ unevaluated_expr_3 = unity + const_unity;
+
+ {
+ double result = evaluate(unity);
+ BOOST_CHECK(result == 1);
+ }
+
+ {
+ double result = evaluate(expr);
+ BOOST_CHECK(result == -41);
+ }
+
+ {
+ double result = evaluate(unevaluated_expr_1);
+ BOOST_CHECK(result == -40);
+ }
+
+ {
+ double result = evaluate(unevaluated_expr_2);
+ BOOST_CHECK(result == 2);
+ }
+
+ {
+ double result = evaluate(unevaluated_expr_3);
+ BOOST_CHECK(result == 2);
+ }
+
+ {
+ double result = evaluate(unity, 5, 6, 7);
+ BOOST_CHECK(result == 1);
+ }
+
+ {
+ double result = evaluate(expr);
+ BOOST_CHECK(result == -41);
+ }
+
+ {
+ double result = evaluate(unevaluated_expr_1, std::string("15"));
+ BOOST_CHECK(result == -40);
+ }
+
+ {
+ double result = evaluate(unevaluated_expr_2, std::string("15"));
+ BOOST_CHECK(result == 2);
+ }
+
+ {
+ double result = evaluate(unevaluated_expr_3, std::string("15"));
+ BOOST_CHECK(result == 2);
+ }
+ }
+
+ return 0;
+}