diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/phoenix/test/regression | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/phoenix/test/regression')
-rw-r--r-- | src/boost/libs/phoenix/test/regression/actor_assignment.cpp | 29 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug4853.cpp | 79 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug5626.cpp | 26 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug5824.cpp | 25 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug5875.cpp | 23 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug5968.cpp | 27 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug6040.cpp | 22 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug6268.cpp | 29 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug7165.cpp | 15 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug7166.cpp | 16 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/bug7624.cpp | 31 | ||||
-rw-r--r-- | src/boost/libs/phoenix/test/regression/from_array.cpp | 60 |
12 files changed, 382 insertions, 0 deletions
diff --git a/src/boost/libs/phoenix/test/regression/actor_assignment.cpp b/src/boost/libs/phoenix/test/regression/actor_assignment.cpp new file mode 100644 index 00000000..9c0259c0 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/actor_assignment.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2018 Nikita Kniazev + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix.hpp> +#include <boost/function.hpp> +#include <string> + +// Checks that rhs Phoenix actor is taken by value on assignment. +// The wrapper function is used to ensure that created temporaries are +// out of scope (as they will be created on the other stack frame). + +boost::function<void()> make_assignment_test(std::string & s) +{ + return boost::phoenix::ref(s) = "asd"; +} + +int main() +{ + std::string s; + make_assignment_test(s)(); + BOOST_TEST(s == "asd"); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/bug4853.cpp b/src/boost/libs/phoenix/test/regression/bug4853.cpp new file mode 100644 index 00000000..09a875b1 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug4853.cpp @@ -0,0 +1,79 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + Copyright (c) 2015 John Fletcher + + 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 <utility> // for std::forward used by boost/range in some cases. +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/range.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/make_shared.hpp> +#include <boost/range/adaptor/transformed.hpp> +#include <boost/range/adaptor/uniqued.hpp> +#include <boost/range/algorithm_ext/push_back.hpp> + +#include <vector> +#include <string> +#include <iostream> + + +namespace phoenix = boost::phoenix; + +struct Foo { + Foo(const std::string& name, int value) + : name_(name) + , value_(value) + { } + + std::string name_; int value_; +}; + +typedef boost::shared_ptr<Foo> FooPtr; + +int range_test_complex() { + typedef std::vector<FooPtr> V; + + V source; + + source.push_back(boost::make_shared<Foo>("Foo", 10)); + source.push_back(boost::make_shared<Foo>("Bar", 20)); + source.push_back(boost::make_shared<Foo>("Baz", 30)); + source.push_back(boost::make_shared<Foo>("Baz", 30)); //duplicate is here + + std::vector<std::string> result1; + std::vector<int> result2; + + using namespace boost::adaptors; + using phoenix::arg_names::arg1; + + // This is failing for gcc 4.4 and 4.5 - reason not identified. +#if ((BOOST_GCC_VERSION < 40400) || (BOOST_GCC_VERSION >= 40600)) + boost::push_back(result1, source | transformed(phoenix::bind(&Foo::name_, *arg1)) | uniqued); + + for(unsigned i = 0; i < result1.size(); ++i) + std::cout << result1[i] << "\n"; +#endif + +// This is failing for gcc 4.4 and 4.5 - reason not identified. +#if !(BOOST_GCC_VERSION < 40600) + boost::push_back(result2, source | transformed(phoenix::bind(&Foo::value_, *arg1)) | uniqued); + + for(unsigned i = 0; i < result2.size(); ++i) + std::cout << result2[i] << "\n"; +#endif + + return 0; + +} + +int main() +{ + return range_test_complex(); +} + diff --git a/src/boost/libs/phoenix/test/regression/bug5626.cpp b/src/boost/libs/phoenix/test/regression/bug5626.cpp new file mode 100644 index 00000000..6f277cab --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug5626.cpp @@ -0,0 +1,26 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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 <utility> // for std::forward used by boost/range in some cases. +#include <boost/range.hpp> +#include <boost/range/irange.hpp> +#include <boost/range/adaptors.hpp> +#include <boost/phoenix.hpp> +#include <boost/detail/lightweight_test.hpp> + +using namespace boost::phoenix::arg_names; +using namespace boost::adaptors; + +int foo() { return 5; } + +int main() +{ + BOOST_TEST((*boost::begin(boost::irange(0,5) | transformed( arg1)) == 0)); + + boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/bug5824.cpp b/src/boost/libs/phoenix/test/regression/bug5824.cpp new file mode 100644 index 00000000..43609904 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug5824.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + 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) +==============================================================================*/ + +// Check for Bug5824 + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +#include <boost/core/lightweight_test.hpp> + +using namespace boost::phoenix::arg_names; + +int main() +{ + int a = 0; + (++arg1, ++arg1)(a); + BOOST_TEST(a == 2); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/bug5875.cpp b/src/boost/libs/phoenix/test/regression/bug5875.cpp new file mode 100644 index 00000000..689c5808 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug5875.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2014 John Fletcher + + 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/phoenix.hpp> +#include <vector> + +#include <boost/detail/lightweight_test.hpp> + +namespace phx = boost::phoenix; + +int main() +{ + std::vector<int> v = phx::let(phx::local_names::_a = std::vector<int>(3)) + [ + phx::local_names::_a + ] + (); + BOOST_TEST( v.size() == 3); +} diff --git a/src/boost/libs/phoenix/test/regression/bug5968.cpp b/src/boost/libs/phoenix/test/regression/bug5968.cpp new file mode 100644 index 00000000..113360a0 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug5968.cpp @@ -0,0 +1,27 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/phoenix.hpp> +#include <boost/signals2.hpp> + +struct s +{ + bool f(int, bool) { return true; } +}; + +int main() +{ + s s_obj; + boost::signals2::signal<bool (int, bool)> sig; + sig.connect( + boost::phoenix::bind( + &s::f, &s_obj, + boost::phoenix::placeholders::arg1, + boost::phoenix::placeholders::arg2)); +} + diff --git a/src/boost/libs/phoenix/test/regression/bug6040.cpp b/src/boost/libs/phoenix/test/regression/bug6040.cpp new file mode 100644 index 00000000..dce413cb --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug6040.cpp @@ -0,0 +1,22 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/phoenix.hpp> +#include <vector> +#include <algorithm> +#include <sstream> + +int main() +{ + std::vector<unsigned char> data; + using boost::phoenix::arg_names::_1; + using boost::phoenix::static_cast_; + std::ostringstream oss; + oss << std::hex; + std::for_each(data.begin(),data.end(), static_cast_<unsigned int>(_1) ); +} diff --git a/src/boost/libs/phoenix/test/regression/bug6268.cpp b/src/boost/libs/phoenix/test/regression/bug6268.cpp new file mode 100644 index 00000000..978d1a0e --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug6268.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + 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/fusion/sequence/comparison.hpp> +#include <boost/fusion/sequence/sequence_facade.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/comparison.hpp> + +struct foo : boost::fusion::sequence_facade<foo, boost::fusion::random_access_traversal_tag> +{ + // Rest of the sequence_facade extension mechanism code omitted, + // as it is not needed to reproduce the error + + foo() : x(), y() {} + + int x; + int y; +}; + +int main() +{ + (void)(boost::phoenix::arg_names::arg1 < foo()); +} diff --git a/src/boost/libs/phoenix/test/regression/bug7165.cpp b/src/boost/libs/phoenix/test/regression/bug7165.cpp new file mode 100644 index 00000000..b7804559 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug7165.cpp @@ -0,0 +1,15 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014-2015 John Fletcher + + 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) +==============================================================================*/ + +#define BOOST_PHOENIX_LIMIT 20 +#include <boost/phoenix/core/limits.hpp> + +int main() +{ +} diff --git a/src/boost/libs/phoenix/test/regression/bug7166.cpp b/src/boost/libs/phoenix/test/regression/bug7166.cpp new file mode 100644 index 00000000..1b3bc76b --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug7166.cpp @@ -0,0 +1,16 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + 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) +==============================================================================*/ + +#define BOOST_PROTO_MAX_ARITY 10 +#define BOOST_PHOENIX_LIMIT 20 +#include <boost/phoenix/core.hpp> + +int main() +{ +} diff --git a/src/boost/libs/phoenix/test/regression/bug7624.cpp b/src/boost/libs/phoenix/test/regression/bug7624.cpp new file mode 100644 index 00000000..f53c6bc5 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug7624.cpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + 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/phoenix.hpp> +#include <boost/range/as_literal.hpp> +#include <boost/core/lightweight_test.hpp> + +using namespace boost::phoenix::placeholders; +using namespace boost::phoenix; + +int main() +{ + char X('x'); + find(boost::as_literal("fox"), 'x')(); // works +#if !(defined (BOOST_NO_CXX11_DECLTYPE) || \ + defined (BOOST_INTEL_CXX_VERSION) || \ + (BOOST_GCC_VERSION < 40500) ) + const char *Y = find(boost::as_literal("fox"), arg1)('x'); // works for C++11 +#else + const char *Y = find(boost::as_literal("fox"), construct<char>(arg1))('x'); // works +#endif + BOOST_TEST(X == *Y); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/from_array.cpp b/src/boost/libs/phoenix/test/regression/from_array.cpp new file mode 100644 index 00000000..b7da4830 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/from_array.cpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2017 Nikita Kniazev + + 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/phoenix/core.hpp> +#include <boost/phoenix/object.hpp> +#include <boost/phoenix/scope.hpp> +#include <boost/phoenix/operator.hpp> + +#include <string> +#include <iostream> + +template <typename T, std::size_t N> +struct array_holder +{ + typedef T underlying_type[N]; + + array_holder(underlying_type const& x) + { + for (std::size_t i = 0; i < N; ++i) elems_[i] = x[i]; + } + + T elems_[N]; + + friend std::ostream& operator<<(std::ostream& os, array_holder const& x) + { + os << x.elems_[0]; + for (std::size_t i = 1; i < N; ++i) os << ", " << x.elems_[i]; + return os; + } +}; + +int main() +{ + using boost::phoenix::construct; + using boost::phoenix::let; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + let(_a = construct<std::string>("str")) + [ + std::cout << _a << std::endl + ](); + + let(_a = construct<array_holder<char, 4> >("str")) + [ + std::cout << _a << std::endl + ](); + + int ints[] = { 1, 2, 3 }; + let(_a = construct<array_holder<int, sizeof(ints) / sizeof(ints[0])> >(ints) ) + [ + std::cout << _a << std::endl + ](); + + return 0; +} |