|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62537 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/bind boost/phoenix/debug boost/phoenix/function boost/phoenix/object boost/phoenix/operator boost/phoenix/scope boost/phoenix/statement boost/phoenix/stl boost/phoenix/support libs/phoenix/test libs/phoenix/test/algorithm libs/phoenix/test/bind libs/phoenix/test/container libs/phoenix/test/core libs/phoenix/test/detail libs/phoenix/test/function libs/phoenix/test/object libs/phoenix/test/operator libs/phoenix/test/scope libs/phoenix/test/statement
From: joel_at_[hidden]
Date: 2010-06-07 21:31:41
Author: djowel
Date: 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
New Revision: 62537
URL: http://svn.boost.org/trac/boost/changeset/62537
Log:
First shot by Thomas Heller
Added:
sandbox/SOC/2010/phoenix3/boost/phoenix/bind/
sandbox/SOC/2010/phoenix3/boost/phoenix/bind.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/debug/
sandbox/SOC/2010/phoenix3/boost/phoenix/debug/dump_env.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/function/
sandbox/SOC/2010/phoenix3/boost/phoenix/function.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/function/function.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/object/
sandbox/SOC/2010/phoenix3/boost/phoenix/operator/
sandbox/SOC/2010/phoenix3/boost/phoenix/operator.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/operator/operator.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/
sandbox/SOC/2010/phoenix3/boost/phoenix/statement/
sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/statement/if.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/boost/phoenix/stl/
sandbox/SOC/2010/phoenix3/boost/phoenix/support/
sandbox/SOC/2010/phoenix3/boost/phoenix/support/element_at.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile.v2 (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/iteration.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/querying.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/querying2.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation1.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation2.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation3.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation4.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_function_object_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_function_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_member_function_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_member_variable_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests.hpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests1a.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests1b.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests2a.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests2b.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests3a.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests3b.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests4a.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests4b.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests5a.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests5b.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests6a.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests6b.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/core/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/core/compose_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/core/primitives_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/detail/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/detail/type_deduction_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/function/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/function/function_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/cast_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/new_delete_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/arithmetic_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/bitwise_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/comparison_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/if_else_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/io_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/logical_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/misc_binary_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/self_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/unary_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/bug_000008.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/dynamic_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/
sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/exceptions.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/if_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/loops_tests.cpp (contents, props changed)
sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp (contents, props changed)
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/bind.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/bind.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_BIND_HPP
+#define PHOENIX_BIND_HPP
+
+#include <boost/phoenix/version.hpp>
+#include <boost/phoenix/bind/bind.hpp>
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,46 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2010 Eric Niebler
+
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_BIND_BIND_HPP
+#define PHOENIX_BIND_BIND_HPP
+
+#include <boost/phoenix/function/function.hpp>
+#include <boost/utility/result_of.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Bind
+ ////////////////////////////////////////////////////////////////////////////
+
+ template<typename F>
+ typename boost::result_of<function<F>()>::type
+ bind(F f)
+ {
+ return function<F>(f)();
+ }
+
+ template<typename F, typename A0>
+ typename boost::result_of<function<F>(A0 const &)>::type
+ bind(F f, A0 const & a0)
+ {
+ return function<F>(f)(a0);
+ }
+
+ template<typename F, typename A0, typename A1>
+ typename boost::result_of<function<F>(A0 const &, A1 const &)>::type
+ bind(F f, A0 const & a0, A1 const & a1)
+ {
+ return function<F>(f)(a0, a1);
+ }
+
+ /* ... more ... */
+
+}}
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/debug/dump_env.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/debug/dump_env.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,78 @@
+/*==============================================================================
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_DEBUG_DUMP_ENVIRONMENT_HPP
+#define PHOENIX_DEBUG_DUMP_ENVIRONMENT_HPP
+
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/phoenix/core/extension.hpp>
+#include <boost/phoenix/core/meta_grammar.hpp>
+#include <boost/proto/proto_fwd.hpp>
+#include <boost/proto/matches.hpp>
+
+#include <iostream>
+
+namespace boost { namespace phoenix
+{
+ namespace detail
+ {
+ struct dump_env_tag {};
+
+ typedef extension<dump_env_tag> dump_env_ext;
+
+ struct dump
+ {
+ template<typename T>
+ void
+ operator()(T & t ) const
+ {
+ std::cout << t << std::endl;
+ }
+ };
+
+ struct dump_env
+ : proto::callable
+ {
+ typedef void result_type;
+
+ template<typename Env>
+ void
+ operator()(Env & env) const
+ {
+ if( fusion::size( env ) == 0 )
+ {
+ std::cout << "current environment is empty.\n";
+ return;
+ }
+
+ std::cout << "current environment is:\n";
+ fusion::for_each( env, dump() );
+ }
+ };
+ }
+
+
+ /// FIXME: boost::result_of doesn't seem to like that...
+ //boost::result_of< detail::dump_environment_extension() >::type
+ /*
+ boost::result_of< detail::dump_env_ext( mpl::void_ ) >::type
+ dump_env()
+ {
+ return detail::dump_env_ext()( mpl::void_() );
+ }*/
+
+
+ template<>
+ struct eval_cases::case_<debug::detail::dump_env_tag>
+ : proto::or_<
+ proto::when<
+ proto::_, debug::detail::dump_env(proto::_state)> >
+ {};
+
+}}
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/function.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/function.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_FUNCTION_HPP
+#define PHOENIX_FUNCTION_HPP
+
+#include <boost/phoenix/version.hpp>
+#include <boost/phoenix/function/function.hpp>
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/function/function.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/function/function.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,104 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2010 Eric Niebler
+
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_FUNCTION_FUNCTION_HPP
+#define PHOENIX_FUNCTION_FUNCTION_HPP
+
+//#include <boost/phoenix/core/extension.hpp>
+#include <boost/phoenix/core/domain.hpp>
+#include <boost/proto/proto.hpp>
+#include <boost/utility/result_of.hpp>
+
+namespace boost { namespace phoenix
+{
+ ////////////////////////////////////////////////////////////////////////////
+ // Functions
+ ////////////////////////////////////////////////////////////////////////////
+
+ // functor which returns our lazy function call extension
+ template<typename F>
+ struct function
+ {
+ //typedef extension<proto::tag::function> extension_type;
+
+ typedef function<F> function_type;
+
+ function() {}
+
+ function(F f)
+ : f(f)
+ {}
+
+ template<typename Signature>
+ struct result;
+
+ template<typename This>
+ struct result<This()> //: boost::result_of<extension_type(F)>
+ : proto::result_of::make_expr<proto::tag::function, phoenix_domain, F>
+ {};
+
+ template<typename This, typename A0>
+ struct result<This(A0 const &)> //: boost::result_of<extension_type(F, A0 const &)>
+ : proto::result_of::make_expr<proto::tag::function, phoenix_domain, F, A0>
+ {};
+
+ template<typename This, typename A0, typename A1>
+ struct result<This(A0 const &, A1 const &)>
+ //: boost::result_of<extension_type(F, A0 const &, A1 const &)>
+ : proto::result_of::make_expr<proto::tag::function, phoenix_domain, F, A0, A1>
+ {};
+
+ /* ... more ... */
+
+ //typename boost::result_of<function_type()>::type
+ typename proto::result_of::make_expr<
+ proto::tag::function, phoenix_domain, F>::type const
+ operator()() const
+ {
+ //return extension_type()(f);
+ return proto::make_expr<proto::tag::function, phoenix_domain>(f);
+ }
+
+ template<typename A0>
+ //typename boost::result_of<function_type(A0 const &)>::type const
+ typename proto::result_of::make_expr<
+ proto::tag::function, phoenix_domain, F, A0>::type const
+ operator()(A0 const & a0) const
+ {
+ //return extension_type()(f, a0);
+ return proto::make_expr<
+ proto::tag::function, phoenix_domain>(f, a0);
+ }
+
+ template<typename A0, typename A1>
+ //typename boost::result_of<function_type(A0 const &, A1 const &)>::type
+ typename proto::result_of::make_expr<
+ proto::tag::function, phoenix_domain, F, A0, A1>::type const
+ operator()(A0 const & a0, A1 const & a1) const
+ {
+ //return extension_type()(f, a0, a1);
+ return proto::make_expr<
+ proto::tag::function, phoenix_domain>(f, a0, a1);
+ }
+
+ /* ... more ... */
+
+ F f;
+ };
+
+}
+
+ template<typename F>
+ struct result_of<phoenix::function<F>()>
+ {
+ typedef phoenix::function<F> Fun;
+ typedef typename Fun::template result<Fun()>::type type;
+ };
+
+}
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/operator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/operator.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_OPERATOR_HPP
+#define PHOENIX_OPERATOR_HPP
+
+#include <boost/phoenix/version.hpp>
+#include <boost/phoenix/operator/operator.hpp>
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/operator/operator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/operator/operator.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2001-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)
+==============================================================================*/
+#ifndef PHOENIX_OPERATOR_OPERATOR_HPP
+#define PHOENIX_OPERATOR_OPERATOR_HPP
+
+#include <boost/proto/operators.hpp>
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_STATEMENT_HPP
+#define PHOENIX_STATEMENT_HPP
+
+#include <boost/phoenix/version.hpp>
+#include <boost/phoenix/statement/if.hpp>
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/if.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/if.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,123 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2010 Eric Niebler
+
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_STATEMENT_IF_HPP
+#define PHOENIX_STATEMENT_IF_HPP
+
+#include <boost/phoenix/core/actor.hpp>
+#include <boost/phoenix/core/as_actor.hpp>
+
+#include <boost/phoenix/support/element_at.hpp>
+
+namespace boost { namespace phoenix
+{
+ ////////////////////////////////////////////////////////////////////////////
+ // If-Else statements
+ ////////////////////////////////////////////////////////////////////////////
+
+ // Function for evaluating lambdas like: if_( foo )[ bar ].else_[ baz ]
+ struct if_else_eval
+ {
+ typedef void result_type;
+
+ template<typename Env, typename Cond, typename Then, typename Else>
+ void
+ operator()(Env & env, Cond const & cond, Then const & then, Else const & else_) const
+ {
+ if( eval( cond, env ) )
+ eval( then, env );
+ else
+ eval( else_, env );
+ }
+ };
+
+ // Function for evaluating lambdas like: if_( foo )[ bar ]
+ struct if_eval
+ {
+ typedef void result_type;
+
+ template<typename Env, typename Cond, typename Then>
+ void
+ operator()(Env & env, Cond const & cond, Then const & then) const
+ {
+ if( eval( cond, env ) )
+ eval( then, env );
+ }
+ };
+
+ // Generator for .else_[ expr ] branch.
+ template<typename Cond, typename Then>
+ struct else_gen
+ {
+ template<typename Else>
+ struct as_actor : phoenix::as_actor<if_else_eval, actor, Cond, Then, Else>
+ {};
+
+ else_gen(Cond const & cond, Then const & then)
+ : cond( cond )
+ , then( then ) {}
+
+ template<typename Else>
+ typename as_actor< Else >::result_type
+ operator[](Else const & else_) const
+ {
+ return as_actor< Else >()(cond, then, else_);
+ }
+
+ Cond const & cond;
+ Then const & then;
+ };
+
+ // We subclass actor so we can provide the member else_ (which is an
+ // else_gen responsible for the .else_[ expr ] branch).
+ template<typename Expr>
+ struct if_actor : actor< Expr >
+ {
+ typedef actor< Expr > base_type;
+
+ if_actor(base_type const & base)
+ : base_type( base )
+ , else_(element_at_c<0>(*this), element_at_c<1>(*this))
+ {}
+
+ typedef typename boost::phoenix::result_of::element_value_at_c<Expr, 0>::type cond_type;
+ typedef typename boost::phoenix::result_of::element_value_at_c<Expr, 1>::type then_type;
+
+ else_gen<cond_type, then_type> else_;
+ };
+
+ // Generator for if( cond )[ then ] branch.
+ template<typename Cond>
+ struct if_gen
+ {
+ template<typename Then>
+ struct as_actor : phoenix::as_actor<if_eval, if_actor, Cond, Then>
+ {};
+
+ if_gen(Cond const & cond)
+ : cond( cond ) {}
+
+ template<typename Then>
+ typename as_actor<Then>::result_type
+ operator[](Then const & then) const
+ {
+ return as_actor<Then>()(cond, then);
+ }
+
+ Cond const & cond;
+ };
+
+ template<typename Cond>
+ if_gen<Cond>
+ if_(Cond const & cond)
+ {
+ return if_gen<Cond>(cond);
+ }
+
+}}
+
+#endif
Added: sandbox/SOC/2010/phoenix3/boost/phoenix/support/element_at.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/support/element_at.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,84 @@
+/*==============================================================================
+ Copyright (c) 2010 Joel de Guzman
+
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_SUPPORT_ELEMENT_AT_HPP
+#define PHOENIX_SUPPORT_ELEMENT_AT_HPP
+
+#include <boost/fusion/sequence/intrinsic/value_at.hpp>
+
+#include <boost/proto/traits.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Actors carry specific information with it. Primitive actors may hold
+ // simple primitive data, like values (e.g. int). Composites hold a tuple
+ // of proto expressions that evaluate to actors (using fusion vector).
+ // The following facilities extract the "elements" from an actor. An
+ // element is just a proto expression that evaluates to an actor.
+ namespace result_of
+ {
+ // Get the Nth element value type from Expr (N is an integral constant)
+ template <class Expr, int N>
+ struct element_value_at_c : fusion::result_of::value_at_c<Expr, N+2>
+ {};
+
+ // Get the Nth element value type from Expr (N is an mpl int_)
+ template <class Expr, class N>
+ struct element_value_at : element_value_at_c<Expr, N::value>
+ {};
+
+ // Get the element type N from Expr (N is an integral constant)
+ template <class Expr, int N>
+ struct element_at_c : proto::result_of::child_c<Expr &, N+2>
+ {};
+
+ // Get the Nth element type N from Expr (N is an mpl int_)
+ template <class Expr, class N>
+ struct element_at : element_at_c<Expr, N::value>
+ {};
+ }
+
+ // Get the Nth element value N from Expr (N is an integral constant)
+ // non-const overload
+ template <int N, class Expr>
+ typename result_of::element_at_c<Expr, N>::type
+ element_at_c(Expr& expr)
+ {
+ return proto::child_c<N+2>(expr);
+ }
+
+ // Get the Nth element value N from Expr (N is an integral constant)
+ // const overload
+ template <int N, class Expr>
+ typename result_of::element_at_c<Expr const, N>::type
+ element_at_c(Expr const& expr)
+ {
+ return proto::child_c<N+2>(expr);
+ }
+
+ // Get the Nth element value N from Expr (N is an mpl int_)
+ // non-const overload
+ template <class N, class Expr>
+ typename result_of::element_at<Expr, N>::type
+ element_at(Expr& expr)
+ {
+ return proto::child_c<N::value + 2>(expr);
+ }
+
+ // Get the Nth element value N from Expr (N is an mpl int_)
+ // const overload
+ template <class N, class Expr>
+ typename result_of::element_at<Expr const, N>::type
+ element_at(Expr const& expr)
+ {
+ return proto::child_c<N::value + 2>(expr);
+ }
+
+}}
+
+#endif
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile.v2 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,90 @@
+#==============================================================================
+# Copyright (c) 2003-2006 Joel de Guzman
+#
+# Use, modification and distribution is subject to 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)
+#==============================================================================
+
+# bring in rules for testing
+import testing ;
+
+local multi-threading = <library>/boost/thread//boost/thread
+ <threading>multi <define>BOOST_ALL_NO_LIB=1 ;
+
+#test-suite phoenix_detail :
+# [ run detail/type_deduction_tests.cpp ]
+# ;
+
+test-suite phoenix_core :
+ [ run core/primitives_tests.cpp ]
+# [ run core/compose_tests.cpp ]
+ ;
+
+test-suite phoenix_operator :
+ [ run operator/arithmetic_tests.cpp ]
+ [ run operator/bitwise_tests.cpp ]
+ [ run operator/comparison_tests.cpp ]
+# [ run operator/if_else_tests.cpp ]
+ [ run operator/io_tests.cpp ]
+ [ run operator/logical_tests.cpp ]
+ [ run operator/misc_binary_tests.cpp ]
+ [ run operator/self_tests.cpp ]
+ [ run operator/unary_tests.cpp ]
+ [ run operator/member.cpp ]
+ ;
+
+#test-suite phoenix_object :
+# [ run object/cast_tests.cpp ]
+# [ run object/new_delete_tests.cpp ]
+# ;
+
+test-suite phoenix_function :
+ [ run function/function_tests.cpp ]
+ ;
+
+test-suite phoenix_bind :
+ [ run bind/bind_function_tests.cpp ]
+ [ run bind/bind_function_object_tests.cpp ]
+ [ run bind/bind_member_function_tests.cpp ]
+ [ run bind/bind_member_variable_tests.cpp ]
+ ;
+
+test-suite phoenix_statement :
+ [ run statement/if_tests.cpp ]
+# [ run statement/loops_tests.cpp ]
+# [ run statement/switch_tests.cpp ]
+# [ run statement/exceptions.cpp ]
+ ;
+
+#test-suite phoenix_container :
+# [ run container/container_tests1a.cpp ]
+# [ run container/container_tests1b.cpp ]
+# [ run container/container_tests2a.cpp ]
+# [ run container/container_tests2b.cpp ]
+# [ run container/container_tests3a.cpp ]
+# [ run container/container_tests3b.cpp ]
+# [ run container/container_tests4a.cpp ]
+# [ run container/container_tests4b.cpp ]
+# [ run container/container_tests5a.cpp ]
+# [ run container/container_tests5b.cpp ]
+# [ run container/container_tests6a.cpp ]
+# [ run container/container_tests6b.cpp ]
+# ;
+
+#test-suite phoenix_scope :
+# [ run scope/lambda_tests.cpp ]
+# [ run scope/let_tests.cpp ]
+# [ run scope/dynamic_tests.cpp ]
+# [ run scope/bug_000008.cpp : : : $(multi-threading) ]
+# ;
+
+#test-suite phoenix_algorithm :
+# [ run algorithm/iteration.cpp ]
+# [ run algorithm/transformation1.cpp ]
+# [ run algorithm/transformation2.cpp ]
+# [ run algorithm/transformation3.cpp ]
+# [ run algorithm/transformation4.cpp ]
+# [ run algorithm/querying.cpp ]
+# [ run algorithm/querying2.cpp ]
+# ;
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/iteration.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/iteration.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,57 @@
+/*=============================================================================
+ Copyright (c) 2005-2007 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+
+ 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/spirit/home/phoenix/stl/algorithm/iteration.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <functional>
+
+namespace
+{
+ struct for_each_tester
+ {
+ int value_;
+ for_each_tester() : value_(0) { }
+ void operator()(
+ int& i)
+ {
+ value_ += i++;
+ return;
+ }
+ };
+
+ void for_each_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ BOOST_TEST(for_each(arg1, for_each_tester())(array).value_ == 6);
+ BOOST_TEST(array[0] == 2);
+ BOOST_TEST(array[1] == 3);
+ BOOST_TEST(array[2] == 4);
+ return;
+ }
+
+ void accumulate_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ BOOST_TEST(accumulate(arg1, 0)(array) == 6);
+ BOOST_TEST(boost::phoenix::accumulate(arg1, 0, std::minus<int>())(array) == -6);
+ return;
+ }
+}
+
+int main()
+{
+ for_each_test();
+ accumulate_test();
+ boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/querying.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/querying.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,299 @@
+/*=============================================================================
+ Copyright (c) 2005 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+ Copyright (c) 2007 Hartmut Kaiser
+
+ 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/spirit/home/phoenix/stl/algorithm/querying.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/assign/list_of.hpp>
+
+#include <boost/config.hpp>
+
+#ifdef BOOST_HAS_HASH
+#include BOOST_HASH_SET_HEADER
+#include BOOST_HASH_MAP_HEADER
+#define BOOST_PHOENIX_HAS_HASH
+#define BOOST_PHOENIX_HASH_NAMESPACE BOOST_STD_EXTENSION_NAMESPACE
+#elif defined(BOOST_DINKUMWARE_STDLIB)
+#include <hash_set>
+#include <hash_map>
+#define BOOST_PHOENIX_HAS_HASH
+#define BOOST_PHOENIX_HASH_NAMESPACE stdext
+#endif
+
+#include <set>
+#include <map>
+#include <functional>
+
+namespace
+{
+ struct even
+ {
+ bool operator()(const int i) const
+ {
+ return i % 2 == 0;
+ }
+ };
+
+ struct mod_2_comparison
+ {
+ bool operator()(
+ const int lhs,
+ const int rhs)
+ {
+ return lhs % 2 == rhs % 2;
+ };
+ };
+
+ void find_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ BOOST_TEST(find(arg1,2)(array) == array + 1);
+
+ std::set<int> s(array, array + 3);
+ BOOST_TEST(find(arg1, 2)(s) == s.find(2));
+
+ std::map<int, int> m = boost::assign::map_list_of(0, 1)(2, 3)(4, 5);
+ BOOST_TEST(find(arg1, 2)(m) == m.find(2));
+
+#ifdef BOOST_PHOENIX_HAS_HASH
+
+ BOOST_PHOENIX_HASH_NAMESPACE::hash_set<int> hs(array, array + 3);
+ BOOST_TEST(find(arg1, 2)(hs) == hs.find(2));
+
+ BOOST_PHOENIX_HASH_NAMESPACE::hash_map<int, int> hm = boost::assign::map_list_of(0, 1)(2, 3)(4, 5);
+ BOOST_TEST(find(arg1, 2)(hm) == hm.find(2));
+
+#endif
+
+ return;
+ }
+
+
+ void find_if_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ BOOST_TEST(find_if(arg1, even())(array) == array + 1);
+ return;
+ }
+
+ void find_end_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3,1,2,3,1};
+ int pattern[] = {1,2,3};
+ BOOST_TEST(find_end(arg1, arg2)(array, pattern) == array + 3);
+ int pattern2[] = {5,6,5};
+ BOOST_TEST(find_end(arg1, arg2, mod_2_comparison())(array, pattern2) == array + 3);
+ return;
+ }
+
+ void find_first_of_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int search_for[] = {2,3,4};
+ BOOST_TEST(find_first_of(arg1, arg2)(array, search_for) == array + 1);
+
+ int search_for2[] = {0};
+ BOOST_TEST(find_first_of(arg1, arg2, mod_2_comparison())(array, search_for2) == array + 1);
+ return;
+ }
+
+ void adjacent_find_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {0,1,3,4,4};
+ BOOST_TEST(adjacent_find(arg1)(array) == array + 3);
+ BOOST_TEST(adjacent_find(arg1, mod_2_comparison())(array) == array + 1);
+ return;
+ }
+
+ void count_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,1,0,1,1};
+ BOOST_TEST(count(arg1, 1)(array) == 4);
+ return;
+ }
+
+ void count_if_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3,4,5};
+ BOOST_TEST(count_if(arg1, even())(array) == 2);
+ return;
+ }
+
+ void distance_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,1,0,1,1};
+ BOOST_TEST(distance(arg1)(array) == 5);
+ return;
+ }
+
+ void mismatch_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3,4,5};
+ int search[] = {1,2,4};
+
+ BOOST_TEST(
+ mismatch(arg1, arg2)(array, search) ==
+ std::make_pair(array + 2, search + 2));
+ int search2[] = {1,2,1,1};
+ BOOST_TEST(
+ mismatch(arg1, arg2, mod_2_comparison())(array, search2)
+ == std::make_pair(array + 3, search2 + 3));
+
+ return;
+ }
+
+ void equal_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[] = {1,2,3};
+ int array3[] = {1,2,4};
+ BOOST_TEST(
+ equal(arg1, arg2)(array, array2));
+ BOOST_TEST(
+ !equal(arg1, arg2)(array, array3));
+
+ BOOST_TEST(
+ equal(arg1, arg2, mod_2_comparison())(array, array2));
+ BOOST_TEST(
+ !equal(arg1, arg2, mod_2_comparison())(array, array3));
+ return;
+ }
+
+ void search_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3,1,2,3};
+ int pattern[] = {2,3};
+ BOOST_TEST(
+ search(arg1, arg2)(array, pattern) == array + 1);
+ int pattern2[] = {1,1};
+ BOOST_TEST(
+ search(arg1, arg2, mod_2_comparison())(array, pattern2) == array + 2);
+ return;
+ }
+
+ void lower_bound_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ const std::set<int> test_set(array, array + 3);
+ BOOST_TEST(lower_bound(arg1, 2)(array) == array + 1);
+ BOOST_TEST(lower_bound(arg1, 2)(test_set) == test_set.lower_bound(2));
+
+ int array2[] = {3,2,1};
+ const std::set<int, std::greater<int> > test_set2(array2, array2 + 3);
+ BOOST_TEST(boost::phoenix::lower_bound(arg1, 2, std::greater<int>())(array2) ==
+ array2 + 1);
+ BOOST_TEST(boost::phoenix::lower_bound(arg1, 2, std::greater<int>())(test_set2) ==
+ test_set2.lower_bound(2));
+ return;
+ }
+
+ void upper_bound_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ const std::set<int> test_set(array, array + 3);
+ BOOST_TEST(upper_bound(arg1, 2)(array) == array + 2);
+ BOOST_TEST(upper_bound(arg1, 2)(test_set) == test_set.upper_bound(2));
+
+ int array2[] = {3,2,1};
+ const std::set<int, std::greater<int> > test_set2(array2, array2 + 3);
+ BOOST_TEST(boost::phoenix::upper_bound(arg1, 2, std::greater<int>())(array2) ==
+ array2 + 2);
+ BOOST_TEST(boost::phoenix::upper_bound(arg1, 2, std::greater<int>())(test_set2) ==
+ test_set2.upper_bound(2));
+ return;
+ }
+
+ void equal_range_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,2,3};
+ const std::set<int> test_set(array, array + 4);
+ BOOST_TEST(equal_range(arg1, 2)(array).first ==
+ array + 1);
+ BOOST_TEST(equal_range(arg1, 2)(array).second ==
+ array + 3);
+
+ BOOST_TEST(equal_range(arg1, 2)(test_set).first ==
+ test_set.equal_range(2).first);
+ BOOST_TEST(equal_range(arg1, 2)(test_set).second ==
+ test_set.equal_range(2).second);
+
+ int array2[] = {3,2,2,1};
+ const std::set<int, std::greater<int> > test_set2(array2, array2 + 4);
+ BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(array2).first ==
+ array2 + 1);
+ BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(array2).second ==
+ array2 + 3);
+
+ BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(test_set2).first ==
+ test_set2.equal_range(2).first);
+ BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(test_set2).second ==
+ test_set2.equal_range(2).second);
+
+ return;
+ }
+
+ void binary_search_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ BOOST_TEST(binary_search(arg1, 2)(array));
+ BOOST_TEST(!binary_search(arg1, 4)(array));
+ return;
+ }
+
+}
+
+int main()
+{
+ find_test();
+ find_if_test();
+ find_end_test();
+ find_first_of_test();
+ adjacent_find_test();
+ count_test();
+ count_if_test();
+ distance_test();
+ mismatch_test();
+ equal_test();
+ search_test();
+ lower_bound_test();
+ upper_bound_test();
+ equal_range_test();
+ binary_search_test();
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/querying2.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/querying2.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,83 @@
+/*=============================================================================
+ Copyright (c) 2005-2007 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+
+ 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/spirit/home/phoenix/stl/algorithm/querying.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/range.hpp>
+
+#include <functional>
+
+namespace
+{
+ void includes_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[] = {1,2};
+ BOOST_TEST(includes(arg1, arg2)(array, array2));
+ boost::iterator_range<int*> rng(array + 1, array + 3);
+ BOOST_TEST(!includes(arg1, arg2)(rng, array2));
+
+ int array3[] = {3,2,1};
+ int array4[] = {2,1};
+ BOOST_TEST(boost::phoenix::includes(arg1, arg2, std::greater<int>())(array3, array4));
+ boost::iterator_range<int*> rng2(array3, array3 + 2);
+ BOOST_TEST(!boost::phoenix::includes(arg1, arg2, std::greater<int>())(rng2, array4));
+ return;
+ }
+
+ void min_element_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,3,2};
+ BOOST_TEST(min_element(arg1)(array) == array);
+ BOOST_TEST(boost::phoenix::min_element(arg1, std::greater<int>())(array) == array + 1);
+ return;
+ }
+
+ void max_element_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,3,2};
+ BOOST_TEST(max_element(arg1)(array) == array + 1);
+ BOOST_TEST(boost::phoenix::max_element(arg1, std::greater<int>())(array) == array);
+ return;
+ }
+
+ void lexicographical_compare_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[] = {1,2,4};
+
+ BOOST_TEST(lexicographical_compare(arg1, arg2)(array, array2));
+ BOOST_TEST(!lexicographical_compare(arg1, arg2)(array2, array));
+ BOOST_TEST(!lexicographical_compare(arg1, arg2)(array, array));
+
+ BOOST_TEST(!boost::phoenix::lexicographical_compare(arg1, arg2, std::greater<int>())(array, array2));
+ BOOST_TEST(boost::phoenix::lexicographical_compare(arg1, arg2, std::greater<int>())(array2, array));
+ BOOST_TEST(!boost::phoenix::lexicographical_compare(arg1, arg2, std::greater<int>())(array, array));
+
+ return;
+ }
+}
+
+int main()
+{
+ includes_test();
+ min_element_test();
+ max_element_test();
+ lexicographical_compare_test();
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation1.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation1.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,390 @@
+/*=============================================================================
+ Copyright (c) 2005-2007 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+
+ 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/spirit/home/phoenix/stl/algorithm/transformation.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <functional>
+#include <list>
+
+namespace
+{
+ struct even
+ {
+ bool operator()(const int i) const
+ {
+ return i % 2 == 0;
+ }
+ };
+
+ struct mod_2_comparison
+ {
+ bool operator()(
+ const int lhs,
+ const int rhs)
+ {
+ return lhs % 2 == rhs % 2;
+ };
+ };
+
+ void swap_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int a = 123;
+ int b = 456;
+ swap(ref(a), ref(b))();
+ BOOST_TEST(a == 456 && b == 123);
+ swap(ref(a), _1)(b);
+ BOOST_TEST(a == 123 && b == 456);
+ swap(_1, _2)(a, b);
+ BOOST_TEST(a == 456 && b == 123);
+ return;
+ }
+
+ void copy_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int output[4];
+ BOOST_TEST(
+ copy(arg1, arg2)(array, output) == output + 3);
+ BOOST_TEST(output[0] == 1);
+ BOOST_TEST(output[1] == 2);
+ BOOST_TEST(output[2] == 3);
+ return;
+ }
+
+ void copy_backward_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int output[4];
+ int* output_end = output + 3;
+ BOOST_TEST(
+ copy_backward(arg1, arg2)(array, output_end) == output);
+ BOOST_TEST(output[0] == 1);
+ BOOST_TEST(output[1] == 2);
+ BOOST_TEST(output[2] == 3);
+ return;
+ }
+
+ struct increment
+ {
+ int operator()(
+ int i) const
+ {
+ return i+1;
+ }
+ };
+
+ void transform_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ BOOST_TEST(
+ transform(arg1, arg2, increment())(array, array) ==
+ array + 3);
+ BOOST_TEST(array[0] == 2);
+ BOOST_TEST(array[1] == 3);
+ BOOST_TEST(array[2] == 4);
+
+ int array2[] = {1,2,3};
+ BOOST_TEST(
+ boost::phoenix::transform(arg1, arg2, arg3, std::plus<int>())(array, array2, array) ==
+ array +3);
+ BOOST_TEST(array[0] == 2 + 1);
+ BOOST_TEST(array[1] == 3 + 2);
+ BOOST_TEST(array[2] == 4 + 3);
+ return;
+ }
+
+ void replace_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ replace(arg1,2,4)(array);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 4);
+ BOOST_TEST(array[2] == 3);
+ return;
+ }
+
+ void replace_if_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ replace_if(arg1, even(), 4)(array);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 4);
+ BOOST_TEST(array[2] == 3);
+ return;
+ }
+
+ void replace_copy_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int input[] = {1,2,3};
+ int output[3];
+ replace_copy(arg1, arg2, 2, 4)(input, output);
+ BOOST_TEST(output[0] == 1);
+ BOOST_TEST(output[1] == 4);
+ BOOST_TEST(output[2] == 3);
+ return;
+ }
+
+ void replace_copy_if_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int input[] = {1,2,3};
+ int output[3];
+ replace_copy_if(arg1, arg2, even(), 4)(input, output);
+ BOOST_TEST(output[0] == 1);
+ BOOST_TEST(output[1] == 4);
+ BOOST_TEST(output[2] == 3);
+ return;
+ }
+
+ void fill_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {0,0,0};
+ fill(arg1, 1)(array);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 1);
+ BOOST_TEST(array[2] == 1);
+ return;
+ }
+
+ void fill_n_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {0,0,0};
+ fill_n(arg1, 2, 1)(array);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 1);
+ BOOST_TEST(array[2] == 0);
+ return;
+ }
+
+ class int_seq
+ {
+ public:
+ int_seq() : val_(0) { }
+
+ int operator()()
+ {
+ return val_++;
+ }
+ private:
+ int val_;
+ };
+
+ void generate_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[3];
+ generate(arg1, int_seq())(array);
+ BOOST_TEST(array[0] == 0);
+ BOOST_TEST(array[1] == 1);
+ BOOST_TEST(array[2] == 2);
+ return;
+ }
+
+ void generate_n_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {0,0,1};
+ generate_n(arg1, 2, int_seq())(array);
+ BOOST_TEST(array[0] == 0);
+ BOOST_TEST(array[1] == 1);
+ BOOST_TEST(array[2] == 1);
+ return;
+ }
+
+
+ void remove_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ std::list<int> test_list(array, array + 3);
+ BOOST_TEST(boost::phoenix::remove(arg1, 2)(array) == array + 2);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 3);
+ BOOST_TEST(boost::phoenix::remove(arg1, 2)(test_list) == test_list.end());
+ std::list<int>::const_iterator it(test_list.begin());
+ BOOST_TEST(*it++ == 1);
+ BOOST_TEST(*it++ == 3);
+ return;
+ }
+
+ void remove_if_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ std::list<int> test_list(array, array + 3);
+ BOOST_TEST(boost::phoenix::remove_if(arg1, even())(array) == array + 2);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 3);
+ BOOST_TEST(boost::phoenix::remove_if(arg1, even())(test_list) == test_list.end());
+ std::list<int>::const_iterator it(test_list.begin());
+ BOOST_TEST(*it++ == 1);
+ BOOST_TEST(*it++ == 3);
+ return;
+ }
+
+ void remove_copy_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[2];
+ BOOST_TEST(boost::phoenix::remove_copy(arg1, arg2, 2)(array, array2) == array2 + 2);
+ BOOST_TEST(array2[0] == 1);
+ BOOST_TEST(array2[1] == 3);
+ return;
+ }
+
+ void remove_copy_if_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[2];
+ BOOST_TEST(boost::phoenix::remove_copy_if(arg1, arg2, even())(array, array2) == array2 + 2);
+ BOOST_TEST(array2[0] == 1);
+ BOOST_TEST(array2[1] == 3);
+ return;
+ }
+
+ void unique_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,2,3};
+ std::list<int> test_list(array, array + 4);
+ BOOST_TEST(unique(arg1)(array) == array + 3);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 2);
+ BOOST_TEST(array[2] == 3);
+
+ BOOST_TEST(unique(arg1)(test_list) == test_list.end());
+ std::list<int>::const_iterator it(test_list.begin());
+ BOOST_TEST(*it++ == 1);
+ BOOST_TEST(*it++ == 2);
+ BOOST_TEST(*it++ == 3);
+
+ int array2[] = {1,3,2};
+ std::list<int> test_list2(array2, array2 + 3);
+ BOOST_TEST(unique(arg1, mod_2_comparison())(array2) == array2 + 2);
+ BOOST_TEST(array2[0] == 1);
+ BOOST_TEST(array2[1] == 2);
+
+ BOOST_TEST(unique(arg1, mod_2_comparison())(test_list2) == test_list2.end());
+ std::list<int>::const_iterator jt(test_list2.begin());
+ BOOST_TEST(*jt++ == 1);
+ BOOST_TEST(*jt++ == 2);
+
+ return;
+ }
+
+ void unique_copy_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,2,3};
+ int out[3];
+ BOOST_TEST(unique_copy(arg1, arg2)(array, out) == out + 3);
+ BOOST_TEST(out[0] == 1);
+ BOOST_TEST(out[1] == 2);
+ BOOST_TEST(out[2] == 3);
+
+ int array2[] = {1,3,2};
+ int out2[2];
+ BOOST_TEST(unique_copy(arg1, arg2, mod_2_comparison())(array2, out2) == out2 + 2);
+ BOOST_TEST(out2[0] == 1);
+ BOOST_TEST(out2[1] == 2);
+
+ return;
+ }
+
+ void reverse_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ std::list<int> test_list(array, array + 3);
+ reverse(arg1)(array);
+ BOOST_TEST(array[0] == 3);
+ BOOST_TEST(array[1] == 2);
+ BOOST_TEST(array[2] == 1);
+
+ reverse(arg1)(test_list);
+ std::list<int>::iterator it(test_list.begin());
+ BOOST_TEST(*it++ == 3);
+ BOOST_TEST(*it++ == 2);
+ BOOST_TEST(*it++ == 1);
+ return;
+ }
+
+ void reverse_copy_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[3];
+ reverse_copy(arg1, arg2)(array, array2);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 2);
+ BOOST_TEST(array[2] == 3);
+
+ BOOST_TEST(array2[0] == 3);
+ BOOST_TEST(array2[1] == 2);
+ BOOST_TEST(array2[2] == 1);
+
+ return;
+ }
+}
+
+int main()
+{
+ copy_test();
+ copy_backward_test();
+ transform_test();
+ replace_test();
+ replace_if_test();
+ replace_copy_test();
+ replace_copy_if_test();
+ fill_test();
+ fill_n_test();
+ generate_test();
+ generate_n_test();
+ remove_test();
+ remove_if_test();
+ remove_copy_test();
+ remove_copy_if_test();
+ unique_test();
+ unique_copy_test();
+ reverse_test();
+ reverse_copy_test();
+ boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation2.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation2.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,188 @@
+/*=============================================================================
+ Copyright (c) 2005-2007 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+
+ 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/spirit/home/phoenix/stl/algorithm/transformation.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <list>
+
+namespace
+{
+ struct even
+ {
+ bool operator()(const int i) const
+ {
+ return i % 2 == 0;
+ }
+ };
+
+ void rotate_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ rotate(arg1, array + 1)(array);
+ std::cout << array[0] << array[1] << array[2] << std::endl;
+ BOOST_TEST(array[0] == 2);
+ BOOST_TEST(array[1] == 3);
+ BOOST_TEST(array[2] == 1);
+
+ return;
+ }
+
+ void rotate_copy_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[3];
+ rotate_copy(arg1, array + 1, arg2)(array, array2);
+ BOOST_TEST(array2[0] == 2);
+ BOOST_TEST(array2[1] == 3);
+ BOOST_TEST(array2[2] == 1);
+
+ return;
+ }
+
+ void random_shuffle_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ random_shuffle(arg1)(array);
+ const int first = array[0];
+ BOOST_TEST(first == 1 || first == 2 || first == 3);
+ const int second = array[1];
+ BOOST_TEST(second == 1 || second == 2 || second == 3);
+ BOOST_TEST(first != second);
+ const int third = array[2];
+ BOOST_TEST(third == 1 || third == 2 || third == 3);
+ BOOST_TEST(first != third && second != third);
+ return;
+ }
+
+ void partition_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int* const end = partition(arg1, even())(array);
+ BOOST_TEST(end == array + 1);
+ BOOST_TEST(array[0] % 2 == 0);
+ BOOST_TEST(array[1] % 2 != 0);
+ BOOST_TEST(array[2] % 2 != 0);
+ return;
+ }
+
+ void stable_partition_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int* const end = stable_partition(arg1, even())(array);
+ BOOST_TEST(end == array + 1);
+ BOOST_TEST(array[0] == 2);
+ BOOST_TEST(array[1] == 1);
+ BOOST_TEST(array[2] == 3);
+ return;
+ }
+
+ void sort_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {3,1,2};
+ std::list<int> test_list(array, array + 3);
+ sort(arg1)(array);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 2);
+ BOOST_TEST(array[2] == 3);
+
+ sort(arg1)(test_list);
+ std::list<int>::const_iterator it(test_list.begin());
+ BOOST_TEST(*it++ == 1);
+ BOOST_TEST(*it++ == 2);
+ BOOST_TEST(*it++ == 3);
+
+ boost::phoenix::sort(arg1, std::greater<int>())(array);
+ BOOST_TEST(array[0] == 3);
+ BOOST_TEST(array[1] == 2);
+ BOOST_TEST(array[2] == 1);
+
+ boost::phoenix::sort(arg1, std::greater<int>())(test_list);
+ std::list<int>::const_iterator jt(test_list.begin());
+ BOOST_TEST(*jt++ == 3);
+ BOOST_TEST(*jt++ == 2);
+ BOOST_TEST(*jt++ == 1);
+
+ return;
+ }
+
+ void stable_sort_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {3,1,2};
+ stable_sort(arg1)(array);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 2);
+ BOOST_TEST(array[2] == 3);
+
+ boost::phoenix::stable_sort(arg1, std::greater<int>())(array);
+ BOOST_TEST(array[0] == 3);
+ BOOST_TEST(array[1] == 2);
+ BOOST_TEST(array[2] == 1);
+
+ return;
+ }
+
+ void partial_sort_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {2,4,1,3};
+ partial_sort(arg1, array + 2)(array);
+ BOOST_TEST(array[0] == 1);
+ BOOST_TEST(array[1] == 2);
+
+ boost::phoenix::partial_sort(arg1, array + 2, std::greater<int>())(array);
+ BOOST_TEST(array[0] == 4);
+ BOOST_TEST(array[1] == 3);
+ return;
+ }
+
+ void partial_sort_copy_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {2,4,1,3};
+ int array2[2];
+ partial_sort_copy(arg1, arg2)(array, array2);
+ BOOST_TEST(array2[0] == 1);
+ BOOST_TEST(array2[1] == 2);
+
+ boost::phoenix::partial_sort(arg1, arg2, std::greater<int>())(array, array2);
+ BOOST_TEST(array2[0] == 4);
+ BOOST_TEST(array2[1] == 3);
+ return;
+ }
+}
+
+int main()
+{
+ rotate_test();
+ rotate_copy_test();
+ random_shuffle_test();
+ partition_test();
+ stable_partition_test();
+ sort_test();
+ stable_sort_test();
+ partial_sort_test();
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation3.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation3.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,176 @@
+/*=============================================================================
+ Copyright (c) 2005-2007 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+
+ 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/spirit/home/phoenix/stl/algorithm/transformation.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <list>
+
+namespace
+{
+ void nth_element_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {5,1,4,3,2};
+ nth_element(arg1, array + 2)(array);
+ BOOST_TEST(array[0] < 3);
+ BOOST_TEST(array[1] < 3);
+ BOOST_TEST(array[2] == 3);
+ BOOST_TEST(array[3] > 3);
+ BOOST_TEST(array[4] > 3);
+
+ boost::phoenix::nth_element(arg1, array + 2, std::greater<int>())(array);
+ BOOST_TEST(array[0] > 3);
+ BOOST_TEST(array[1] > 3);
+ BOOST_TEST(array[2] == 3);
+ BOOST_TEST(array[3] < 3);
+ BOOST_TEST(array[4] < 3);
+
+ return;
+ }
+
+ void merge_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[] = {2,3,4};
+ int output[6];
+
+ BOOST_TEST(merge(arg1, arg2, arg3)(array, array2, output) == output + 6);
+ int expected_result[] = {1,2,2,3,3,4};
+ BOOST_TEST(std::equal(output, output + 6, expected_result));
+
+ int array3[] = {5,4,3};
+ int array4[] = {3,2,1};
+ int output2[6];
+ BOOST_TEST(boost::phoenix::merge(arg1, arg2, arg3, std::greater<int>())(array3, array4, output2) ==
+ output2 + 6);
+ int expected_result2[] = {5,4,3,3,2,1};
+ BOOST_TEST(std::equal(output2, output2 + 6, expected_result2));
+ return;
+ }
+
+ void inplace_merge_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3,2,3,4};
+ inplace_merge(arg1, array + 3)(array);
+ int expected_result[] = {1,2,2,3,3,4};
+ BOOST_TEST(std::equal(array, array + 6, expected_result));
+
+ int array2[] = {5,4,3,4,3,2};
+ boost::phoenix::inplace_merge(arg1, array2 + 3, std::greater<int>())(array2);
+ int expected_result2[] = {5,4,4,3,3,2};
+ BOOST_TEST(std::equal(array2, array2 + 6, expected_result2));
+ return;
+ }
+
+ void set_union_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[] = {2,3,4};
+ int output[4];
+ BOOST_TEST(set_union(arg1, arg2, arg3)(array, array2, output) == output + 4);
+ int expected_result[] = {1,2,3,4};
+ BOOST_TEST(std::equal(output, output + 4, expected_result));
+
+ int array3[] = {3,2,1};
+ int array4[] = {4,3,2};
+ int output2[4];
+ BOOST_TEST(boost::phoenix::set_union(arg1, arg2, arg3, std::greater<int>())
+ (array3, array4, output2) ==
+ output2 + 4);
+ int expected_result2[] = {4,3,2,1};
+ BOOST_TEST(std::equal(output2, output2 + 4, expected_result2));
+ return;
+ }
+
+ void set_intersection_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[] = {2,3,4};
+ int output[2];
+ BOOST_TEST(set_intersection(arg1, arg2, arg3)(array, array2, output) == output + 2);
+ int expected_result[] = {2,3};
+ BOOST_TEST(std::equal(output, output + 2, expected_result));
+
+ int array3[] = {3,2,1};
+ int array4[] = {4,3,2};
+ int output2[2];
+ BOOST_TEST(boost::phoenix::set_intersection(arg1, arg2, arg3, std::greater<int>())
+ (array3, array4, output2) ==
+ output2 + 2);
+ int expected_result2[] = {3,2};
+ BOOST_TEST(std::equal(output2, output2 + 2, expected_result2));
+ return;
+ }
+
+ void set_difference_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[] = {2,3,4};
+ int output[1];
+ BOOST_TEST(set_difference(arg1, arg2, arg3)(array, array2, output) == output + 1);
+ int expected_result[] = {1};
+ BOOST_TEST(std::equal(output, output + 1, expected_result));
+
+ int array3[] = {3,2,1};
+ int array4[] = {4,3,2};
+ int output2[1];
+ BOOST_TEST(boost::phoenix::set_difference(arg1, arg2, arg3, std::greater<int>())
+ (array3, array4, output2) ==
+ output2 + 1);
+ int expected_result2[] = {1};
+ BOOST_TEST(std::equal(output2, output2 + 1, expected_result2));
+ return;
+ }
+
+ void set_symmetric_difference_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int array2[] = {2,3,4};
+ int output[2];
+ BOOST_TEST(set_symmetric_difference(arg1, arg2, arg3)(array, array2, output) == output + 2);
+ int expected_result[] = {1,4};
+ BOOST_TEST(std::equal(output, output + 2, expected_result));
+
+ int array3[] = {3,2,1};
+ int array4[] = {4,3,2};
+ int output2[2];
+ BOOST_TEST(boost::phoenix::set_symmetric_difference(arg1, arg2, arg3, std::greater<int>())
+ (array3, array4, output2) ==
+ output2 + 2);
+ int expected_result2[] = {4,1};
+ BOOST_TEST(std::equal(output2, output2 + 2, expected_result2));
+ return;
+ }
+}
+
+int main()
+{
+ nth_element_test();
+ merge_test();
+ inplace_merge_test();
+ set_union_test();
+ set_intersection_test();
+ set_difference_test();
+ set_symmetric_difference_test();
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation4.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/algorithm/transformation4.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,153 @@
+/*=============================================================================
+ Copyright (c) 2005-2007 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+
+ 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/spirit/home/phoenix/stl/algorithm/transformation.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <vector>
+#include <functional>
+#include <algorithm>
+
+namespace
+{
+ void heap_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ std::vector<int> vec(array, array + 3);
+ boost::phoenix::make_heap(arg1)(vec);
+ vec.push_back(5);
+ boost::phoenix::push_heap(arg1)(vec);
+ vec.push_back(4);
+ boost::phoenix::push_heap(arg1)(vec);
+ boost::phoenix::pop_heap(arg1)(vec);
+ BOOST_TEST(vec.back() == 5);
+ vec.pop_back();
+ boost::phoenix::sort_heap(arg1)(vec);
+ int expected_result[] = {1,2,3,4};
+ BOOST_TEST(std::equal(vec.begin(), vec.end(), expected_result));
+
+ int array2[] = {3,2,1};
+ std::vector<int> vec2(array2, array2 + 3);
+ boost::phoenix::make_heap(arg1, std::greater<int>())(vec2);
+ vec2.push_back(5);
+ boost::phoenix::push_heap(arg1, std::greater<int>())(vec2);
+ vec2.push_back(4);
+ boost::phoenix::push_heap(arg1, std::greater<int>())(vec2);
+ boost::phoenix::pop_heap(arg1, std::greater<int>())(vec2);
+ BOOST_TEST(vec2.back() == 1);
+ vec2.pop_back();
+ boost::phoenix::sort_heap(arg1, std::greater<int>())(vec2);
+ int expected_result2[] = {5,4,3,2};
+ BOOST_TEST(std::equal(vec2.begin(), vec2.end(), expected_result2));
+
+ return;
+ }
+
+ void next_permutation_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2};
+ int expected_result[] = {2,1};
+ int expected_result2[] = {1,2};
+
+ BOOST_TEST(next_permutation(arg1)(array));
+ BOOST_TEST(std::equal(array, array + 2, expected_result));
+ BOOST_TEST(!next_permutation(arg1)(array));
+ BOOST_TEST(std::equal(array, array + 2, expected_result2));
+
+ std::reverse(array, array + 2);
+ BOOST_TEST(boost::phoenix::next_permutation(arg1, std::greater<int>())(array));
+ BOOST_TEST(std::equal(array, array + 2, expected_result2));
+ BOOST_TEST(!boost::phoenix::next_permutation(arg1, std::greater<int>())(array));
+ BOOST_TEST(std::equal(array, array + 2, expected_result));
+ return;
+ }
+
+ void prev_permutation_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {2,1};
+ int expected_result[] = {1,2};
+ int expected_result2[] = {2,1};
+
+ BOOST_TEST(prev_permutation(arg1)(array));
+ BOOST_TEST(std::equal(array, array + 2, expected_result));
+ BOOST_TEST(!prev_permutation(arg1)(array));
+ BOOST_TEST(std::equal(array, array + 2, expected_result2));
+
+ std::reverse(array, array + 2);
+ BOOST_TEST(boost::phoenix::prev_permutation(arg1, std::greater<int>())(array));
+ BOOST_TEST(std::equal(array, array + 2, expected_result2));
+ BOOST_TEST(!boost::phoenix::prev_permutation(arg1, std::greater<int>())(array));
+ BOOST_TEST(std::equal(array, array + 2, expected_result));
+ return;
+ }
+
+ void inner_product_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int lhs[] = {1,2,3};
+ int rhs[] = {4,5,6};
+ BOOST_TEST(inner_product(arg1, arg2, 0)
+ (lhs, rhs) == 1*4 + 2*5 + 3*6);
+ BOOST_TEST(boost::phoenix::inner_product(arg1, arg2, 1, std::multiplies<int>(), std::minus<int>())
+ (lhs, rhs) == (1 - 4) * (2 - 5) * (3 - 6));
+ return;
+ }
+
+ void partial_sum_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int output[3];
+ BOOST_TEST(partial_sum(arg1, arg2)(array, output) == output + 3);
+ int expected_result[] = {1, 3, 6};
+ BOOST_TEST(std::equal(output, output + 3, expected_result));
+
+ BOOST_TEST(boost::phoenix::partial_sum(arg1, arg2, std::multiplies<int>())
+ (array, output) == output + 3);
+ int expected_result2[] = {1, 2, 6};
+ BOOST_TEST(std::equal(output, output + 3, expected_result2));
+ return;
+ }
+
+ void adjacent_difference_test()
+ {
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ int array[] = {1,2,3};
+ int output[3];
+ BOOST_TEST(adjacent_difference(arg1, arg2)(array, output) == output + 3);
+ int expected_result[] = {1, 1, 1};
+ BOOST_TEST(std::equal(output, output + 3, expected_result));
+ BOOST_TEST(boost::phoenix::adjacent_difference(arg1, arg2, std::plus<int>())
+ (array, output) == output + 3);
+ int expected_result2[] = {1, 3, 5};
+ BOOST_TEST(std::equal(output, output + 3, expected_result2));
+ return;
+ }
+
+}
+
+int main()
+{
+ heap_test();
+ next_permutation_test();
+ prev_permutation_test();
+ inner_product_test();
+ partial_sum_test();
+ adjacent_difference_test();
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_function_object_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_function_object_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,124 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <cmath>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/bind.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+ struct test
+ {
+ typedef void result_type;
+ void operator()() const
+ {
+ cout << "Test lazy functions...\n";
+ }
+ };
+
+ struct sqr
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Arg>
+ struct result<This(Arg&)>
+ {
+ typedef Arg type;
+ };
+
+ template <typename Arg>
+ Arg operator()(Arg n) const
+ {
+ std::cout << boost::is_reference< Arg >::value << " <-- Arg is reference :(\n";
+ return n * n;
+ }
+ };
+
+ struct fact
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Arg>
+ struct result<This(Arg&)>
+ {
+ typedef Arg type;
+ };
+
+ template <typename Arg>
+ Arg operator()(Arg n) const
+ {
+ return (n <= 0) ? 1 : n * (*this)(n-1);
+ }
+ };
+
+ struct power
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Arg1, typename Arg2>
+ struct result<This(Arg1&, Arg2&)>
+ {
+ typedef Arg1 type;
+ };
+
+ template <typename Arg1, typename Arg2>
+ Arg1 operator()(Arg1 a, Arg2 b) const
+ {
+ return pow(a, b);
+ }
+ };
+
+ /*
+ struct add
+ {
+ template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ struct result
+ {
+ typedef Arg1 type;
+ };
+
+ template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ Arg1 operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const
+ {
+ return a + b + c + d;
+ }
+ };
+ */
+
+int
+main()
+{
+ int i5 = 5;
+ double d5 = 5, d3 = 3;
+
+ test()();
+ BOOST_TEST(bind(sqr(), arg1)(i5) == (i5*i5));
+ BOOST_TEST(bind(fact(), 4)(0) == 24);
+ BOOST_TEST(bind(fact(), arg1)(i5) == 120);
+ BOOST_TEST((int)bind(power(), arg1, arg2)(d5, d3) == (int)pow(d5, d3));
+ BOOST_TEST((bind(sqr(), arg1) + 5)(i5) == ((i5*i5)+5));
+ //BOOST_TEST(bind(add(), arg1, arg1, arg1, arg1)(i5) == (5+5+5+5)); // not implemented yet
+
+ int const ic5 = 5;
+ // testing consts
+ BOOST_TEST(bind(sqr(), arg1)(ic5) == (ic5*ic5));
+
+ // From Steven Watanabe
+ sqr s;
+ int x = 2;
+ int result = bind(ref(s), _1)(x);
+ BOOST_TEST(result == 4);
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_function_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_function_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,57 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <cmath>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/bind.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+namespace test
+{
+ void
+ test()
+ {
+ cout << "Test binding functions...\n";
+ }
+
+ int
+ negate(int n)
+ {
+ return -n;
+ }
+
+ int
+ plus(int a, int b)
+ {
+ return a + b;
+ }
+
+ int
+ plus4(int a, int b, int c, int d)
+ {
+ return a + b + c + d;
+ }
+}
+
+int
+main()
+{
+ int a = 123;
+ int b = 256;
+
+ bind(test::test)(0);
+ BOOST_TEST(bind(test::negate, arg1)(a) == -a);
+ BOOST_TEST(bind(test::plus, arg1, arg2)(a, b) == a+b);
+ //BOOST_TEST(bind(test::plus4, arg1, arg2, 3, 4)(a, b) == a+b+3+4);
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_member_function_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_member_function_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,78 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <cmath>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/bind.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+namespace phx = boost::phoenix;
+
+namespace test
+{
+ struct x : boost::noncopyable // test non-copyable (hold this by reference)
+ {
+ void
+ test() const
+ {
+ cout << "Test binding member functions...\n";
+ }
+ };
+
+ struct y : boost::noncopyable // test non-copyable (hold this by reference)
+ {
+ int
+ negate(int n) const
+ {
+ return -n;
+ }
+ };
+
+ struct z : boost::noncopyable // test non-copyable (hold this by reference)
+ {
+ int
+ plus(int a, int b) const
+ {
+ return a + b;
+ }
+ };
+
+ struct zz : boost::noncopyable // test non-copyable (hold this by reference)
+ {
+ int
+ plus3(int a, int b, int c)
+ {
+ return a + b + c;
+ }
+ };
+}
+
+int
+main()
+{
+ int a = 123;
+ int b = 256;
+ test::x x_;
+ test::y y_;
+ test::z z_;
+ test::zz zz_;
+
+ //bind(&test::x::test, x_)(0); // <- original test, fails due to attempt of copying
+ bind(&test::x::test, ref(x_))(0);
+ //BOOST_TEST(bind(&test::y::negate, y_, arg1)(a) == -a); // same as above
+ BOOST_TEST(bind(&test::y::negate, ref(y_), arg1)(a) == -a);
+ //BOOST_TEST(bind(&test::z::plus, arg1, arg2, arg3)(z_, a, b) == a+b);
+ //BOOST_TEST(bind(&test::zz::plus3, zz_, arg1, arg2, arg3)(a, b, a) == a+b+a);
+ BOOST_TEST(bind(&test::y::negate, &y_, 777)(a) == -777);
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_member_variable_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/bind/bind_member_variable_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,103 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <cmath>
+#include <boost/noncopyable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/bind.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+namespace phx = boost::phoenix;
+
+namespace test
+{
+ struct x : boost::noncopyable // test non-copyable (hold this by reference)
+ {
+ int m;
+ };
+
+ struct xx {
+ int m;
+ };
+}
+
+template<class T, class F>
+void write_test(F f) {
+ T x_;
+ bind(&T::m, f(x_))(0) = 122;
+ BOOST_TEST(x_.m == 122);
+ bind(&T::m, arg1)(f(x_)) = 123;
+ BOOST_TEST(x_.m == 123);
+}
+
+template<class T, class F>
+void read_test(F f) {
+ T x_;
+ x_.m = 123;
+
+ BOOST_TEST(bind(&T::m, f(x_))(0) == 123);
+ BOOST_TEST(bind(&T::m, arg1)(f(x_)) == 123);
+}
+
+struct identity
+{
+ template<class T>
+ T& operator()(T& t) const
+ {
+ return t;
+ }
+};
+
+struct constify
+{
+ template<class T>
+ const T& operator()(const T& t) const
+ {
+ return t;
+ }
+};
+
+struct add_pointer
+{
+ template<class T>
+ T* const operator()(T& t) const
+ {
+ return &t;
+ }
+};
+
+struct add_const_pointer
+{
+ template<class T>
+ const T* const operator()(const T& t) const
+ {
+ return &t;
+ }
+};
+
+int
+main()
+{
+ //write_test<test::x>(identity());
+ write_test<test::x>(add_pointer());
+ //write_test<test::xx>(identity());
+ write_test<test::xx>(add_pointer());
+
+ //read_test<test::x>(identity());
+ //read_test<test::x>(constify()); // this fails because of capture by value.
+ read_test<test::x>(add_pointer());
+ read_test<test::x>(add_const_pointer());
+ //read_test<test::xx>(identity());
+ //read_test<test::xx>(constify());// this fails because of capture by value.
+ read_test<test::xx>(add_pointer());
+ read_test<test::xx>(add_const_pointer());
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests.hpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,814 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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)
+==============================================================================*/
+#if !defined(CONTAINER_TESTS_HPP)
+#define CONTAINER_TESTS_HPP
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/home/phoenix/stl/container/container.hpp>
+
+#include <iostream>
+#include <typeinfo>
+#include <deque>
+#include <list>
+#include <map>
+#include <vector>
+#include <utility>
+
+#ifdef BOOST_MSVC
+#pragma warning(disable : 4800)
+#endif
+
+using std::cerr;
+namespace phx = boost::phoenix;
+
+std::deque<int> const build_deque();
+std::list<int> const build_list();
+std::map<int, int> const build_map();
+std::multimap<int, int> const build_multimap();
+std::vector<int> const build_vector();
+
+inline bool
+test(bool fail)
+{
+ BOOST_TEST(!fail);
+ return fail;
+}
+
+template <typename Container>
+void test_assign(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::assign;
+
+ typename Container::size_type count = 2;
+ typename Container::const_iterator first = c.begin();
+ typename Container::const_iterator second = first;
+ typename Container::value_type value = *first;
+
+ assign(arg1, count, value)(c);
+
+ // iterators may be invalidated!
+ first = c.begin();
+ second = first;
+
+ std::advance(second, 1);
+ if (test(*first != *second)) {
+ cerr << "Failed " << typeid(Container).name() << " test_assign 1\n";
+ return;
+ }
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ Container const const_c = c;
+ assign(const_c, count, value);
+#endif
+}
+
+template <typename Container>
+void test_assign2(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::arg_names::arg2;
+ using phx::arg_names::arg3;
+ using phx::assign;
+
+ Container c2 = c;
+ typename Container::const_iterator first = c2.begin();
+ typename Container::const_iterator last = c2.end();
+ typename Container::size_type size = c2.size();
+
+ c.clear();
+ assign(arg1, arg2, arg3)(c, first, last);
+ if (test(c.size() != size)) {
+ cerr << "Failed " << typeid(Container).name()
+ << " test_assign2 1\n"
+ << "size == " << c.size() << '\n';
+ return;
+ }
+
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ Container const const_c = c;
+ assign(const_c, first, second);
+#endif
+}
+
+template <typename Container>
+void test_at(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::at;
+
+ typename Container::reference r1 = at(arg1, 0)(c);
+ if (test(r1 != c.at(0))) {
+ cerr << "Failed " << typeid(Container).name() << " test_at 1\n";
+ return;
+ }
+
+ typename Container::const_reference r2 = at(arg1, 0)(c);
+ if (test(r2 != c.at(0))) {
+ cerr << "Failed " << typeid(Container).name() << " test_at 2\n";
+ return;
+ }
+
+ Container const const_c = c;
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ typename Container::reference r3 = at(arg1, 0)(const_c);
+#endif
+
+ typename Container::const_reference r4 = at(arg1, 0)(const_c);
+ if (test(r4 != c.at(0))) {
+ cerr << "Failed " << typeid(Container).name() << " test_at 4\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_back(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::back;
+
+ typename Container::reference r1 = back(arg1)(c);
+ if (test(r1 != c.back())) {
+ cerr << "Failed " << typeid(Container).name() << " test_back 1\n";
+ return;
+ }
+ typename Container::const_reference r2 = back(arg1)(c);
+ if (test(r2 != c.back())) {
+ cerr << "Failed " << typeid(Container).name() << " test_back 2\n";
+ return;
+ }
+
+ Container const const_c = c;
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ typename Container::reference r3 = back(arg1)(const_c);
+#endif
+
+ typename Container::const_reference r4 = back(arg1)(const_c);
+ if (test(r4 != c.back())) {
+ cerr << "Failed " << typeid(Container).name() << " test_back 4\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_begin(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::begin;
+
+ typename Container::iterator it1 = begin(arg1)(c);
+ if (test(it1 != c.begin())) {
+ cerr << "Failed " << typeid(Container).name() << " test_begin 1\n";
+ return;
+ }
+ typename Container::const_iterator it2 = begin(arg1)(c);
+ if (test(it2 != c.begin())) {
+ cerr << "Failed " << typeid(Container).name() << " test_begin 2\n";
+ return;
+ }
+
+ Container const const_c = c;
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ typename Container::iterator it3 = begin(arg1)(const_c);
+#endif
+
+ typename Container::const_iterator it4 = begin(arg1)(const_c);
+ if (test(it4 != const_c.begin())) {
+ cerr << "Failed " << typeid(Container).name() << " test_begin 4\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_capacity(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::capacity;
+
+ typename Container::size_type s1 = capacity(arg1)(c);
+ if (test(s1 != c.capacity())) {
+ cerr << "Failed " << typeid(Container).name() << " test_capacity 1\n";
+ return;
+ }
+
+ Container const const_c = c;
+ typename Container::size_type s2 = capacity(arg1)(const_c);
+ if (test(s2 != const_c.capacity())) {
+ cerr << "Failed " << typeid(Container).name() << " test_capacity 2\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_clear(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::clear;
+
+ clear(arg1)(c);
+ if (test(!c.empty())) {
+ cerr << "Failed " << typeid(Container).name() << " test_clear 1\n";
+ return;
+ }
+
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ Container const const_c = c;
+ clear(arg1)(const_c);
+#endif
+}
+
+template <typename Container>
+void test_empty(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::empty;
+
+ typename Container::size_type s1 = empty(arg1)(c);
+ if (test(bool(s1) != c.empty())) {
+ cerr << "Failed " << typeid(Container).name() << " test_empty 1\n";
+ return;
+ }
+
+ Container const const_c = c;
+ typename Container::size_type s2 = empty(arg1)(const_c);
+ if (test(bool(s2) != const_c.empty())) {
+ cerr << "Failed " << typeid(Container).name() << " test_empty 2\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_end(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::end;
+
+ typename Container::iterator it1 = end(arg1)(c);
+ if (test(it1 != c.end())) {
+ cerr << "Failed " << typeid(Container).name() << " test_end 1\n";
+ return;
+ }
+ typename Container::const_iterator it2 = end(arg1)(c);
+ if (test(it2 != c.end())) {
+ cerr << "Failed " << typeid(Container).name() << " test_end 2\n";
+ return;
+ }
+
+ Container const const_c = c;
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ typename Container::iterator it3 = end(arg1)(const_c);
+#endif
+
+ typename Container::const_iterator it4 = end(arg1)(const_c);
+ if (test(it4 != const_c.end())) {
+ cerr << "Failed " << typeid(Container).name() << " test_end 4\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_erase(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::arg_names::arg2;
+ using phx::arg_names::arg3;
+ using phx::erase;
+
+ Container const const_c = c;
+
+ typename Container::size_type size = c.size();
+ typename Container::iterator c_begin = c.begin();
+ erase(arg1, arg2)(c, c_begin);
+ if (test(c.size() + 1 != size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_erase 1\n";
+ return;
+ }
+
+ c_begin = c.begin();
+ typename Container::iterator c_end = c.end();
+ erase(arg1, arg2, arg3)(c, c_begin, c_end);
+ if (test(!c.empty())) {
+ cerr << "Failed " << typeid(Container).name() << " test_erase 2\n";
+ return;
+ }
+
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ erase(arg1, const_c.begin())(const_c);
+ erase(arg1, const_c.begin(), const_c.end())(const_c);
+#endif
+}
+
+template <typename Container>
+void test_map_erase(Container c)
+{
+ test_erase(c);
+ if (boost::report_errors() != 0)
+ return;
+
+ using phx::arg_names::arg1;
+ using phx::arg_names::arg2;
+ using phx::erase;
+
+ typename Container::value_type const value = *c.begin();
+ typename Container::key_type const key = value.first;
+ typename Container::size_type const removed =
+ erase(arg1, arg2)(c, key);
+ if (test(removed != 1)) {
+ cerr << "Failed " << typeid(Container).name() << " test_map_erase 1\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_front(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::front;
+
+ typename Container::reference r1 = front(arg1)(c);
+ if (test(r1 != c.front())) {
+ cerr << "Failed " << typeid(Container).name() << " test_front 1\n";
+ return;
+ }
+ typename Container::const_reference r2 = front(arg1)(c);
+ if (test(r2 != c.front())) {
+ cerr << "Failed " << typeid(Container).name() << " test_front 2\n";
+ return;
+ }
+
+ Container const const_c = c;
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ typename Container::reference r3 = front(arg1)(const_c);
+#endif
+
+ typename Container::const_reference r4 = front(arg1)(const_c);
+ if (test(r4 != c.front())) {
+ cerr << "Failed " << typeid(Container).name() << " test_front 4\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_get_allocator(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::get_allocator;
+
+ Container const const_c = c;
+
+ typename Container::allocator_type a1 = get_allocator(arg1)(c);
+ if (test(a1 != c.get_allocator())) {
+ cerr << "Failed " << typeid(Container).name() << " test_get_allocator 1\n";
+ return;
+ }
+
+ typename Container::allocator_type a2 = get_allocator(arg1)(const_c);
+ if (test(a2 != const_c.get_allocator())) {
+ cerr << "Failed " << typeid(Container).name() << " test_get_allocator 2\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_insert(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::insert;
+
+ typename Container::value_type const value = *c.begin();
+ typename Container::iterator it = insert(arg1, c.begin(), value)(c);
+ if (test(it != c.begin() || *it != *(++it))) {
+ cerr << "Failed " << typeid(Container).name() << " test_insert 1\n";
+ return;
+ }
+
+ typename Container::size_type size = c.size();
+ insert(arg1, c.begin(), 3, value)(c);
+ if (test(c.size() != size + 3)) {
+ cerr << "Failed " << typeid(Container).name() << " test_insert 2\n";
+ return;
+ }
+
+ Container const const_c = c;
+ size = c.size();
+ insert(arg1, c.begin(), const_c.begin(), const_c.end())(c);
+ if (test(c.size() != 2 * size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_insert 3\n";
+ return;
+ }
+}
+
+inline void test_map_insert(std::map<int, int> c)
+{
+ using phx::arg_names::arg1;
+ using phx::arg_names::arg2;
+ using phx::arg_names::arg3;
+
+ typedef std::map<int, int> Map;
+
+ Map::value_type const value = *c.begin();
+ Map::iterator c_begin = c.begin();
+ // wrapper for
+ // iterator insert(iterator where, const value_type& val);
+ Map::iterator it =
+ phx::insert(arg1, arg2, arg3)(c, c_begin, value);
+
+ if (test(it != c.begin() /*|| *it != *(++it)*/)) {
+ cerr << "Failed " << typeid(Map).name() << " test_map_insert 1\n";
+ return;
+ }
+
+ // wrapper for
+ // pair<iterator, bool> insert(const value_type& val);
+ Map::value_type const value2(1400, 2200);
+ std::pair<Map::iterator, bool> result =
+ phx::insert(arg1, arg2)(c, value2);
+ if (test(!result.second)) {
+ cerr << "Failed " << typeid(Map).name() << " test_map_insert 2\n";
+ return;
+ }
+
+ // wrapper for
+ // template<class InIt>
+ // void insert(InIt first, InIt last);
+ Map const const_c = build_map();
+ Map::size_type size = c.size();
+ phx::insert(arg1, const_c.begin(), const_c.end())(c);
+ if (test(c.size() != size + const_c.size())) {
+ cerr << "Failed " << typeid(Map).name() << " test_map_insert 3\n";
+ return;
+ }
+}
+
+inline void test_multimap_insert(std::multimap<int, int> c)
+{
+ using phx::arg_names::arg1;
+ using phx::arg_names::arg2;
+ using phx::arg_names::arg3;
+
+ typedef std::multimap<int, int> Multimap;
+
+ Multimap::value_type const value = *c.begin();
+ Multimap::iterator c_begin = c.begin();
+ // wrapper for
+ // iterator insert(iterator where, const value_type& val);
+ Multimap::iterator it =
+ phx::insert(arg1, arg2, arg3)(c, c_begin, value);
+
+ if (test(it != c.begin() || *it != *(++it))) {
+ cerr << "Failed " << typeid(Multimap).name()
+ << " test_multimap_insert 1\n";
+ return;
+ }
+
+ // wrapper for
+ // iterator insert(const value_type& val);
+ Multimap::value_type const value2(1400, 2200);
+ it = phx::insert(arg1, arg2)(c, value2);
+ if (test(it == c.end())) {
+ cerr << "Failed " << typeid(Multimap).name()
+ << " test_multimap_insert 2\n";
+ return;
+ }
+
+ // wrapper for
+ // template<class InIt>
+ // void insert(InIt first, InIt last);
+ Multimap const const_c = build_multimap();
+ Multimap::size_type size = c.size();
+ phx::insert(arg1, const_c.begin(), const_c.end())(c);
+ if (test(c.size() != size + const_c.size())) {
+ cerr << "Failed " << typeid(Multimap).name()
+ << " test_multimap_insert 3\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_key_comp(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::key_comp;
+
+ typename Container::key_compare comp = key_comp(arg1)(c);
+
+ Container const const_c = c;
+ comp = key_comp(arg1)(const_c);
+}
+
+template <typename Container>
+void test_max_size(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::max_size;
+
+ Container const const_c = c;
+
+ typename Container::size_type s1 = max_size(arg1)(c);
+ if (test(s1 != c.max_size())) {
+ cerr << "Failed " << typeid(Container).name() << " test_max_size 1\n";
+ return;
+ }
+
+ typename Container::size_type s2 = max_size(arg1)(const_c);
+ if (test(s2 != const_c.max_size())) {
+ cerr << "Failed " << typeid(Container).name() << " test_max_size 2\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_pop_back(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::pop_back;
+
+ Container const const_c = c;
+
+ typename Container::size_type size = c.size();
+
+ pop_back(arg1)(c);
+ if (test(c.size() + 1 != size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_pop_back 1\n";
+ return;
+ }
+
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ pop_back(arg1)(const_c);
+#endif
+}
+
+template <typename Container>
+void test_pop_front(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::pop_front;
+
+ Container const const_c = c;
+
+ typename Container::size_type size = c.size();
+
+ pop_front(arg1)(c);
+ if (test(c.size() + 1 != size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_pop_front 1\n";
+ return;
+ }
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ pop_front(arg1)(const_c);
+#endif
+}
+
+template <typename Container>
+void test_push_back(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::arg_names::arg2;
+ using phx::push_back;
+
+ Container const const_c = c;
+
+ typename Container::value_type data = *c.begin();
+ typename Container::size_type size = c.size();
+ push_back(arg1, arg2)(c, data);
+ if (test(c.size() != size + 1)) {
+ cerr << "Failed " << typeid(Container).name() << " test_push_back 1\n";
+ return;
+ }
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ push_back(arg1, arg2)(const_c, data);
+#endif
+}
+
+template <typename Container>
+void test_push_front(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::arg_names::arg2;
+ using phx::push_front;
+
+ Container const const_c = c;
+
+ typename Container::value_type data = *c.begin();
+ typename Container::size_type size = c.size();
+ push_front(arg1, arg2)(c, data);
+ if (test(c.size() != size + 1)) {
+ cerr << "Failed " << typeid(Container).name() << " test_push_front 1\n";
+ return;
+ }
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ push_front(arg1, arg2)(const_c, data);
+#endif
+}
+
+template <typename Container>
+void test_rbegin(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::rbegin;
+
+ typename Container::reverse_iterator it1 = rbegin(arg1)(c);
+ typename Container::reverse_iterator it1_test = c.rbegin();
+ if (test(it1 != it1_test)) {
+ cerr << "Failed " << typeid(Container).name() << " test_rbegin 1\n";
+ return;
+ }
+ typename Container::const_reverse_iterator it2 = rbegin(arg1)(c);
+ typename Container::const_reverse_iterator it2_test = c.rbegin();
+ if (test(it2 != it2_test)) {
+ cerr << "Failed " << typeid(Container).name() << " test_rbegin 2\n";
+ return;
+ }
+
+ Container const const_c = c;
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ typename Container::reverse_iterator it3 = rbegin(arg1)(const_c);
+#endif
+
+ typename Container::const_reverse_iterator it4 = rbegin(arg1)(const_c);
+ it2_test = const_c.rbegin();
+ if (test(it4 != it2_test)) {
+ cerr << "Failed " << typeid(Container).name() << " test_rbegin 4\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_rend(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::rend;
+
+ typename Container::reverse_iterator it1 = rend(arg1)(c);
+ typename Container::reverse_iterator it1_test = c.rend();
+ if (test(it1 != it1_test)) {
+ cerr << "Failed " << typeid(Container).name() << " test_rend 1\n";
+ return;
+ }
+ typename Container::const_reverse_iterator it2 = rend(arg1)(c);
+ typename Container::const_reverse_iterator it2_test = c.rend();
+ if (test(it2 != it2_test)) {
+ cerr << "Failed " << typeid(Container).name() << " test_rend 2\n";
+ return;
+ }
+
+ Container const const_c = c;
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ // Should not --- does not, Yay! --- compile.
+ typename Container::reverse_iterator it3 = rend(arg1)(const_c);
+#endif
+
+ typename Container::const_reverse_iterator it4 = rend(arg1)(const_c);
+ it2_test = const_c.rend();
+ if (test(it4 != it2_test)) {
+ cerr << "Failed " << typeid(Container).name() << " test_rend 4\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_reserve(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::reserve;
+
+ Container const const_c = c;
+
+ typename Container::size_type count = 2 * c.size();
+ reserve(arg1, count)(c);
+ if (test(c.capacity() < count)) {
+ cerr << "Failed " << typeid(Container).name() << " test_reserve 1\n";
+ return;
+ }
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ reserve(arg1, count)(const_c)(const_c);
+#endif
+}
+
+template <typename Container>
+void test_resize(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::resize;
+
+ Container const const_c = c;
+
+ typename Container::size_type new_size = 2 * c.size();
+ resize(arg1, new_size)(c);
+ if (test(c.size() != new_size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_resize 1\n";
+ return;
+ }
+
+ new_size = 2 * c.size();
+ typename Container::value_type value = *c.begin();
+ resize(arg1, new_size, value)(c);
+ if (test(c.size() != new_size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_resize 2\n";
+ return;
+ }
+#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST)
+ new_size = 2 * const_c.size();
+ resize(arg1, new_size)(const_c);
+
+ new_size = 2 * const_c.size();
+ resize(arg1, new_size, value)(const_c);
+#endif
+}
+
+template <typename Container>
+void test_size(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::size;
+
+ Container const const_c = c;
+
+ typename Container::size_type s1 = size(arg1)(c);
+ if (test(s1 != c.size())) {
+ cerr << "Failed " << typeid(Container).name() << " test_size 1\n";
+ return;
+ }
+
+ typename Container::size_type s2 = size(arg1)(const_c);
+ if (test(s2 != const_c.size())) {
+ cerr << "Failed " << typeid(Container).name() << " test_size 2\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_splice(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::arg_names::arg2;
+ using phx::arg_names::arg3;
+ using phx::arg_names::arg4;
+ using phx::arg_names::arg5;
+ using phx::splice;
+
+ typename Container::iterator c_end;
+ typename Container::iterator c2_begin;
+ typename Container::iterator c2_end;
+ typename Container::size_type size = c.size();
+
+ Container const copy = c;
+ Container const copy2 = build_list();
+ Container c2 = copy2;
+
+ size = c.size();
+ c_end = c.end();
+ splice(arg1, arg2, arg3)(c, c_end, c2);
+ if (test(c.size() != 2 * size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_splice 1\n";
+ return;
+ }
+
+ c = copy;
+ c_end = c.end();
+ c2 = copy2;
+ c2_begin = c2.begin();
+ size = c.size() + 1;
+ splice(arg1, arg2, arg3, arg4)(c, c_end, c2, c2_begin);
+ if (test(c.size() != size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_splice 2\n";
+ return;
+ }
+
+ c = copy;
+ c_end = c.end();
+ c2 = copy2;
+ c2_begin = c2.begin();
+ c2_end = c2.end();
+ size = c.size() + c2.size();
+ splice(arg1, arg2, arg3, arg4, arg5)(c, c_end, c2, c2_begin, c2_end);
+ if (test(c.size() != size)) {
+ cerr << "Failed " << typeid(Container).name() << " test_splice 3\n";
+ return;
+ }
+}
+
+template <typename Container>
+void test_value_comp(Container c)
+{
+ using phx::arg_names::arg1;
+ using phx::value_comp;
+
+ typename Container::value_compare comp = value_comp(arg1)(c);
+
+ Container const const_c = c;
+ comp = value_comp(arg1)(const_c);
+}
+
+#endif
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests1a.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests1a.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,46 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+
+std::list<int> const build_list()
+{
+ std::vector<int> const data = build_vector();
+ return std::list<int>(data.begin(), data.end());
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::list<int> const data = build_list();
+ test_assign(data);
+ test_assign2(data);
+ test_back(data);
+ test_begin(data);
+ test_clear(data);
+ return boost::report_errors();
+}
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests1b.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests1b.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,48 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+
+std::list<int> const build_list()
+{
+ std::vector<int> const data = build_vector();
+ return std::list<int>(data.begin(), data.end());
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::list<int> const data = build_list();
+ test_empty(data);
+ test_end(data);
+ test_erase(data);
+ test_front(data);
+ test_get_allocator(data);
+ test_insert(data);
+ test_max_size(data);
+ return boost::report_errors();
+}
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests2a.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests2a.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,46 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+
+std::list<int> const build_list()
+{
+ std::vector<int> const data = build_vector();
+ return std::list<int>(data.begin(), data.end());
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::list<int> const data = build_list();
+ test_pop_back(data);
+ test_pop_front(data);
+ test_push_back(data);
+ test_push_front(data);
+ return boost::report_errors();
+}
+
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests2b.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests2b.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,47 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+
+std::list<int> const build_list()
+{
+ std::vector<int> const data = build_vector();
+ return std::list<int>(data.begin(), data.end());
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::list<int> const data = build_list();
+ test_rbegin(data);
+ test_rend(data);
+ test_resize(data);
+ test_size(data);
+ test_splice(data);
+ return boost::report_errors();
+}
+
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests3a.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests3a.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,60 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+#include <boost/static_assert.hpp>
+
+std::map<int, int> const build_map()
+{
+ typedef std::map<int, int> int_map;
+ typedef std::vector<int> int_vector;
+
+ int_map result;
+ int_vector const data = build_vector();
+ int_vector::const_iterator it = data.begin();
+ int_vector::const_iterator const end = data.end();
+ for (; it != end; ++it) {
+ int const value = *it;
+ result[value] = 100 * value;
+ }
+ return result;
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::map<int, int> >::value));
+
+ std::map<int, int> const data = build_map();
+ test_begin(data);
+ test_clear(data);
+ test_empty(data);
+ test_end(data);
+ test_map_erase(data);
+ test_get_allocator(data);
+ return boost::report_errors();
+}
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests3b.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests3b.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,61 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+#include <boost/static_assert.hpp>
+
+std::map<int, int> const build_map()
+{
+ typedef std::map<int, int> int_map;
+ typedef std::vector<int> int_vector;
+
+ int_map result;
+ int_vector const data = build_vector();
+ int_vector::const_iterator it = data.begin();
+ int_vector::const_iterator const end = data.end();
+ for (; it != end; ++it) {
+ int const value = *it;
+ result[value] = 100 * value;
+ }
+ return result;
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::map<int, int> >::value));
+
+ std::map<int, int> const data = build_map();
+ test_map_insert(data);
+ test_key_comp(data);
+ test_max_size(data);
+ test_rbegin(data);
+ test_rend(data);
+ test_size(data);
+ test_value_comp(data);
+ return boost::report_errors();
+}
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests4a.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests4a.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,47 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+#include <boost/static_assert.hpp>
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::vector<int> const data = build_vector();
+ test_assign(data);
+ test_assign2(data);
+ test_at(data);
+ test_back(data);
+ test_begin(data);
+ test_capacity(data);
+ test_clear(data);
+ test_end(data);
+ test_empty(data);
+ test_erase(data);
+ test_front(data);
+ return boost::report_errors();
+}
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests4b.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests4b.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,46 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+#include <boost/static_assert.hpp>
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::vector<int> const data = build_vector();
+ test_get_allocator(data);
+ test_insert(data);
+ test_max_size(data);
+ test_pop_back(data);
+ test_push_back(data);
+ test_rbegin(data);
+ test_rend(data);
+ test_reserve(data);
+ test_resize(data);
+ test_size(data);
+ return boost::report_errors();
+}
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests5a.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests5a.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,53 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+
+std::deque<int> const build_deque()
+{
+ std::vector<int> const data = build_vector();
+ return std::deque<int>(data.begin(), data.end());
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::deque<int> const data = build_deque();
+ test_assign(data);
+ test_assign2(data);
+ test_at(data);
+ test_back(data);
+ test_begin(data);
+ test_clear(data);
+ test_front(data);
+ test_empty(data);
+ test_end(data);
+ test_erase(data);
+ test_get_allocator(data);
+ return boost::report_errors();
+}
+
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests5b.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests5b.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,52 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+
+std::deque<int> const build_deque()
+{
+ std::vector<int> const data = build_vector();
+ return std::deque<int>(data.begin(), data.end());
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::deque<int> const data = build_deque();
+ test_insert(data);
+ test_max_size(data);
+ test_pop_back(data);
+ test_pop_front(data);
+ test_push_back(data);
+ test_push_front(data);
+ test_rbegin(data);
+ test_rend(data);
+ test_resize(data);
+ test_size(data);
+ return boost::report_errors();
+}
+
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests6a.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests6a.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,69 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+#include <boost/static_assert.hpp>
+
+std::map<int, int> const build_map()
+{
+ typedef std::map<int, int> int_map;
+ typedef std::vector<int> int_vector;
+
+ int_map result;
+ int_vector const data = build_vector();
+ int_vector::const_iterator it = data.begin();
+ int_vector::const_iterator const end = data.end();
+ for (; it != end; ++it) {
+ int const value = *it;
+ result[value] = 100 * value;
+ }
+ return result;
+}
+
+std::multimap<int, int> const build_multimap()
+{
+ typedef std::map<int, int> int_map;
+ typedef std::multimap<int, int> int_multimap;
+ int_map const data = build_map();
+ return int_multimap(data.begin(), data.end());
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::multimap<int, int> const data = build_multimap();
+ test_begin(data);
+ test_clear(data);
+ test_empty(data);
+ test_end(data);
+ test_map_erase(data);
+ test_get_allocator(data);
+ return boost::report_errors();
+}
+
+
+
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests6b.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/container/container_tests6b.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,70 @@
+/*=============================================================================
+ Copyright (c) 2004 Angus Leeming
+
+ 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 "container_tests.hpp"
+#include <boost/static_assert.hpp>
+
+std::map<int, int> const build_map()
+{
+ typedef std::map<int, int> int_map;
+ typedef std::vector<int> int_vector;
+
+ int_map result;
+ int_vector const data = build_vector();
+ int_vector::const_iterator it = data.begin();
+ int_vector::const_iterator const end = data.end();
+ for (; it != end; ++it) {
+ int const value = *it;
+ result[value] = 100 * value;
+ }
+ return result;
+}
+
+std::multimap<int, int> const build_multimap()
+{
+ typedef std::map<int, int> int_map;
+ typedef std::multimap<int, int> int_multimap;
+ int_map const data = build_map();
+ return int_multimap(data.begin(), data.end());
+}
+
+std::vector<int> const init_vector()
+{
+ typedef std::vector<int> int_vector;
+ int const data[] = { -4, -3, -2, -1, 0 };
+ int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
+ return int_vector(data, data + data_size);
+}
+
+std::vector<int> const build_vector()
+{
+ typedef std::vector<int> int_vector;
+ static int_vector data = init_vector();
+ int_vector::size_type const size = data.size();
+ int_vector::iterator it = data.begin();
+ int_vector::iterator const end = data.end();
+ for (; it != end; ++it)
+ *it += size;
+ return data;
+}
+
+int
+main()
+{
+ std::multimap<int, int> const data = build_multimap();
+ test_multimap_insert(data);
+ test_key_comp(data);
+ test_max_size(data);
+ test_rbegin(data);
+ test_rend(data);
+ test_size(data);
+ test_value_comp(data);
+ return boost::report_errors();
+}
+
+
+
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/core/compose_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/core/compose_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,84 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+struct X
+{
+ template <
+ typename Env
+ , typename A0 = void_
+ , typename A1 = void_
+ , typename A2 = void_
+ >
+ struct result
+ {
+ typedef int type;
+ };
+
+ template <typename RT, typename Env
+ , typename A0, typename A1, typename A2>
+ static RT
+ eval(Env const& env, A0& a0, A1& a1, A2& a2)
+ {
+ return a0.eval(env) + a1.eval(env) + a2.eval(env);
+ }
+};
+
+int
+main()
+{
+ using boost::fusion::at_c;
+ {
+ // testing as_actor
+ BOOST_STATIC_ASSERT((boost::is_same<
+ as_actor<actor<argument<0> > >::type, actor<argument<0> > >::value));
+ BOOST_STATIC_ASSERT((boost::is_same<
+ as_actor<int>::type, actor<value<int> > >::value));
+ }
+
+ {
+ // testing compose
+ char const* s = "Hi";
+ int x = 123;
+
+ BOOST_TEST(at_c<0>(compose<X>(1, arg1, val(1)))
+ .eval(basic_environment<>()) == 1);
+ BOOST_TEST(at_c<1>(compose<X>(1, arg1, val(456)))
+ .eval(basic_environment<char const*>(s)) == s);
+ BOOST_TEST(at_c<2>(compose<X>(1, arg1, val(456)))
+ .eval(basic_environment<>()) == 456);
+ BOOST_TEST(compose<X>(9876, arg1, val(456))
+ .eval(basic_environment<int>(x)) == 10455);
+
+ // testing composite sizes
+ cout << "sizeof(arg1) is: "
+ << sizeof(arg1) << endl;
+ cout << "sizeof(compose<X>(arg1)) is: "
+ << sizeof(compose<X>(arg1)) << endl;
+ cout << "sizeof(compose<X>(1, arg1, val(456))) is: "
+ << sizeof(compose<X>(1, arg1, val(456))) << endl;
+ cout << "sizeof(compose<X>()) is: "
+ << sizeof(compose<X>()) << endl;
+ cout << "sizeof(compose<X>('x')) is: "
+ << sizeof(compose<X>('x')) << endl;
+ cout << "sizeof(compose<X>('x', 3)) is: "
+ << sizeof(compose<X>('x', 3)) << endl;
+ cout << "sizeof(compose<X>('x', 'y', 3)) is: "
+ << sizeof(compose<X>('x', 'y', 3)) << endl;
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/core/primitives_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/core/primitives_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,69 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <string>
+
+#include <boost/phoenix/core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ char c1 = '1';
+ int i1 = 1, i2 = 2, i = 4;
+ const char* s2 = "2";
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ // Values, references and arguments
+ //
+ ///////////////////////////////////////////////////////////////////////////
+
+ // argument
+ BOOST_TEST(arg1(c1) == c1);
+ BOOST_TEST(arg1(i1, i2) == i1);
+ BOOST_TEST(arg2(i1, s2) == s2);
+ BOOST_TEST(&(arg1(c1)) == &c1); // must be an lvalue
+
+ // value
+ //cout << val("Hello,")(0) << val(' ')(0) << val("World")(0) << endl;
+ BOOST_TEST(val(3)(0) == 3);
+ //BOOST_TEST(val("Hello, world")(0) == std::string("Hello, world"));
+ //BOOST_TEST(val(_1)(i1) == i1);
+
+ // should not compile:
+#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
+ &val(_1)(i1); // should return an rvalue
+#endif
+
+ // reference
+ BOOST_TEST(cref(i)(0) == ref(i)(0));
+ BOOST_TEST(cref(i)(0) == 4);
+ BOOST_TEST(i == 4);
+ BOOST_TEST(ref(++i)(0) == 5);
+ BOOST_TEST(i == 5);
+
+ // should not compile:
+#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
+ ref(arg1);
+#endif
+
+ // testing consts
+ int const ic = 123;
+ BOOST_TEST(arg1(ic) == 123);
+
+ // should not compile:
+#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
+ arg1();
+#endif
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/detail/type_deduction_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/detail/type_deduction_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,374 @@
+/*=============================================================================
+ Copyright (c) 2001-2003 Joel de Guzman
+
+ 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/spirit/home/phoenix/detail/type_deduction.hpp>
+#include <iostream>
+#include <vector>
+#include <map>
+#include <string>
+#include <complex>
+#include <boost/shared_ptr.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+
+namespace boost
+{
+ BOOST_UNARY_RESULT_OF(-x, result_of_negate);
+ BOOST_UNARY_RESULT_OF(+x, result_of_posit);
+ BOOST_UNARY_RESULT_OF(!x, result_of_logical_not);
+ BOOST_UNARY_RESULT_OF(~x, result_of_invert);
+ BOOST_UNARY_RESULT_OF(&x, result_of_reference);
+ BOOST_UNARY_RESULT_OF(*x, result_of_dereference);
+
+ BOOST_UNARY_RESULT_OF(++x, result_of_pre_increment);
+ BOOST_UNARY_RESULT_OF(--x, result_of_pre_decrement);
+ BOOST_UNARY_RESULT_OF(x++, result_of_post_increment);
+ BOOST_UNARY_RESULT_OF(x--, result_of_post_decrement);
+
+ BOOST_BINARY_RESULT_OF(x = y, result_of_assign);
+ BOOST_ASYMMETRIC_BINARY_RESULT_OF(x[y], result_of_index);
+
+ BOOST_BINARY_RESULT_OF(x += y, result_of_plus_assign);
+ BOOST_BINARY_RESULT_OF(x -= y, result_of_minus_assign);
+ BOOST_BINARY_RESULT_OF(x *= y, result_of_multiplies_assign);
+ BOOST_BINARY_RESULT_OF(x /= y, result_of_divides_assign);
+ BOOST_BINARY_RESULT_OF(x %= y, result_of_modulus_assign);
+
+ BOOST_BINARY_RESULT_OF(x &= y, result_of_and_assign);
+ BOOST_BINARY_RESULT_OF(x |= y, result_of_or_assign);
+ BOOST_BINARY_RESULT_OF(x ^= y, result_of_xor_assign);
+ BOOST_BINARY_RESULT_OF(x <<= y, result_of_shift_left_assign);
+ BOOST_BINARY_RESULT_OF(x >>= y, result_of_shift_right_assign);
+
+ BOOST_BINARY_RESULT_OF(x + y, result_of_plus);
+ BOOST_BINARY_RESULT_OF(x - y, result_of_minus);
+ BOOST_BINARY_RESULT_OF(x * y, result_of_multiplies);
+ BOOST_BINARY_RESULT_OF(x / y, result_of_divides);
+ BOOST_BINARY_RESULT_OF(x % y, result_of_modulus);
+
+ BOOST_BINARY_RESULT_OF(x & y, result_of_and);
+ BOOST_BINARY_RESULT_OF(x | y, result_of_or);
+ BOOST_BINARY_RESULT_OF(x ^ y, result_of_xor);
+ BOOST_BINARY_RESULT_OF(x << y, result_of_shift_left);
+ BOOST_BINARY_RESULT_OF(x >> y, result_of_shift_right);
+
+ BOOST_BINARY_RESULT_OF(x == y, result_of_equal_to);
+ BOOST_BINARY_RESULT_OF(x != y, result_of_not_equal_to);
+ BOOST_BINARY_RESULT_OF(x < y, result_of_less);
+ BOOST_BINARY_RESULT_OF(x <= y, result_of_less_equal);
+ BOOST_BINARY_RESULT_OF(x > y, result_of_greater);
+ BOOST_BINARY_RESULT_OF(x >= y, result_of_greater_equal);
+
+ BOOST_BINARY_RESULT_OF(x && y, result_of_logical_and);
+ BOOST_BINARY_RESULT_OF(x || y, result_of_logical_or);
+ BOOST_BINARY_RESULT_OF(true ? x : y, result_of_if_else);
+}
+
+using namespace boost;
+using namespace std;
+
+struct X {};
+X operator+(X, int);
+
+struct Y {};
+Y* operator+(Y, int);
+
+struct Z {};
+Z const* operator+(Z const&, int);
+Z& operator+(Z&, int);
+bool operator==(Z, Z);
+bool operator==(Z, int);
+
+struct W {};
+Z operator+(W, int);
+bool operator==(W, Z);
+
+int
+main()
+{
+ // ASSIGN
+ {
+ typedef result_of_assign<int, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int&>::value));
+ }
+
+ {
+ typedef result_of_assign<int*, int*>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int*&>::value));
+ }
+
+ // PLUS
+ {
+ typedef result_of_plus<int, double>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, double>::value));
+ }
+ {
+ typedef result_of_plus<double, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, double>::value));
+ }
+ {
+ typedef result_of_plus<int, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+ {
+ typedef result_of_plus<float, short>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, float>::value));
+ }
+ {
+ typedef result_of_plus<char, short>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+ {
+ typedef result_of_plus<long, short>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, long>::value));
+ }
+ {
+ typedef result_of_plus<long, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, long>::value));
+ }
+ {
+ typedef result_of_plus<X, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X>::value));
+ }
+ {
+ typedef result_of_plus<Y, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, Y*>::value));
+ }
+ {
+ typedef result_of_plus<Z, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, Z&>::value));
+ }
+ {
+ typedef result_of_plus<Z const, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, Z const*>::value));
+ }
+ {
+ typedef result_of_plus<complex<double>, double>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, complex<double> >::value));
+ }
+ {
+ typedef result_of_plus<double, complex<double> >::type result;
+ BOOST_STATIC_ASSERT((is_same<result, complex<double> >::value));
+ }
+ {
+ typedef result_of_plus<int*, size_t>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int*>::value));
+ }
+
+ // INDEX
+ {
+ typedef result_of_index<int(&)[3], int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int&>::value));
+ }
+ {
+ typedef result_of_index<X(&)[3], int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X&>::value));
+ }
+ {
+ typedef result_of_index<X const(&)[3], int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X const&>::value));
+ }
+ {
+ typedef result_of_index<X*, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X&>::value));
+ }
+ {
+ typedef result_of_index<X const*, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X const&>::value));
+ }
+ {
+ typedef result_of_index<vector<int>, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, vector<int>::reference>::value));
+ }
+ {
+ typedef result_of_index<vector<int> const, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+ {
+ typedef result_of_index<vector<X> const, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, vector<X>::const_reference>::value));
+ }
+ {
+ typedef result_of_index<vector<X>, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, vector<X>::reference>::value));
+ }
+ {
+ typedef result_of_index<string, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, string::reference>::value));
+ }
+ {
+ typedef result_of_index<vector<int>::iterator, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, vector<int>::iterator::reference>::value));
+ }
+ {
+ typedef result_of_index<vector<int>::const_iterator, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+ {
+ typedef result_of_index<vector<X>::const_iterator, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, vector<X>::const_iterator::reference>::value));
+ }
+ {
+ typedef result_of_index<map<char, X>, char>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, map<char, X>::mapped_type>::value));
+ }
+
+ // PLUS ASSIGN
+ {
+ typedef result_of_plus_assign<int, char>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int&>::value));
+ }
+ {
+ typedef result_of_plus_assign<double, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, double&>::value));
+ }
+ {
+ typedef result_of_plus_assign<complex<double>, double>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, complex<double>&>::value));
+ }
+
+ // SHIFT LEFT
+ {
+ typedef result_of_shift_left<int, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+ {
+ typedef result_of_shift_left<short, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+ {
+ typedef result_of_shift_left<ostream, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, ostream&>::value));
+ }
+
+ // EQUAL
+ {
+ typedef result_of_equal_to<int, double>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, bool>::value));
+ }
+ {
+ typedef result_of_equal_to<double, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, bool>::value));
+ }
+ {
+ typedef result_of_equal_to<int, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, bool>::value));
+ }
+ {
+ typedef result_of_equal_to<float, short>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, bool>::value));
+ }
+ {
+ typedef result_of_equal_to<char, short>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, bool>::value));
+ }
+ {
+ typedef result_of_equal_to<Z, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, bool>::value));
+ }
+ {
+ typedef result_of_equal_to<Z, Z>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, bool>::value));
+ }
+ {
+ typedef result_of_equal_to<W, Z>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, bool>::value));
+ }
+
+ // MINUS (pointers)
+ {
+ typedef result_of_minus<X*, X*>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, std::ptrdiff_t>::value));
+ }
+
+ // DEREFERENCE
+ {
+ typedef result_of_dereference<X*>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X&>::value));
+ }
+ {
+ typedef result_of_dereference<vector<X>::iterator>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X&>::value));
+ }
+ {
+ typedef result_of_dereference<shared_ptr<X> >::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X&>::value));
+ }
+
+ // ADDRESS OF
+ {
+ typedef result_of_reference<X>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X*>::value));
+ }
+ {
+ typedef result_of_reference<X const>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X const*>::value));
+ }
+
+ // PRE INCREMENT
+ {
+ typedef result_of_pre_increment<int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int&>::value));
+ }
+
+ // POST INCREMENT
+ {
+ typedef result_of_post_increment<int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+
+ // IF-ELSE-EXPRESSION ( c ? a : b )
+ {
+ typedef result_of_if_else<int, char>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+ {
+ typedef result_of_if_else<int, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int&>::value));
+ }
+ {
+ typedef result_of_if_else<int const, int const>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int>::value));
+ }
+ {
+ typedef result_of_if_else<X, X>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X&>::value));
+ }
+ {
+ typedef result_of_if_else<X const&, X const&>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X const&>::value));
+ }
+
+ // DEDUCTION FAILURE
+ {
+ typedef result_of_plus<W, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, error_cant_deduce_type>::value));
+ }
+
+ // local_reference
+ {
+ using phoenix::detail::local_reference;
+ typedef result_of_assign<local_reference<int>, int>::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int&>::value));
+ }
+
+ // local_reference
+ {
+ using phoenix::detail::local_reference;
+ typedef result_of_pre_increment<local_reference<int> >::type result;
+ BOOST_STATIC_ASSERT((is_same<result, int&>::value));
+ }
+
+ // local_reference
+ {
+ using phoenix::detail::local_reference;
+ typedef result_of_if_else<local_reference<X const>, local_reference<X const> >::type result;
+ BOOST_STATIC_ASSERT((is_same<result, X const&>::value));
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/function/function_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/function/function_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,128 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <cmath>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/function.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+ struct test_impl
+ {
+ typedef void result_type;
+ void operator()() const
+ {
+ cout << "Test lazy functions...\n";
+ }
+ };
+
+ function<test_impl> test;
+
+ struct sqr_impl
+ {
+ template<typename Signature>
+ struct result;
+
+ template <typename This, typename Arg>
+ struct result<This(Arg &)>
+ {
+ typedef Arg type;
+ };
+
+ template <typename Arg>
+ Arg operator()(Arg n) const
+ {
+ return n * n;
+ }
+ };
+
+ function<sqr_impl> sqr;
+
+ struct fact_impl
+ {
+ template<typename Signature>
+ struct result;
+
+ template <typename This, typename Arg>
+ struct result<This(Arg &)>
+ {
+ typedef Arg type;
+ };
+
+ template <typename Arg>
+ Arg operator()(Arg n) const
+ {
+ return (n <= 0) ? 1 : n * (*this)(n-1);
+ }
+ };
+
+ function<fact_impl> fact;
+
+ struct pow_impl
+ {
+
+ template<typename Sig>
+ struct result;
+
+ template <typename This, typename Arg1, typename Arg2>
+ struct result<This(Arg1 &, Arg2 &)>
+ {
+ typedef Arg1 type;
+ };
+
+ template <typename Arg1, typename Arg2>
+ Arg1 operator()(Arg1 a, Arg2 b) const
+ {
+ return pow(a, b);
+ }
+ };
+
+ function<pow_impl> power;
+
+ /*
+ struct add_impl
+ {
+ template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ struct result
+ {
+ typedef Arg1 type;
+ };
+
+ template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ Arg1 operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const
+ {
+ return a + b + c + d;
+ }
+ };
+
+ function<add_impl> add;
+ */
+
+int
+main()
+{
+ int i5 = 5;
+ double d5 = 5, d3 = 3;
+
+ test()(0);
+ BOOST_TEST(sqr(arg1)(i5) == (i5*i5));
+ BOOST_TEST(fact(4)(0) == 24);
+ BOOST_TEST(fact(arg1)(i5) == 120);
+ BOOST_TEST((int)power(arg1, arg2)(d5, d3) == (int)pow(d5, d3));
+ BOOST_TEST((sqr(arg1) + 5)(i5) == ((i5*i5)+5));
+ //BOOST_TEST(add(arg1, arg1, arg1, arg1)(i5) == (5+5+5+5));
+
+ int const ic5 = 5;
+ // testing consts
+ BOOST_TEST(sqr(arg1)(ic5) == (ic5*ic5));
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/cast_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/cast_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,63 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <string>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_object.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+struct T
+{
+ string foo() { return "T"; }
+};
+
+struct U : T
+{
+ string foo() { return "U"; }
+};
+
+struct VT
+{
+ virtual string foo() { return "T"; }
+};
+
+struct VU : VT
+{
+ virtual string foo() { return "U"; }
+};
+
+int
+main()
+{
+ {
+ U u;
+ BOOST_TEST(arg1(u).foo() == "U");
+ BOOST_TEST(static_cast_<T&>(arg1)(u).foo() == "T");
+ }
+
+ {
+ U const u = U();
+ BOOST_TEST(const_cast_<U&>(arg1)(u).foo() == "U");
+ }
+
+ {
+ VU u;
+ VT* tp = &u;
+ BOOST_TEST(arg1(tp)->foo() == "U");
+ BOOST_TEST(dynamic_cast_<VU*>(arg1)(tp) != 0);
+ }
+
+ {
+ void* p = 0;
+ reinterpret_cast_<VU*>(arg1)(p); // compile test only
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/new_delete_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/new_delete_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,52 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <vector>
+#include <algorithm>
+#include <boost/shared_ptr.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_object.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int n = 0;
+
+struct X
+{
+ X(int, int, int) { cout << "new X(int, int, int)" << endl; ++n; }
+ X() { cout << "new X" << endl; ++n; }
+ ~X() { cout << "delete X" << endl; --n; }
+};
+
+int
+main()
+{
+ {
+ vector<X*> v(10);
+
+ for_each(v.begin(), v.end(), arg1 = new_<X>());
+ for_each(v.begin(), v.end(), delete_(arg1));
+
+ for_each(v.begin(), v.end(), arg1 = new_<X>(1, 2, 3));
+ for_each(v.begin(), v.end(), delete_(arg1));
+ }
+
+ {
+ using boost::shared_ptr;
+ vector<shared_ptr<X> > v(10);
+ for_each(v.begin(), v.end(),
+ arg1 = construct<shared_ptr<X> >(new_<X>())
+ );
+ }
+
+ BOOST_TEST(n == 0);
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/arithmetic_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/arithmetic_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,54 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+using namespace boost::phoenix;
+using namespace std;
+
+int
+main()
+{
+ {
+ int x = 123;
+
+ BOOST_TEST((ref(x) += 456)(0) == (123 + 456));
+ BOOST_TEST(x == 123 + 456);
+ BOOST_TEST((ref(x) -= 456)(0) == 123);
+ BOOST_TEST(x == 123);
+ BOOST_TEST((ref(x) *= 456)(0) == 123 * 456);
+ BOOST_TEST(x == 123 * 456);
+ BOOST_TEST((ref(x) /= 456)(0) == 123);
+ BOOST_TEST(x == 123);
+
+ int& r1 = (ref(x) += 456)(0); // should be an lvalue
+ int& r2 = (ref(x) -= 456)(0); // should be an lvalue
+ int& r3 = (ref(x) *= 456)(0); // should be an lvalue
+ int& r4 = (ref(x) /= 456)(0); // should be an lvalue
+ BOOST_TEST(r1 == 123 && r2 == 123 && r3 == 123 && r4 == 123);
+
+ BOOST_TEST((ref(x) %= 456)(0) == 123 % 456);
+ BOOST_TEST(x == 123 % 456);
+ }
+
+ {
+ BOOST_TEST((val(123) + 456)(0) == 123 + 456);
+ BOOST_TEST((val(123) - 456)(0) == 123 - 456);
+ BOOST_TEST((val(123) * 456)(0) == 123 * 456);
+ BOOST_TEST((val(123) / 456)(0) == 123 / 456);
+ BOOST_TEST((val(123) % 456)(0) == 123 % 456);
+
+ BOOST_TEST((123 + val(456))(0) == 123 + 456);
+ BOOST_TEST((123 - val(456))(0) == 123 - 456);
+ BOOST_TEST((123 * val(456))(0) == 123 * 456);
+ BOOST_TEST((123 / val(456))(0) == 123 / 456);
+ BOOST_TEST((123 % val(456))(0) == 123 % 456);
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/bitwise_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/bitwise_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,73 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ {
+ int x;
+ int y;
+
+ x = 123;
+ y = 123;
+ (ref(x) &= 456)(0);
+ y &= 456;
+ BOOST_TEST(x == y);
+
+ x = 123;
+ y = 123;
+ (ref(x) |= 456)(0);
+ y |= 456;
+ BOOST_TEST(x == y);
+
+ x = 123;
+ y = 123;
+ (ref(x) ^= 456)(0);
+ y ^= 456;
+ BOOST_TEST(x == y);
+
+ x = 123;
+ y = 123;
+ (ref(x) <<= 4)(0);
+ y <<= 4;
+ BOOST_TEST(x == y);
+
+ x = 1230000;
+ y = 1230000;
+ (ref(x) >>= 4)(0);
+ y >>= 4;
+ BOOST_TEST(x == y);
+
+ int& r1 = (ref(x) &= 456)(0); // should be an lvalue
+ int& r2 = (ref(x) |= 456)(0); // should be an lvalue
+ int& r3 = (ref(x) ^= 456)(0); // should be an lvalue
+ int& r4 = (ref(x) <<= 4)(0); // should be an lvalue
+ int& r5 = (ref(x) >>= 4)(0); // should be an lvalue
+ BOOST_TEST(&r1 == &r2 && &r2 == &r3 && &r3 == &r4 && &r4 == &r5);
+ }
+
+ {
+ BOOST_TEST((val(123) & 456)(0) == (123 & 456));
+ BOOST_TEST((val(123) | 456)(0) == (123 | 456));
+ BOOST_TEST((val(123) ^ 456)(0) == (123 ^ 456));
+ BOOST_TEST((val(123) << 4)(0) == (123 << 4));
+ BOOST_TEST((val(1230000) >> 4)(0) == (1230000 >> 4));
+
+ char const* s = "Yabadabadoo!!!\n";
+ (cout << arg1)(s);
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/comparison_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/comparison_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,28 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+using namespace boost::phoenix;
+using namespace std;
+
+int
+main()
+{
+ {
+ BOOST_TEST(!(val(123) == 456)(0));
+ BOOST_TEST((val(123) != 456)(0));
+ BOOST_TEST(!(val(123) > 456)(0));
+ BOOST_TEST((val(123) < 456)(0));
+ BOOST_TEST(!(val(123) > 456)(0));
+ BOOST_TEST((val(123) <= 123)(0));
+ BOOST_TEST((val(123) >= 123)(0));
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/if_else_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/if_else_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,34 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ {
+ int x = 0;
+ int y = 0;
+ bool c = false;
+
+ BOOST_TEST(if_else(arg1, 1234, 5678)(c) == 5678);
+ BOOST_TEST(if_else(arg1, 1234, 'x')(c) == 'x');
+
+ int& r = if_else(arg1, ref(x), ref(y))(c); // should be an lvalue
+ BOOST_TEST(&y == &r);
+
+ (if_else(arg1, ref(x), ref(y)) = 986754321)(c);
+ BOOST_TEST(y == 986754321);
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/io_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/io_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,54 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <vector>
+#include <algorithm>
+#include <sstream>
+#include <string>
+#include <algorithm>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+#include <boost/fusion/include/io.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ int i100 = 100;
+ string hello = "hello";
+ const char* world = " world";
+
+ int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ vector<int> v(init, init+10);
+
+ char const* msg = "cout assert\n";
+ (cout << arg1)(msg);
+ //(cout << arg1 << endl)(hello);
+ //(arg1 << hex)(cout);
+ (cout << val(hello))(0);
+
+ (cout << val(hello) << world << ", you da man!\n")(0);
+ for_each(v.begin(), v.end(), cout << arg1 << ',');
+ (cout << arg1 + 1)(i100);
+
+ //(cout << arg1 << "this is it, shukz:" << hex << arg2 << endl << endl)(msg, i100);
+
+ int in;
+ int out = 12345;
+ stringstream sstr;
+ (sstr << arg1)(out);
+ //(sstr >> arg1)(in);
+ //BOOST_TEST(in == out);
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/logical_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/logical_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,36 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ {
+ bool x = false;
+ bool y = true;
+
+ BOOST_TEST((!arg1)(x) == true);
+ BOOST_TEST((!arg1)(y) == false);
+ BOOST_TEST((arg1 || arg2)(x, y) == true);
+ BOOST_TEST((arg1 && arg2)(x, y) == false);
+
+ // short circuiting:
+ int i = 1234;
+ //(arg1 || (arg2 = 4567))(y, i);
+ BOOST_TEST(i == 1234);
+ //(arg1 && (arg2 = 4567))(y, i);
+ //BOOST_TEST(i == 4567);
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,87 @@
+/*=============================================================================
+ Copyright (c) 2005-2007 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+
+ 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/operator.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <memory>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+
+namespace
+{
+ struct Test
+ {
+ int value;
+
+ int func(int n) const { return n; }
+ int dunc() { return 10; }
+ int kunc() const { return 555; }
+ };
+}
+
+int main()
+{
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ using namespace boost;
+
+ Test test = {1};
+ const Test* cptr = &test;
+ Test* ptr = &test;
+
+ BOOST_TEST((val(ptr)->*&Test::value)(0) == 1);
+ BOOST_TEST((val(cptr)->*&Test::value)(0) == 1);
+ BOOST_TEST((arg1->*&Test::value)(cptr) == 1);
+
+ ((val(ptr)->*&Test::value) = 2)(0);
+ BOOST_TEST(test.value == 2);
+
+ BOOST_TEST((val(ptr)->*&Test::func)(3)(0) == 3);
+ int i = 33;
+ //BOOST_TEST((arg1->*&Test::func)(arg2)(cptr, i) == i);
+ BOOST_TEST((val(cptr)->*&Test::func)(4)(0) == 4);
+ //BOOST_TEST((val(ptr)->*&Test::dunc)(0)() == 10);
+
+ //BOOST_TEST((arg1->*&Test::func)(5)(ptr) == 5);
+ //BOOST_TEST((arg1->*&Test::kunc)()(ptr));
+
+ shared_ptr<Test> sptr(new Test(test));
+
+ BOOST_TEST((arg1->*&Test::value)(sptr) == 2);
+ //BOOST_TEST((arg1->*&Test::func)(6)(sptr) == 6);
+
+ scoped_ptr<Test> scptr(new Test(test));
+
+ BOOST_TEST((arg1->*&Test::value)(scptr) == 2);
+ //BOOST_TEST((arg1->*&Test::func)(7)(scptr) == 7);
+
+ shared_ptr<const Test> csptr(new Test(test));
+
+ BOOST_TEST((arg1->*&Test::value)(csptr) == 2);
+ //BOOST_TEST((arg1->*&Test::func)(8)(csptr) == 8);
+
+ scoped_ptr<const Test> cscptr(new Test(test));
+
+ BOOST_TEST((arg1->*&Test::value)(cscptr) == 2);
+ //BOOST_TEST((arg1->*&Test::func)(9)(cscptr) == 9);
+
+ std::auto_ptr<Test> aptr(new Test(test));
+
+ BOOST_TEST((arg1->*&Test::value)(aptr) == 2);
+ //BOOST_TEST((arg1->*&Test::func)(10)(aptr) == 10);
+
+ std::auto_ptr<const Test> captr(new Test(test));
+
+ BOOST_TEST((arg1->*&Test::value)(captr) == 2);
+ //BOOST_TEST((arg1->*&Test::func)(11)(captr) == 11);
+
+ return 0;
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/misc_binary_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/misc_binary_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,99 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <string>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::placeholders;
+using namespace std;
+
+int
+main()
+{
+ { // From Phoenix 1.1 binary tests
+
+ int i2 = 2, i3 = 3, i = 5;
+ const char* world = " world";
+
+
+ BOOST_TEST((ref(i) = ref(i))(0) == 5);
+ BOOST_TEST((ref(i) = 3)(0) == 3);
+ BOOST_TEST(i == 3);
+ i = 5;
+ int x, y, z;
+ (ref(x) = ref(y) = ref(z) = 10)(0);
+ BOOST_TEST(x == 10 && y == 10 && z == 10);
+ BOOST_TEST((val(world)[3])(0) == world[3]);
+
+ BOOST_TEST((ref(i) += 5)(0) == 10);
+ BOOST_TEST((ref(i) -= 5)(0) == 5);
+ BOOST_TEST((ref(i) *= 5)(0) == 25);
+ BOOST_TEST((ref(i) /= 5)(0) == 5);
+ BOOST_TEST((ref(i) %= 2)(0) == 1);
+
+ BOOST_TEST((ref(i) <<= 3)(0) == 8);
+ BOOST_TEST((ref(i) >>= 1)(0) == 4);
+ BOOST_TEST((ref(i) |= 0xFF)(0) == 0xFF);
+ BOOST_TEST((ref(i) &= 0xF0)(0) == 0xF0);
+ BOOST_TEST((ref(i) ^= 0xFFFFFFFF)(0) == int(0xFFFFFF0F));
+
+ BOOST_TEST((val(5) == val(5))(0));
+ BOOST_TEST((val(5) == 5)(0));
+
+ BOOST_TEST((arg1 + arg2 )(i2, i3) == i2 + i3 );
+ BOOST_TEST((arg1 - arg2)(i2, i3) == i2 - i3);
+ BOOST_TEST((arg1 * arg2)(i2, i3) == i2 * i3);
+ BOOST_TEST((arg1 / arg2)(i2, i3) == i2 / i3);
+ BOOST_TEST((arg1 % arg2)(i2, i3) == i2 % i3);
+ BOOST_TEST((arg1 & arg2)(i2, i3) == (i2 & i3));
+ BOOST_TEST((arg1 | arg2)(i2, i3) == (i2 | i3));
+ BOOST_TEST((arg1 ^ arg2)(i2, i3) == (i2 ^ i3));
+ BOOST_TEST((arg1 << arg2)(i2, i3) == i2 << i3);
+ BOOST_TEST((arg1 >> arg2)(i2, i3) == i2 >> i3);
+
+ BOOST_TEST((val(5) != val(6))(0));
+ BOOST_TEST((val(5) < val(6))(0));
+ BOOST_TEST(!(val(5) > val(6))(0));
+ BOOST_TEST((val(5) < val(6))(0));
+ BOOST_TEST((val(5) <= val(6))(0));
+ BOOST_TEST((val(5) <= val(5))(0));
+ BOOST_TEST((val(7) >= val(6))(0));
+ BOOST_TEST((val(7) >= val(7))(0));
+
+ BOOST_TEST((val(false) && val(false))(0) == false);
+ BOOST_TEST((val(true) && val(false))(0) == false);
+ BOOST_TEST((val(false) && val(true))(0) == false);
+ BOOST_TEST((val(true) && val(true))(0) == true);
+
+ BOOST_TEST((val(false) || val(false))(0) == false);
+ BOOST_TEST((val(true) || val(false))(0) == true);
+ BOOST_TEST((val(false) || val(true))(0) == true);
+ BOOST_TEST((val(true) || val(true))(0) == true);
+ }
+
+ { // From Phoenix 1.1 mixed_binary tests
+
+ int i1 = 1, i2 = 2, i50 = 50, i100 = 100;
+ double d2_5 = 2.5;
+ string hello = "hello";
+ const char* world = " world";
+
+ BOOST_TEST((arg1 + arg2)(i100, i50) == (i100 + i50));
+ BOOST_TEST((arg1 + 3)(i100) == (3 + i100));
+ BOOST_TEST((arg1 + arg2)(hello, world) == "hello world");
+ BOOST_TEST((arg1 + arg2)(i1, d2_5) == (i1 + d2_5));
+
+ BOOST_TEST((*(arg1 + arg2))(world, i2) == *(world + i2));
+ BOOST_TEST((*(arg1 + arg2))(i2, world) == *(i2 + world));
+ BOOST_TEST((*(val(world+i2) - arg1))(i2) == *world);
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/self_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/self_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,56 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <vector>
+#include <string>
+#include <map>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ {
+ int x = 123;
+ BOOST_TEST((&arg1)(x) == &x);
+ BOOST_TEST((*&arg1)(x) == 123);
+
+ int y = 968;
+ (ref(x) = arg1)(y);
+ BOOST_TEST(x == y);
+
+ //(arg1 = 456)(x);
+ //BOOST_TEST(x == 456);
+ //int& r = (arg1 = 456)(x); // must be an lvalue
+ //BOOST_TEST(&r == &x);
+
+ int c[] = { 1, 2, 3, 4, 5 };
+ BOOST_TEST((arg1[3])(c) == 4);
+
+ //int& r2 = (arg1[3])(c); // must be an lvalue
+ int const & r2 = (arg1[3])(c); // must be an lvalue
+ //BOOST_TEST(&r2 == &c[3]);
+
+ vector<string> v;
+ v.push_back("a");
+ v.push_back("b");
+ v.push_back("c");
+ v.push_back("d");
+
+ BOOST_TEST((arg1[3])(v) == "d");
+
+ map<string, int> m;
+ //(arg1["Kimpo"] = arg2)(m, x);
+ //BOOST_TEST(m["Kimpo"] == x);
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/unary_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/unary_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,64 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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/core.hpp>
+#include <boost/phoenix/operator.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ {
+ BOOST_TEST((-val(123))(0) == -123);
+ BOOST_TEST((- -val(123))(0) == 123);
+ BOOST_TEST((+val(123))(0) == 123);
+ }
+
+ {
+ int x = 123;
+
+ BOOST_TEST((++ref(x))(0) == 124);
+ BOOST_TEST(x == 124);
+ BOOST_TEST((--ref(x))(0) == 123);
+ BOOST_TEST(x == 123);
+
+ BOOST_TEST((ref(x)++)(0) == 123);
+ BOOST_TEST(x == 124);
+ BOOST_TEST((ref(x)--)(0) == 124);
+ BOOST_TEST(x == 123);
+
+ int& r1 = (++ref(x))(0); // should be an lvalue
+ int& r2 = (--ref(x))(0); // should be an lvalue
+ BOOST_TEST(r1 == 123 && r2 == 123);
+ }
+
+ { // From Phoenix 1.1 unary tests
+
+ int i1 = 1, i = 5;
+
+ BOOST_TEST((!val(true))(0) == false);
+ BOOST_TEST((-val(1))(0) == -1);
+ BOOST_TEST((+val(1))(0) == +1);
+ BOOST_TEST((~val(1))(0) == ~1);
+ BOOST_TEST(*(&arg1)(i1) == *(&i1));
+ BOOST_TEST((&arg1)(i1) == &i1);
+
+ BOOST_TEST((*val(&i1))(0) == *(&i1));
+ BOOST_TEST((*&arg1)(i1) == *(&i1));
+ BOOST_TEST((++ref(i))(0) == 6);
+ BOOST_TEST((--ref(i))(0) == 5);
+ BOOST_TEST((ref(i)++)(0) == 5);
+ BOOST_TEST(i == 6);
+ BOOST_TEST((ref(i)--)(0) == 6);
+ BOOST_TEST(i == 5);
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/bug_000008.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/bug_000008.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,97 @@
+/*=============================================================================
+ Copyright (c) 2003 Martin Wille
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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)
+=============================================================================*/
+
+ // see http://article.gmane.org/gmane.comp.parsers.spirit.general/4575
+ // or https://sf.net/mailarchive/forum.php?thread_id=2692308&forum_id=1595
+ // for a description of the bug being tested for by this program
+ //
+ // This code is borrowed from Spirit's bug_000008.cpp test for multithreads.
+#include <iostream>
+#include <boost/config.hpp>
+#include <boost/assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/home/phoenix/scope/dynamic.hpp>
+
+#if defined(DONT_HAVE_BOOST) \
+ || !defined(BOOST_HAS_THREADS) \
+ || defined(BOOST_DISABLE_THREADS) \
+ || (defined(__GNUC__) && defined(__WIN32__)) // MinGW
+#define SKIP_TEST
+#endif
+
+
+#if defined(SKIP_TEST)
+// we end here if we can't do multithreading
+static void skipped()
+{
+ std::cout << "skipped\n";
+}
+
+int
+main()
+{
+ skipped();
+ return boost::report_errors();
+}
+
+#else
+// the real MT stuff
+
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_scope.hpp>
+#include <boost/thread.hpp>
+
+static const int number_of_calls_per_thread=20000;
+
+struct test_dynamic : boost::phoenix::dynamic<int>
+{
+ test_dynamic() : b(*this) {}
+ member1 b;
+};
+
+void
+in_thread(void)
+{
+ test_dynamic s; // should now be a local
+
+ for (int i = 0; i < number_of_calls_per_thread; ++i)
+ {
+ boost::phoenix::dynamic_frame<test_dynamic::self_type> frame(s);
+ (s.b = 123)();
+ {
+ boost::phoenix::dynamic_frame<test_dynamic::self_type> frame(s);
+ (s.b = 456)();
+ BOOST_ASSERT((s.b == 456)());
+ }
+ BOOST_ASSERT((s.b == 123)());
+ }
+}
+
+void
+bug_000008()
+{
+ boost::thread t1(in_thread);
+ boost::thread t2(in_thread);
+ boost::thread t3(in_thread);
+ boost::thread t4(in_thread);
+
+ t1.join();
+ t2.join();
+ t3.join();
+ t4.join();
+}
+
+int
+main()
+{
+ bug_000008();
+ return boost::report_errors();
+}
+
+#endif
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/dynamic_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/dynamic_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,79 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <string>
+
+#define PHOENIX_LIMIT 6
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/home/phoenix/scope/dynamic.hpp>
+
+struct my_dynamic : ::boost::phoenix::dynamic<int, std::string, double>
+{
+ my_dynamic() : num(*this), message(*this), real(*this) {}
+
+ member1 num;
+ member2 message;
+ member3 real;
+};
+
+// You may also use the macro below to achieve the same as above:
+//
+// PHOENIX_DYNAMIC(
+// my_dynamic,
+// (int, num)
+// (std::string, message)
+// (double, real)
+// );
+
+int
+main()
+{
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+
+ my_dynamic clos;
+
+ { // First stack frame
+ dynamic_frame<my_dynamic::self_type> frame(clos);
+ (clos.num = 123)();
+ (clos.num += 456)();
+ (clos.real = clos.num / 56.5)();
+ (clos.message = "Hello " + std::string("World "))();
+
+ { // Second stack frame
+ dynamic_frame<my_dynamic::self_type> frame(clos);
+ (clos.num = 987)();
+ (clos.message = "Abracadabra ")();
+ (clos.real = clos.num * 1e30)();
+
+ { // Third stack frame
+ boost::fusion::vector<int, char const*, double> init(-1, "Direct Init ", 3.14);
+ dynamic_frame<my_dynamic::self_type> frame(clos, init);
+
+ (std::cout << clos.message << clos.num << ", " << clos.real << '\n')();
+ BOOST_TEST(clos.num() == -1);
+ BOOST_TEST(clos.real() == 3.14);
+ BOOST_TEST(clos.message() == "Direct Init ");
+ }
+
+ (std::cout << clos.message << clos.num << ", " << clos.real << '\n')();
+ BOOST_TEST(clos.num() == 987);
+ BOOST_TEST(clos.real() == clos.num() * 1e30);
+ BOOST_TEST(clos.message() == "Abracadabra ");
+ }
+
+ (std::cout << clos.message << clos.num << ", " << clos.real << '\n')();
+ BOOST_TEST(clos.num() == 123+456);
+ BOOST_TEST(clos.real() == clos.num() / 56.5);
+ BOOST_TEST(clos.message() == "Hello " + std::string("World "));
+ }
+
+ return 0;
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,180 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <cmath>
+#include <algorithm>
+#include <vector>
+
+#define PHOENIX_LIMIT 5
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_scope.hpp>
+#include <boost/spirit/include/phoenix_function.hpp>
+
+namespace boost { namespace phoenix
+{
+ struct for_each_impl
+ {
+ template <typename C, typename F>
+ struct result
+ {
+ typedef void type;
+ };
+
+ template <typename C, typename F>
+ void operator()(C& c, F f) const
+ {
+ std::for_each(c.begin(), c.end(), f);
+ }
+ };
+
+ function<for_each_impl> const for_each = for_each_impl();
+
+ struct push_back_impl
+ {
+ template <typename C, typename T>
+ struct result
+ {
+ typedef void type;
+ };
+
+ template <typename C, typename T>
+ void operator()(C& c, T& x) const
+ {
+ c.push_back(x);
+ }
+ };
+
+ function<push_back_impl> const push_back = push_back_impl();
+}}
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace boost::phoenix::local_names;
+using namespace std;
+
+struct zzz {};
+
+int
+main()
+{
+ {
+ int x = 1;
+ int y = lambda[_1]()(x);
+ BOOST_TEST(x == y);
+ }
+
+ {
+ int x = 1, y = 10;
+ BOOST_TEST(
+ (_1 + lambda[_1 + 2])(x)(y) == 1+10+2
+ );
+ BOOST_TEST(
+ (_1 + lambda[-_1])(x)(y) == 1+-10
+ );
+ }
+
+ {
+ int x = 1, y = 10, z = 13;
+ BOOST_TEST(
+ lambda(_a = _1, _b = _2)
+ [
+ _1 + _a + _b
+ ]
+ (x, z)(y) == x + y + z
+ );
+ }
+
+ {
+ int x = 4;
+ int y = 5;
+ lambda(_a = _1)[_a = 555](x)();
+ BOOST_TEST(x == 555);
+ (void)y;
+ }
+
+ {
+ int x = 1;
+ long x2 = 2;
+ short x3 = 3;
+ char const* y = "hello";
+ zzz z;
+
+ BOOST_TEST(lambda[_1](x)(y) == y);
+ BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x);
+ BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x);
+ BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2);
+ BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6);
+ }
+
+ {
+ int x = 1, y = 10;
+ BOOST_TEST(
+ (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2
+ );
+ }
+
+ {
+ int x = 1, y = 10;
+ BOOST_TEST(
+ (_1 +
+ lambda(_a = _1)
+ [
+ _a + lambda[_a + 2]
+ ]
+ )
+ (x)(y)(y) == 1+1+1+2
+ );
+ }
+
+ {
+ using boost::phoenix::for_each;
+
+ int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ std::vector<int> v(init, init+10);
+
+ int x = 0;
+ for_each(_1, lambda(_a = _2)[_a += _1])(v, x);
+ BOOST_TEST(x == 55);
+ }
+
+ {
+ using boost::phoenix::for_each;
+ using boost::phoenix::push_back;
+
+ int x = 10;
+ std::vector<std::vector<int> > v(10);
+
+ for_each(_1, lambda(_a = _2)[push_back(_1, _a)])(v, x);
+
+ int y = 0;
+ for_each(arg1, lambda[ref(y) += _1[0]])(v);
+ BOOST_TEST(y == 100);
+ }
+
+ {
+ int x = 1, y = 10, z = 13;
+ BOOST_TEST(
+ lambda(_a = _1, _b = _2)
+ [
+ _1 + _a + _b
+ ]
+ (x, z)(y) == x + y + z
+ );
+ }
+
+ {
+ // $$$ Fixme. This should not be failing $$$
+ int x = (let(_a = lambda[val(1)])[_a])()();
+ //~ BOOST_TEST(x == 1);
+ }
+
+ return boost::report_errors();
+}
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,146 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <cmath>
+#include <algorithm>
+#include <vector>
+
+#define PHOENIX_LIMIT 6
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_scope.hpp>
+#include <boost/spirit/include/phoenix_function.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace boost::phoenix::local_names;
+using namespace std;
+
+int
+main()
+{
+ {
+ int x = 1;
+ BOOST_TEST(
+ let(_a = _1)
+ [
+ _a
+ ]
+ (x) == x
+ );
+ }
+
+ {
+ int x = 1, y = 10;
+ BOOST_TEST(
+ let(_a = _1, _b = _2)
+ [
+ _a + _b
+ ]
+ (x, y) == x + y
+ );
+ }
+
+ {
+ int x = 1, y = 10, z = 13;
+ BOOST_TEST(
+ let(_x = _1, _y = _2)
+ [
+ let(_z = _3)
+ [
+ _x + _y + _z
+ ]
+ ]
+ (x, y, z) == x + y + z
+ );
+ }
+
+ {
+ int x = 1, y = 10;
+ BOOST_TEST(
+ let(_x = _1)
+ [
+ _x +
+ let(_x = _2)
+ [
+ -_x
+ ]
+ ]
+ (x, y) == x + -y
+ );
+ }
+
+ {
+ int x = 999;
+ BOOST_TEST(
+ let(_x = _1) // _x is a reference to _x
+ [
+ _x += 888
+ ]
+ (x) == 999 + 888
+ );
+
+ BOOST_TEST(x == 888 + 999);
+ }
+
+ {
+ int x = 999;
+ BOOST_TEST(
+ let(_x = val(_1)) // _x holds x by value
+ [
+ val(_x += 888)
+ ]
+ (x) == x + 888
+ );
+
+ BOOST_TEST(x == 999);
+ }
+
+ {
+ BOOST_TEST(
+ let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5)
+ [
+ _a + _b + _c + _d + _e
+ ]
+ () == 1 + 2 + 3 + 4 + 5
+ );
+ }
+
+#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
+ {
+ // disallow this:
+ int i;
+ (_a + _b)(i);
+ }
+#endif
+
+ {
+ // show that we can return a local from an outer scope
+ int y = 0;
+ int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y);
+ BOOST_TEST(x == 1);
+ }
+
+ {
+ // show that this code returns an lvalue
+ int i = 1;
+ let(_a = arg1)[ _a ](i)++;
+ BOOST_TEST(i == 2);
+ }
+
+ {
+ // show that what you put in is what you get out
+ int i = 1;
+ int& j = let(_a = arg1)[ _a ](i);
+ BOOST_TEST(&i == &j);
+ }
+
+ return boost::report_errors();
+}
+
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/exceptions.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/exceptions.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,100 @@
+/*=============================================================================
+ Copyright (c) 2005-2007 Dan Marsden
+ Copyright (c) 2005-2007 Joel de Guzman
+
+ 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 <stdexcept>
+#include <string>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ using namespace boost::phoenix;
+ using namespace boost::phoenix::arg_names;
+ using namespace std;
+
+ {
+ try
+ {
+ throw_(runtime_error("error"))();
+ BOOST_ERROR("exception should have been thrown");
+ }
+ catch(runtime_error& err)
+ {
+ BOOST_TEST(err.what() == string("error"));
+ }
+ }
+
+ {
+ try
+ {
+ try
+ {
+ throw runtime_error("error");
+ }
+ catch(exception&)
+ {
+ throw_()();
+ BOOST_ERROR("exception should have been rethrown");
+ }
+ }
+ catch(exception& err)
+ {
+ BOOST_TEST(err.what() == string("error"));
+ }
+ }
+
+ {
+ bool caught_exception = false;
+
+ try_
+ [ throw_(runtime_error("error")) ]
+ .catch_<exception>()
+ [ ref(caught_exception) = true ]();
+
+ BOOST_TEST(caught_exception);
+ }
+
+ {
+ bool caught_exception = false;
+ try_
+ [ throw_(runtime_error("error")) ]
+ .catch_all
+ [ ref(caught_exception) = true ]();
+ BOOST_TEST(caught_exception);
+ }
+
+ {
+ bool caught_correct_exception = false;
+ try_
+ [ throw_(runtime_error("error")) ]
+ .catch_<string>()
+ [ ref(caught_correct_exception) = false ]
+ .catch_<exception>()
+ [ ref(caught_correct_exception) = true]();
+
+ BOOST_TEST(caught_correct_exception);
+ }
+
+ {
+ bool caught_correct_exception = false;
+ try_
+ [ throw_(runtime_error("error")) ]
+ .catch_<string>()
+ [ ref(caught_correct_exception) = false ]
+ .catch_all
+ [ ref(caught_correct_exception) = true]();
+
+ BOOST_TEST(caught_correct_exception);
+ }
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/if_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/if_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,70 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <vector>
+#include <algorithm>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/statement.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/core.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ vector<int> v(init, init+10);
+
+ cout << dec;
+ int x = 0;
+
+ for_each(v.begin(), v.end(),
+ if_(arg1 > 3 && arg1 <= 8)
+ [
+ cout << arg1 << ", ",
+ ref(x) += arg1
+ ]
+ );
+
+ cout << endl;
+ BOOST_TEST(x == 4+5+6+7+8);
+
+ x = 0;
+ int y = 0;
+ int z = 0;
+
+ for_each(v.begin(), v.end(),
+ if_(arg1 > 5)
+ [
+ cout << arg1 << " > 5\n",
+ ref(x) += arg1
+ ]
+ .else_
+ [
+ if_(arg1 == 5)
+ [
+ cout << arg1 << " == 5\n",
+ ref(z) += arg1
+ ]
+ .else_
+ [
+ cout << arg1 << " < 5\n",
+ ref(y) += arg1
+ ]
+ ]
+ );
+
+ cout << endl;
+ BOOST_TEST(x == 6+7+8+9+10);
+ BOOST_TEST(y == 1+2+3+4);
+ BOOST_TEST(z == 5);
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/loops_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/loops_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,79 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <vector>
+#include <algorithm>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ vector<int> v(init, init+10);
+ vector<int> t = v;
+ cout << endl;
+ int x = 0;
+
+ for_each(v.begin(), v.end(),
+ (
+ while_(arg1--)
+ [
+ cout << arg1 << ", ",
+ ++ref(x)
+ ],
+ cout << val("\n")
+ )
+ );
+
+ BOOST_TEST(x == 1+2+3+4+5+6+7+8+9+10);
+ cout << endl;
+ v = t;
+ x = 0;
+
+ for_each(v.begin(), v.end(),
+ (
+ do_
+ [
+ cout << arg1 << ", ",
+ ++ref(x)
+ ]
+ .while_(arg1--),
+ cout << val("\n")
+ )
+ );
+
+ BOOST_TEST(x == 2+3+4+5+6+7+8+9+10+11);
+ cout << endl;
+ v = t;
+ x = 0;
+
+ int iii;
+ for_each(v.begin(), v.end(),
+ (
+ for_(ref(iii) = 0, ref(iii) < arg1, ++ref(iii))
+ [
+ cout << arg1 << ", ",
+ ++ref(x)
+ ],
+ cout << val("\n")
+ )
+ );
+
+ BOOST_TEST(x == 1+2+3+4+5+6+7+8+9+10);
+ cout << endl;
+ v = t;
+ x = 0;
+
+ return boost::report_errors();
+}
Added: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp 2010-06-07 21:31:35 EDT (Mon, 07 Jun 2010)
@@ -0,0 +1,69 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <vector>
+#include <algorithm>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+
+using namespace boost::phoenix;
+using namespace boost::phoenix::arg_names;
+using namespace std;
+
+int
+main()
+{
+ int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ vector<int> v(init, init+10);
+
+ for_each(v.begin(), v.end(),
+ switch_(_1)
+ [
+ // wierd case, why not just use if(...), but valid, nonetheless
+ case_<4>(cout << val("<4>") << endl)
+ ]
+ );
+
+ cout << endl;
+
+ for_each(v.begin(), v.end(),
+ switch_(_1)
+ [
+ // wierd case, but valid, nonetheless
+ default_(cout << val("<any...>") << endl)
+ ]
+ );
+
+ cout << endl;
+
+ for_each(v.begin(), v.end(),
+ switch_(_1)
+ [
+ case_<1>(cout << val("<1>") << endl),
+ case_<2>(cout << val("<2>") << endl),
+ case_<3>(cout << val("<3>") << endl),
+ case_<4>(cout << val("<4>") << endl)
+ ]
+ );
+
+ cout << endl;
+
+ for_each(v.begin(), v.end(),
+ switch_(_1)
+ [
+ case_<1>(cout << val("<1>") << endl),
+ case_<2>(cout << val("<2>") << endl),
+ case_<3>(cout << val("<3>") << endl),
+ case_<4>(cout << val("<4>") << endl),
+ default_(cout << val("<over 4>") << endl)
+ ]
+ );
+
+ return boost::report_errors();
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk