Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-05-11 20:13:40


Author: eric_niebler
Date: 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
New Revision: 45290
URL: http://svn.boost.org/trac/boost/changeset/45290

Log:
initial version of phoenix v3, built on top of proto
Added:
   branches/proto/v4/boost/phoenix/
   branches/proto/v4/boost/phoenix/core/
   branches/proto/v4/boost/phoenix/core.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/core/actor.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/core/argument.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/core/limits.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/core/reference.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/core/value.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/operator/
   branches/proto/v4/boost/phoenix/operator.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/operator/if_else.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/operator/io.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/statement/
   branches/proto/v4/boost/phoenix/statement.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/statement/if.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/version.hpp (contents, props changed)
   branches/proto/v4/libs/phoenix/
   branches/proto/v4/libs/phoenix/test/
   branches/proto/v4/libs/phoenix/test/Jamfile.v2 (contents, props changed)
   branches/proto/v4/libs/phoenix/test/algorithm/
   branches/proto/v4/libs/phoenix/test/algorithm/iteration.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/algorithm/querying.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/algorithm/querying2.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/algorithm/transformation1.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/algorithm/transformation2.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/algorithm/transformation3.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/algorithm/transformation4.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/bind/
   branches/proto/v4/libs/phoenix/test/bind/bind_function_object_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/bind/bind_function_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/bind/bind_member_function_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/bind/bind_member_variable_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/
   branches/proto/v4/libs/phoenix/test/container/container_tests.hpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests1a.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests1b.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests2a.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests2b.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests3a.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests3b.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests4a.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests4b.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests5a.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests5b.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests6a.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/container/container_tests6b.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/core/
   branches/proto/v4/libs/phoenix/test/core/compose_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/core/primitives_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/detail/
   branches/proto/v4/libs/phoenix/test/detail/type_deduction_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/function/
   branches/proto/v4/libs/phoenix/test/function/function_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/object/
   branches/proto/v4/libs/phoenix/test/object/cast_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/object/new_delete_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/
   branches/proto/v4/libs/phoenix/test/operator/arithmetic_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/bitwise_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/comparison_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/if_else_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/io_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/logical_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/member.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/misc_binary_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/self_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/operator/unary_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/scope/
   branches/proto/v4/libs/phoenix/test/scope/bug_000008.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/scope/dynamic_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/scope/lambda_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/scope/let_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/statement/
   branches/proto/v4/libs/phoenix/test/statement/exceptions.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/statement/if_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/statement/loops_tests.cpp (contents, props changed)
   branches/proto/v4/libs/phoenix/test/statement/switch_tests.cpp (contents, props changed)

Added: branches/proto/v4/boost/phoenix/core.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/core.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,23 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_CORE_HPP
+#define PHOENIX_CORE_HPP
+
+#include <boost/phoenix/version.hpp>
+#include <boost/phoenix/core/limits.hpp>
+//#include <boost/phoenix/core/basic_environment.hpp>
+#include <boost/phoenix/core/actor.hpp>
+//#include <boost/phoenix/core/as_actor.hpp>
+//#include <boost/phoenix/core/is_actor.hpp>
+#include <boost/phoenix/core/argument.hpp>
+#include <boost/phoenix/core/value.hpp>
+#include <boost/phoenix/core/reference.hpp>
+//#include <boost/phoenix/core/compose.hpp>
+//#include <boost/phoenix/core/composite.hpp>
+//#include <boost/phoenix/core/nothing.hpp>
+
+#endif

Added: branches/proto/v4/boost/phoenix/core/actor.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/core/actor.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,343 @@
+#ifndef BOOST_PP_IS_ITERATING
+ /*=============================================================================
+ 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)
+ ==============================================================================*/
+ #ifndef BOOST_PHOENIX_ACTOR_HPP_EAN_2008_05_09
+ #define BOOST_PHOENIX_ACTOR_HPP_EAN_2008_05_09
+
+ #include <iosfwd>
+ #include <boost/phoenix/core/limits.hpp>
+ #include <boost/config.hpp>
+ #include <boost/mpl/if.hpp>
+ #include <boost/mpl/or.hpp>
+ #include <boost/mpl/and.hpp>
+ #include <boost/mpl/bool.hpp>
+ #include <boost/mpl/void.hpp>
+ #include <boost/mpl/identity.hpp>
+ #include <boost/proto/proto.hpp>
+ #include <boost/type_traits/is_abstract.hpp>
+ #include <boost/type_traits/is_function.hpp>
+ #include <boost/type_traits/is_base_of.hpp>
+ #include <boost/type_traits/add_reference.hpp>
+ #include <boost/type_traits/remove_const.hpp>
+ #include <boost/preprocessor.hpp>
+ #include <boost/utility/result_of.hpp>
+ #include <boost/fusion/include/vector.hpp>
+
+ namespace boost { namespace phoenix
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Tag, typename Void = void>
+ struct extension;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Value, typename Void = void>
+ struct terminal_extension
+ : proto::_expr
+ {
+ typedef void phoenix_terminal_extension_not_specialized_;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Value, typename Void = void>
+ struct is_terminal_extended
+ : mpl::true_
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Value>
+ struct is_terminal_extended<Value, typename terminal_extension<Value>::phoenix_terminal_extension_not_specialized_>
+ : mpl::false_
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Value, typename Void = void>
+ struct is_terminal_nullary
+ : mpl::true_
+ {};
+
+ namespace actorns_
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ struct actor;
+ }
+
+ using actorns_::actor;
+
+ namespace detail
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////
+ struct evaluator;
+ }
+
+ using detail::evaluator;
+
+ namespace detail
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // True when a lambda expression can be applied with no arguments and
+ // without an active exception object
+ struct is_nullary
+ : proto::or_<
+ proto::when<
+ proto::terminal<proto::_>
+ , is_terminal_nullary<proto::_value>()
+ >
+ , proto::when<
+ proto::_
+ , proto::fold<proto::_, mpl::true_(), mpl::and_<proto::_state, is_nullary>()>
+ >
+ >
+ {};
+
+ struct evaluator;
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ struct cases
+ {
+ template<typename Tag>
+ struct case_
+ : phoenix::extension<Tag>
+ {};
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ struct evaluator
+ : proto::switch_<cases>
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // These terminal types are always stored by reference
+ template<typename Value>
+ struct storage
+ {
+ typedef
+ typename mpl::eval_if_c<
+ mpl::or_<
+ is_abstract<Value>
+ , is_function<Value>
+ , is_base_of<std::ios_base, Value>
+ >::type::value
+ , add_reference<Value>
+ , remove_const<Value>
+ >::type
+ type;
+ };
+
+ template<typename T, std::size_t N>
+ struct storage<T[N]>
+ {
+ typedef T (&type)[N];
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // Store terminals by value, unless they are streams, arrays, functions or abstract types.
+ struct generator
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ {
+ typedef actor<Expr> type;
+ };
+
+ template<typename This, typename T>
+ struct result<This(proto::expr<proto::tag::terminal, proto::term<T &> >)>
+ {
+ typedef
+ actor<
+ proto::expr<
+ proto::tag::terminal
+ , proto::term<typename storage<T>::type>
+ >
+ >
+ type;
+ };
+
+ template<typename Expr>
+ actor<Expr> operator()(Expr const &expr) const
+ {
+ actor<Expr> that = {expr};
+ return that;
+ }
+
+ template<typename T>
+ actor<
+ proto::expr<
+ proto::tag::terminal
+ , proto::term<typename storage<T>::type>
+ >
+ >
+ operator()(proto::expr<proto::tag::terminal, proto::term<T &> > const &expr) const
+ {
+ actor<
+ proto::expr<
+ proto::tag::terminal
+ , proto::term<typename storage<T>::type>
+ >
+ > that = {{expr.child0}};
+ return that;
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ struct domain
+ : proto::domain<generator>
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Sig>
+ struct result;
+
+ template<typename This>
+ struct result<This()>
+ : mpl::if_c<
+ result_of<is_nullary(This &)>::type::value
+ , result_of<evaluator(This &, mpl::void_ const &, fusion::vector0 &)>
+ , mpl::identity<void>
+ >::type
+ {};
+
+ #define M0(Z, N, DATA) \
+ template<typename This BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, typename A)> \
+ struct result<This(BOOST_PP_ENUM_PARAMS_Z(Z, N, A))> \
+ : result_of< \
+ evaluator( \
+ This & \
+ , mpl::void_ const & \
+ , BOOST_PP_CAT(fusion::vector, N)<BOOST_PP_ENUM_PARAMS_Z(Z, N, A)> & \
+ ) \
+ > \
+ {}; \
+ /**/
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(PHOENIX_LIMIT), M0, ~)
+ #undef M0
+ }
+
+ namespace actorns_
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ struct actor
+ {
+ BOOST_PROTO_BASIC_EXTENDS(Expr, actor<Expr>, detail::domain)
+ BOOST_PROTO_EXTENDS_ASSIGN()
+ BOOST_PROTO_EXTENDS_SUBSCRIPT()
+
+ template<typename Sig>
+ struct result
+ : detail::result<Sig>
+ {};
+
+ typename result<Expr const()>::type
+ operator()() const
+ {
+ BOOST_MPL_ASSERT((proto::matches<Expr, evaluator>));
+ fusion::vector0 args;
+ return evaluator()(*this, mpl::void_(), args);
+ }
+
+ #define M0(Z, N, _) ((0))
+
+ #define M1(Z, N, _) ((0)(1))
+
+ #define M2(R, PRODUCT) M3(R, BOOST_PP_SEQ_SIZE(PRODUCT), PRODUCT)
+
+ #define M3(R, SIZE, PRODUCT) \
+ template<BOOST_PP_ENUM_PARAMS(SIZE, typename A)> \
+ typename result<Expr const(BOOST_PP_SEQ_FOR_EACH_I_R(R, M5, ~, PRODUCT))>::type \
+ operator ()(BOOST_PP_SEQ_FOR_EACH_I_R(R, M4, ~, PRODUCT)) const \
+ { \
+ BOOST_MPL_ASSERT((proto::matches<Expr, evaluator>)); \
+ BOOST_PP_CAT(fusion::vector, SIZE)<BOOST_PP_SEQ_FOR_EACH_I_R(R, M5, ~, PRODUCT)> args \
+ (BOOST_PP_SEQ_FOR_EACH_I_R(R, M6, ~, PRODUCT)); \
+ return evaluator()(*this, mpl::void_(), args); \
+ } \
+ /**/
+
+ #define M4(R, _, I, ELEM) \
+ BOOST_PP_COMMA_IF(I) BOOST_PP_CAT(A, I) BOOST_PP_CAT(C, ELEM) &BOOST_PP_CAT(a, I) \
+ /**/
+
+ #define M5(R, _, I, ELEM) \
+ BOOST_PP_COMMA_IF(I) BOOST_PP_CAT(A, I) BOOST_PP_CAT(C, ELEM)& \
+ /**/
+
+ #define M6(R, _, I, ELEM) \
+ BOOST_PP_COMMA_IF(I) BOOST_PP_CAT(a, I) \
+ /**/
+
+ #define C0
+
+ #define C1 const
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, PHOENIX_LIMIT, <boost/phoenix/core/actor.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ #undef C0
+ #undef C1
+ #undef M0
+ #undef M1
+ #undef M2
+ #undef M3
+ #undef M4
+ #undef M5
+ #undef M6
+ };
+
+ } // namespace actorns_
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Tag, typename Void>
+ struct extension
+ : proto::when<
+ proto::nary_expr<proto::_, proto::vararg<evaluator> >
+ , proto::_default<evaluator>
+ >
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<>
+ struct extension<proto::tag::terminal, void>
+ : proto::or_<
+ // If the handling of a particular terminal type has been
+ // overridden, invoke the specified handler.
+ proto::when<
+ proto::if_<is_terminal_extended<proto::_value>()>
+ , proto::lazy<terminal_extension<proto::_value> >
+ >
+ // Otherwise, just return the value of the terminal.
+ , proto::otherwise<proto::_value>
+ >
+ {};
+
+ }}
+
+ #endif
+
+#else
+
+ #if BOOST_PP_ITERATION() <= PHOENIX_PERFECT_FORWARD_LIMIT
+
+ BOOST_PP_SEQ_FOR_EACH_PRODUCT(
+ M2,
+ BOOST_PP_REPEAT(BOOST_PP_ITERATION(), M1, ~)
+ )
+
+ #else
+
+ BOOST_PP_SEQ_FOR_EACH_PRODUCT(
+ M2,
+ BOOST_PP_REPEAT(PHOENIX_PERFECT_FORWARD_LIMIT, M1, ~)
+ BOOST_PP_REPEAT(BOOST_PP_SUB(BOOST_PP_ITERATION(), PHOENIX_PERFECT_FORWARD_LIMIT), M0, ~)
+ )
+
+ #endif
+
+#endif

Added: branches/proto/v4/boost/phoenix/core/argument.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/core/argument.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,117 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_ARGUMENT_HPP_EAN_2008_05_10
+#define BOOST_PHOENIX_ARGUMENT_HPP_EAN_2008_05_10
+
+#include <iosfwd>
+#include <boost/config.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/next_prior.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/proto/proto.hpp>
+#include <boost/phoenix/core/limits.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+ namespace detail
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Int>
+ struct argument
+ {
+ typedef typename Int::tag tag;
+ typedef typename Int::value_type value_type;
+ typedef argument<Int> type;
+ typedef argument<typename Int::next> next;
+ typedef argument<typename Int::prior> prior;
+ BOOST_STATIC_CONSTANT(value_type, value = Int::value);
+
+ friend std::ostream &operator<<(std::ostream &sout, argument<Int>)
+ {
+ return sout << "boost::phoenix::arg_names::arg" << (Int::value+1);
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ struct at : proto::callable
+ {
+ template<class Sig>
+ struct result;
+
+ template<class This, class Cont, class Int>
+ struct result<This(Cont, Int)>
+ : fusion::result_of::at<
+ typename remove_reference<Cont>::type
+ , typename remove_reference<Int>::type
+ >
+ {};
+
+ template<typename Cont, typename Int>
+ typename fusion::result_of::at<Cont, Int>::type
+ operator ()(Cont &cont, Int const &) const
+ {
+ return fusion::at<Int>(cont);
+ }
+ };
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<int I, typename _ = proto::is_proto_expr>
+ struct argument
+ {
+ typedef
+ typename proto::terminal<detail::argument<mpl::int_<I> > >::type
+ base_type;
+
+ BOOST_PROTO_BASIC_EXTENDS(base_type, argument<I>, detail::domain)
+
+ // For backwards compatibility
+ operator actor<argument<I> > const &() const
+ {
+ return argument<I,_>::argI;
+ }
+
+ static actor<argument<I> > const argI;
+ };
+
+ template<int I, typename _>
+ actor<argument<I> > const argument<I,_>::argI = {{{{}}}};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Int, typename Void>
+ struct is_terminal_nullary;
+
+ template<typename Int>
+ struct is_terminal_nullary<detail::argument<Int>, void>
+ : mpl::false_
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Int, typename Void>
+ struct terminal_extension;
+
+ template<typename Int>
+ struct terminal_extension<detail::argument<Int>, void>
+ : proto::call<detail::at(proto::_data, proto::_value)>
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ namespace arg_names
+ {
+ actor<argument<0> > const arg1 = {{{{}}}};
+ actor<argument<1> > const arg2 = {{{{}}}};
+ actor<argument<2> > const arg3 = {{{{}}}};
+
+ actor<argument<0> > const _1 = {{{{}}}};
+ actor<argument<1> > const _2 = {{{{}}}};
+ actor<argument<2> > const _3 = {{{{}}}};
+ }
+
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/core/limits.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/core/limits.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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)
+==============================================================================*/
+#ifndef PHOENIX_CORE_LIMITS_HPP
+#define PHOENIX_CORE_LIMITS_HPP
+
+#if !defined(PHOENIX_LIMIT)
+# define PHOENIX_LIMIT 10
+#endif
+
+#if !defined(PHOENIX_PERFECT_FORWARD_LIMIT)
+# define PHOENIX_PERFECT_FORWARD_LIMIT 3
+#endif
+
+#if !defined(PHOENIX_ACTOR_LIMIT)
+# define PHOENIX_ACTOR_LIMIT PHOENIX_LIMIT
+#elif (PHOENIX_ACTOR_LIMIT > PHOENIX_LIMIT)
+# error "PHOENIX_ACTOR_LIMIT is set too high"
+#endif
+
+#if !defined(FUSION_MAX_TUPLE_SIZE)
+# define FUSION_MAX_TUPLE_SIZE PHOENIX_LIMIT
+#elif (FUSION_MAX_TUPLE_SIZE < PHOENIX_LIMIT)
+# error "FUSION_MAX_TUPLE_SIZE is set too low"
+#endif
+
+#if !defined(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY)
+# define BOOST_PROTO_MAX_FUNCTION_CALL_ARITY 5
+#endif
+
+#if defined(BOOST_PROTO_MAX_ARITY)
+# if BOOST_PROTO_MAX_ARITY < PHOENIX_LIMIT
+# error BOOST_PROTO_MAX_ARITY must be at least as large as PHOENIX_LIMIT
+# endif
+#else
+# define BOOST_PROTO_MAX_ARITY PHOENIX_LIMIT
+#endif
+
+#if defined(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
+# if BOOST_MPL_LIMIT_METAFUNCTION_ARITY < PHOENIX_LIMIT
+# error BOOST_MPL_LIMIT_METAFUNCTION_ARITY must be at least as large as PHOENIX_LIMIT
+# endif
+#else
+# define BOOST_MPL_LIMIT_METAFUNCTION_ARITY PHOENIX_LIMIT
+#endif
+
+// this include will bring in mpl::vectorN and
+// fusion::tupleN where N is PHOENIX_ACTOR_LIMIT
+#include <boost/fusion/include/vector.hpp>
+
+// OK, limits set. Include Proto.
+#include <boost/proto/proto.hpp>
+
+#endif

Added: branches/proto/v4/boost/phoenix/core/reference.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/core/reference.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,59 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_REFERENCE_HPP_EAN_2008_05_10
+#define BOOST_PHOENIX_REFERENCE_HPP_EAN_2008_05_10
+
+#include <boost/phoenix/core/limits.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+ namespace detail
+ {
+ struct domain;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
+ struct reference
+ : proto::extends<typename proto::terminal<T &>::type, reference<T>, detail::domain>
+ {
+ explicit reference(T &t)
+ : proto::extends<typename proto::terminal<T &>::type, reference<T>, detail::domain>(
+ proto::terminal<T &>::type::make(t)
+ )
+ {}
+
+ // For backwards compatibility
+ operator actor<reference<T> >() const
+ {
+ actor<reference<T> > that = {*this};
+ return that;
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
+ actor<typename proto::terminal<T &>::type> const
+ ref(T &t)
+ {
+ actor<typename proto::terminal<T &>::type> that = {{t}};
+ return that;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
+ actor<typename proto::terminal<T const &>::type> const
+ cref(T const &t)
+ {
+ actor<typename proto::terminal<T const &>::type> that = {{t}};
+ return that;
+ }
+
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/core/value.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/core/value.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,66 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_VALUE_HPP_EAN_2008_05_10
+#define BOOST_PHOENIX_VALUE_HPP_EAN_2008_05_10
+
+#include <boost/phoenix/core/limits.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+ namespace detail
+ {
+ struct domain;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
+ struct value
+ : proto::extends<typename proto::terminal<T>::type, value<T>, detail::domain>
+ {
+ explicit value(T const &t)
+ : proto::extends<typename proto::terminal<T>::type, value<T>, detail::domain>(
+ proto::terminal<T>::type::make(t)
+ )
+ {}
+
+ // For backwards compatibility
+ operator actor<value<T> >() const
+ {
+ actor<value<T> > that = {*this};
+ return that;
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
+ actor<typename proto::terminal<T>::type> const
+ val(T const &t)
+ {
+ actor<typename proto::terminal<T>::type> that = {{t}};
+ return that;
+ }
+
+ template<typename T, std::size_t N>
+ actor<typename proto::terminal<T(&)[N]>::type> const
+ val(T (&t)[N])
+ {
+ actor<typename proto::terminal<T(&)[N]>::type> that = {{t}};
+ return that;
+ }
+
+ template<typename T, std::size_t N>
+ actor<typename proto::terminal<T const(&)[N]>::type> const
+ val(T const (&t)[N])
+ {
+ actor<typename proto::terminal<T const(&)[N]>::type> that = {{t}};
+ return that;
+ }
+
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/operator.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/operator.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,20 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_OPERATOR_HPP
+#define PHOENIX_OPERATOR_HPP
+
+#include <boost/phoenix/version.hpp>
+//#include <boost/phoenix/operator/arithmetic.hpp>
+//#include <boost/phoenix/operator/bitwise.hpp>
+//#include <boost/phoenix/operator/comparison.hpp>
+#include <boost/phoenix/operator/if_else.hpp>
+//#include <boost/phoenix/operator/logical.hpp>
+//#include <boost/phoenix/operator/self.hpp>
+#include <boost/phoenix/operator/io.hpp>
+//#include <boost/phoenix/operator/member.hpp>
+
+#endif

Added: branches/proto/v4/boost/phoenix/operator/if_else.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/operator/if_else.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,17 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_OPERATOR_IF_ELSE_HPP
+#define PHOENIX_OPERATOR_IF_ELSE_HPP
+
+#include <boost/proto/proto.hpp>
+
+namespace boost { namespace phoenix
+{
+ using proto::if_else;
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/operator/io.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/operator/io.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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)
+==============================================================================*/
+#ifndef PHOENIX_OPERATOR_IO_HPP
+#define PHOENIX_OPERATOR_IO_HPP
+
+#include <iosfwd>
+#include <boost/phoenix/core/actor.hpp>
+#include <boost/proto/proto.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ namespace actorns_
+ {
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ actor<
+ typename proto::shift_left<
+ actor<Expr> const &
+ , proto::terminal<std::ostream &(*)(std::ostream &)>::type
+ >::type
+ > const
+ operator<<(actor<Expr> const &expr, std::ostream &(*omanip)(std::ostream &))
+ {
+ actor<
+ typename proto::shift_left<
+ actor<Expr> const &
+ , proto::terminal<std::ostream &(*)(std::ostream &)>::type
+ >::type
+ > that = {{expr, {omanip}}};
+ return that;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ actor<
+ typename proto::shift_left<
+ actor<Expr> const &
+ , proto::terminal<std::ios_base &(*)(std::ios_base &)>::type
+ >::type
+ > const
+ operator<<(actor<Expr> const &expr, std::ios_base &(*iomanip)(std::ios_base &))
+ {
+ actor<
+ typename proto::shift_left<
+ actor<Expr> const &
+ , proto::terminal<std::ios_base &(*)(std::ios_base &)>::type
+ >::type
+ > that = {{expr, {iomanip}}};
+ return that;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ actor<
+ typename proto::shift_right<
+ actor<Expr> const &
+ , proto::terminal<std::istream &(*)(std::istream &)>::type
+ >::type
+ > const
+ operator>>(actor<Expr> const &expr, std::istream &(*imanip)(std::istream &))
+ {
+ actor<
+ typename proto::shift_right<
+ actor<Expr> const &
+ , proto::terminal<std::istream &(*)(std::istream &)>::type
+ >::type
+ > that = {{expr, {imanip}}};
+ return that;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ actor<
+ typename proto::shift_right<
+ actor<Expr> const &
+ , proto::terminal<std::ios_base &(*)(std::ios_base &)>::type
+ >::type
+ > const
+ operator>>(actor<Expr> const &expr, std::ios_base &(*iomanip)(std::ios_base &))
+ {
+ actor<
+ typename proto::shift_right<
+ actor<Expr> const &
+ , proto::terminal<std::ios_base &(*)(std::ios_base &)>::type
+ >::type
+ > that = {{expr, {iomanip}}};
+ return that;
+ }
+ } // actorns_
+
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/statement.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/statement.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,20 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_STATEMENT_HPP
+#define PHOENIX_STATEMENT_HPP
+
+#include <boost/phoenix/version.hpp>
+//#include <boost/phoenix/statement/do_while.hpp>
+//#include <boost/phoenix/statement/for.hpp>
+#include <boost/phoenix/statement/if.hpp>
+//#include <boost/phoenix/statement/sequence.hpp>
+//#include <boost/phoenix/statement/switch.hpp>
+//#include <boost/phoenix/statement/while.hpp>
+//#include <boost/phoenix/statement/throw.hpp>
+//#include <boost/phoenix/statement/try_catch.hpp>
+
+#endif

Added: branches/proto/v4/boost/phoenix/statement/if.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/statement/if.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,209 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_IF_HPP_EAN_2008_05_09
+#define BOOST_PHOENIX_IF_HPP_EAN_2008_05_09
+
+#include <boost/ref.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/proto/proto.hpp>
+
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4355) // 'this' : used in base member initializer list
+#endif
+
+namespace boost { namespace phoenix
+{
+ template<typename Tag, typename Void>
+ struct extension;
+
+ namespace actorns_
+ {
+ template<typename Expr>
+ struct actor;
+ }
+
+ using actorns_::actor;
+
+ namespace detail
+ {
+ struct domain;
+ struct evaluator;
+ }
+
+ using detail::evaluator;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ namespace tag
+ {
+ struct if_ {};
+ struct else_ {};
+ }
+
+ namespace detail
+ {
+ // if_generator and else_generator are a bit of a hack to make
+ // the if_(foo)[bar].else_[baz] syntax work. Would be nice to have
+ // a cleaner mechanism for this, built into proto.
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ struct else_generator
+ {
+ typedef typename proto::result_of::left<Expr const &>::type condition_type;
+ typedef typename proto::result_of::right<Expr const &>::type body1_type;
+
+ explicit else_generator(Expr const &expr)
+ : if_(expr)
+ {}
+
+ template<typename Body2>
+ typename proto::result_of::make_expr<
+ tag::else_
+ , domain
+ , condition_type
+ , body1_type
+ , Body2 const &
+ >::type const
+ operator[](Body2 const &body2) const
+ {
+ return proto::implicit_expr(proto::left(this->if_), proto::right(this->if_), body2);
+ }
+
+ private:
+ Expr const &if_;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ struct actor_with_else : Expr
+ {
+ actor_with_else(Expr const &expr)
+ : Expr(expr)
+ , else_(*this)
+ {}
+
+ actor_with_else(actor_with_else const &that)
+ : Expr(that)
+ , else_(*this)
+ {}
+
+ else_generator<Expr> else_;
+
+ private:
+ actor_with_else &operator=(actor_with_else const &);
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Cond>
+ struct if_generator
+ {
+ explicit if_generator(Cond const &c)
+ : cond(c)
+ {}
+
+ template<typename Body>
+ actor_with_else<
+ typename proto::result_of::make_expr<
+ tag::if_
+ , domain
+ , Cond const &
+ , Body const &
+ >::type
+ > const
+ operator[](Body const &body) const
+ {
+ return proto::make_expr<tag::if_, domain>(boost::ref(this->cond), boost::ref(body));
+ }
+
+ private:
+ Cond const &cond;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // Proto transform that evaluates if_(condition)[ expression ]
+ struct if_evaluator : proto::transform<if_evaluator>
+ {
+ template<typename Expr, typename State, typename Data>
+ struct impl : proto::transform_impl<Expr, State, Data>
+ {
+ typedef void result_type;
+
+ result_type operator()(
+ typename impl::expr_param expr
+ , typename impl::state_param state
+ , typename impl::data_param data
+ ) const
+ {
+ if(evaluator()(proto::left(expr), state, data))
+ {
+ evaluator()(proto::right(expr), state, data);
+ }
+ }
+ };
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // Proto transform that evaluates if_(condition)[ expression ].else_[ expression ]
+ struct if_else_evaluator : proto::transform<if_else_evaluator>
+ {
+ template<typename Expr, typename State, typename Data>
+ struct impl : proto::transform_impl<Expr, State, Data>
+ {
+ typedef void result_type;
+
+ result_type operator()(
+ typename impl::expr_param expr
+ , typename impl::state_param state
+ , typename impl::data_param data
+ ) const
+ {
+ if(evaluator()(proto::child_c<0>(expr), state, data))
+ {
+ evaluator()(proto::child_c<1>(expr), state, data);
+ }
+ else
+ {
+ evaluator()(proto::child_c<2>(expr), state, data);
+ }
+ }
+ };
+ };
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ detail::if_generator<Expr> const if_(Expr const &expr)
+ {
+ return detail::if_generator<Expr>(expr);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<>
+ struct extension<tag::if_, void>
+ : proto::when<
+ proto::binary_expr<tag::if_, evaluator, evaluator>
+ , detail::if_evaluator
+ >
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<>
+ struct extension<tag::else_, void>
+ : proto::when<
+ proto::nary_expr<tag::else_, evaluator, evaluator, evaluator>
+ , detail::if_else_evaluator
+ >
+ {};
+
+}}
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+#endif

Added: branches/proto/v4/boost/phoenix/version.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/version.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,18 @@
+/*=============================================================================
+ Copyright (c) 2005-2008 Hartmut Kaiser
+ 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)
+==============================================================================*/
+#ifndef PHOENIX_VERSION_HPP
+#define PHOENIX_VERSION_HPP
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// This is the version of the library
+//
+///////////////////////////////////////////////////////////////////////////////
+#define BOOST_PHOENIX_VERSION 0x3000 // 3.0.0
+
+#endif

Added: branches/proto/v4/libs/phoenix/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/Jamfile.v2 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/algorithm/iteration.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/algorithm/iteration.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/stl/algorithm/iteration.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/algorithm/querying.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/algorithm/querying.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,270 @@
+/*=============================================================================
+ 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/phoenix/stl/algorithm/querying.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <set>
+#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));
+
+ 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: branches/proto/v4/libs/phoenix/test/algorithm/querying2.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/algorithm/querying2.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/stl.hpp/querying.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/algorithm/transformation1.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/algorithm/transformation1.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/stl/algorithm/transformation.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/algorithm/transformation2.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/algorithm/transformation2.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/stl/algorithm/transformation.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/algorithm/transformation3.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/algorithm/transformation3.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/stl/algorithm/transformation.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/algorithm/transformation4.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/algorithm/transformation4.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/stl/algorithm/transformation.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/bind/bind_function_object_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/bind/bind_function_object_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,106 @@
+/*=============================================================================
+ 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 Arg>
+ struct result
+ {
+ typedef Arg type;
+ };
+
+ template <typename Arg>
+ Arg operator()(Arg n) const
+ {
+ return n * n;
+ }
+ };
+
+ struct fact
+ {
+ template <typename Arg>
+ struct result
+ {
+ typedef Arg type;
+ };
+
+ template <typename Arg>
+ Arg operator()(Arg n) const
+ {
+ return (n <= 0) ? 1 : n * (*this)(n-1);
+ }
+ };
+
+ struct power
+ {
+ template <typename Arg1, typename Arg2>
+ struct result
+ {
+ 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)() == 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));
+
+ int const ic5 = 5;
+ // testing consts
+ BOOST_TEST(bind(sqr(), arg1)(ic5) == (ic5*ic5));
+
+ return boost::report_errors();
+}

Added: branches/proto/v4/libs/phoenix/test/bind/bind_function_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/bind/bind_function_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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)();
+ 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: branches/proto/v4/libs/phoenix/test/bind/bind_member_function_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/bind/bind_member_function_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,76 @@
+/*=============================================================================
+ 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)
+ {
+ return -n;
+ }
+ };
+
+ struct z : boost::noncopyable // test non-copyable (hold this by reference)
+ {
+ int
+ plus(int a, int b)
+ {
+ 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_)();
+ BOOST_TEST(bind(&test::y::negate, 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: branches/proto/v4/libs/phoenix/test/bind/bind_member_variable_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/bind/bind_member_variable_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,37 @@
+/*=============================================================================
+ 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;
+ };
+}
+
+int
+main()
+{
+ test::x x_;
+ bind(&test::x::m, x_)() = 123;
+ bind(&test::x::m, arg1)(x_) = 123;
+ BOOST_TEST(x_.m == 123);
+
+ return boost::report_errors();
+}

Added: branches/proto/v4/libs/phoenix/test/container/container_tests.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests.hpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/core.hpp>
+#include <boost/spirit/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: branches/proto/v4/libs/phoenix/test/container/container_tests1a.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests1a.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests1b.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests1b.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests2a.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests2a.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests2b.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests2b.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests3a.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests3a.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests3b.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests3b.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests4a.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests4a.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests4b.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests4b.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests5a.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests5a.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests5b.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests5b.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests6a.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests6a.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/container/container_tests6b.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/container/container_tests6b.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/core/compose_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/core/compose_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/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: branches/proto/v4/libs/phoenix/test/core/primitives_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/core/primitives_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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 <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,")() << val(' ')() << val("World")() << endl;
+ BOOST_TEST(val(3)() == 3);
+ BOOST_TEST(val("Hello, world")() == std::string("Hello, world"));
+ // WTF?
+ //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)() == ref(i)());
+ BOOST_TEST(cref(i)() == 4);
+ BOOST_TEST(i == 4);
+ BOOST_TEST(ref(++i)() == 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: branches/proto/v4/libs/phoenix/test/detail/type_deduction_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/detail/type_deduction_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/function/function_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/function/function_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,116 @@
+/*=============================================================================
+ 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 Arg>
+ struct result
+ {
+ typedef Arg type;
+ };
+
+ template <typename Arg>
+ Arg operator()(Arg n) const
+ {
+ return n * n;
+ }
+ };
+
+ function<sqr_impl> sqr;
+
+ struct fact_impl
+ {
+ template <typename Arg>
+ struct result
+ {
+ 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 Arg1, typename Arg2>
+ struct result
+ {
+ 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()();
+ BOOST_TEST(sqr(arg1)(i5) == (i5*i5));
+ BOOST_TEST(fact(4)() == 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: branches/proto/v4/libs/phoenix/test/object/cast_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/object/cast_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/core.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/object/new_delete_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/object/new_delete_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/core.hpp>
+#include <boost/phoenix/object.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/operator/arithmetic_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/arithmetic_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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)() == 123 + 456);
+ BOOST_TEST(x == 123 + 456);
+ BOOST_TEST((ref(x) -= 456)() == 123);
+ BOOST_TEST(x == 123);
+ BOOST_TEST((ref(x) *= 456)() == 123 * 456);
+ BOOST_TEST(x == 123 * 456);
+ BOOST_TEST((ref(x) /= 456)() == 123);
+ BOOST_TEST(x == 123);
+
+ int& r1 = (ref(x) += 456)(); // should be an lvalue
+ int& r2 = (ref(x) -= 456)(); // should be an lvalue
+ int& r3 = (ref(x) *= 456)(); // should be an lvalue
+ int& r4 = (ref(x) /= 456)(); // should be an lvalue
+ BOOST_TEST(r1 == 123 && r2 == 123 && r3 == 123 && r4 == 123);
+
+ BOOST_TEST((ref(x) %= 456)() == 123 % 456);
+ BOOST_TEST(x == 123 % 456);
+ }
+
+ {
+ BOOST_TEST((val(123) + 456)() == 123 + 456);
+ BOOST_TEST((val(123) - 456)() == 123 - 456);
+ BOOST_TEST((val(123) * 456)() == 123 * 456);
+ BOOST_TEST((val(123) / 456)() == 123 / 456);
+ BOOST_TEST((val(123) % 456)() == 123 % 456);
+
+ BOOST_TEST((123 + val(456))() == 123 + 456);
+ BOOST_TEST((123 - val(456))() == 123 - 456);
+ BOOST_TEST((123 * val(456))() == 123 * 456);
+ BOOST_TEST((123 / val(456))() == 123 / 456);
+ BOOST_TEST((123 % val(456))() == 123 % 456);
+ }
+
+ return boost::report_errors();
+}

Added: branches/proto/v4/libs/phoenix/test/operator/bitwise_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/bitwise_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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)();
+ y &= 456;
+ BOOST_TEST(x == y);
+
+ x = 123;
+ y = 123;
+ (ref(x) |= 456)();
+ y |= 456;
+ BOOST_TEST(x == y);
+
+ x = 123;
+ y = 123;
+ (ref(x) ^= 456)();
+ y ^= 456;
+ BOOST_TEST(x == y);
+
+ x = 123;
+ y = 123;
+ (ref(x) <<= 4)();
+ y <<= 4;
+ BOOST_TEST(x == y);
+
+ x = 1230000;
+ y = 1230000;
+ (ref(x) >>= 4)();
+ y >>= 4;
+ BOOST_TEST(x == y);
+
+ int& r1 = (ref(x) &= 456)(); // should be an lvalue
+ int& r2 = (ref(x) |= 456)(); // should be an lvalue
+ int& r3 = (ref(x) ^= 456)(); // should be an lvalue
+ int& r4 = (ref(x) <<= 4)(); // should be an lvalue
+ int& r5 = (ref(x) >>= 4)(); // should be an lvalue
+ BOOST_TEST(&r1 == &r2 && &r2 == &r3 && &r3 == &r4 && &r4 == &r5);
+ }
+
+ {
+ BOOST_TEST((val(123) & 456)() == (123 & 456));
+ BOOST_TEST((val(123) | 456)() == (123 | 456));
+ BOOST_TEST((val(123) ^ 456)() == (123 ^ 456));
+ BOOST_TEST((val(123) << 4)() == (123 << 4));
+ BOOST_TEST((val(1230000) >> 4)() == (1230000 >> 4));
+
+ char const* s = "Yabadabadoo!!!\n";
+ (cout << arg1)(s);
+ }
+
+ return boost::report_errors();
+}

Added: branches/proto/v4/libs/phoenix/test/operator/comparison_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/comparison_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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)());
+ BOOST_TEST((val(123) != 456)());
+ BOOST_TEST(!(val(123) > 456)());
+ BOOST_TEST((val(123) < 456)());
+ BOOST_TEST(!(val(123) > 456)());
+ BOOST_TEST((val(123) <= 123)());
+ BOOST_TEST((val(123) >= 123)());
+ }
+
+ return boost::report_errors();
+}

Added: branches/proto/v4/libs/phoenix/test/operator/if_else_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/if_else_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/operator/io_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/io_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,51 @@
+/*=============================================================================
+ 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>
+
+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))();
+
+ (cout << val(hello) << world << ", you da man!\n")();
+ for_each(v.begin(), v.end(), cout << arg1 << ',');
+
+ (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: branches/proto/v4/libs/phoenix/test/operator/logical_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/logical_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/operator/member.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/member.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/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 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)() == 1);
+ BOOST_TEST((val(cptr)->*&Test::value)() == 1);
+ BOOST_TEST((arg1->*&Test::value)(cptr) == 1);
+
+ ((val(ptr)->*&Test::value) = 2)();
+ BOOST_TEST(test.value == 2);
+
+ BOOST_TEST((val(ptr)->*&Test::func)(3)() == 3);
+ BOOST_TEST((val(cptr)->*&Test::func)(4)() == 4);
+ BOOST_TEST((val(ptr)->*&Test::dunc)()() == 10);
+
+ BOOST_TEST((arg1->*&Test::func)(5)(ptr) == 5);
+
+ 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: branches/proto/v4/libs/phoenix/test/operator/misc_binary_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/misc_binary_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,97 @@
+/*=============================================================================
+ 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::arg_names;
+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))() == 5);
+ BOOST_TEST((ref(i) = 3)() == 3);
+ BOOST_TEST(i == 3);
+ i = 5;
+ int x, y, z;
+ (ref(x) = ref(y) = ref(z) = 10)();
+ BOOST_TEST(x == 10 && y == 10 && z == 10);
+ BOOST_TEST((val(world)[3])() == world[3]);
+
+ BOOST_TEST((ref(i) += 5)() == 10);
+ BOOST_TEST((ref(i) -= 5)() == 5);
+ BOOST_TEST((ref(i) *= 5)() == 25);
+ BOOST_TEST((ref(i) /= 5)() == 5);
+ BOOST_TEST((ref(i) %= 2)() == 1);
+
+ BOOST_TEST((ref(i) <<= 3)() == 8);
+ BOOST_TEST((ref(i) >>= 1)() == 4);
+ BOOST_TEST((ref(i) |= 0xFF)() == 0xFF);
+ BOOST_TEST((ref(i) &= 0xF0)() == 0xF0);
+ BOOST_TEST((ref(i) ^= 0xFFFFFFFF)() == int(0xFFFFFF0F));
+
+ BOOST_TEST((val(5) == val(5))());
+ BOOST_TEST((val(5) == 5)());
+
+ 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))());
+ BOOST_TEST((val(5) < val(6))());
+ BOOST_TEST(!(val(5) > val(6))());
+ BOOST_TEST((val(5) < val(6))());
+ BOOST_TEST((val(5) <= val(6))());
+ BOOST_TEST((val(5) <= val(5))());
+ BOOST_TEST((val(7) >= val(6))());
+ BOOST_TEST((val(7) >= val(7))());
+
+ BOOST_TEST((val(false) && val(false))() == false);
+ BOOST_TEST((val(true) && val(false))() == false);
+ BOOST_TEST((val(false) && val(true))() == false);
+ BOOST_TEST((val(true) && val(true))() == true);
+
+ BOOST_TEST((val(false) || val(false))() == false);
+ BOOST_TEST((val(true) || val(false))() == true);
+ BOOST_TEST((val(false) || val(true))() == true);
+ BOOST_TEST((val(true) || val(true))() == 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: branches/proto/v4/libs/phoenix/test/operator/self_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/self_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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
+ 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");
+
+ // TODO fix me ... how?
+ //map<string, int> m;
+ //(arg1["Kimpo"] = arg2)(m, x);
+ //BOOST_TEST(m["Kimpo"] == x);
+ }
+
+ return boost::report_errors();
+}

Added: branches/proto/v4/libs/phoenix/test/operator/unary_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/operator/unary_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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))() == -123);
+ BOOST_TEST((- -val(123))() == 123);
+ BOOST_TEST((+val(123))() == 123);
+ }
+
+ {
+ int x = 123;
+
+ BOOST_TEST((++ref(x))() == 124);
+ BOOST_TEST(x == 124);
+ BOOST_TEST((--ref(x))() == 123);
+ BOOST_TEST(x == 123);
+
+ BOOST_TEST((ref(x)++)() == 123);
+ BOOST_TEST(x == 124);
+ BOOST_TEST((ref(x)--)() == 124);
+ BOOST_TEST(x == 123);
+
+ int& r1 = (++ref(x))(); // should be an lvalue
+ int& r2 = (--ref(x))(); // 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))() == false);
+ BOOST_TEST((-val(1))() == -1);
+ BOOST_TEST((+val(1))() == +1);
+ BOOST_TEST((~val(1))() == ~1);
+ BOOST_TEST(*(&arg1)(i1) == *(&i1));
+ BOOST_TEST((&arg1)(i1) == &i1);
+
+ BOOST_TEST((*val(&i1))() == *(&i1));
+ BOOST_TEST((*&arg1)(i1) == *(&i1));
+ BOOST_TEST((++ref(i))() == 6);
+ BOOST_TEST((--ref(i))() == 5);
+ BOOST_TEST((ref(i)++)() == 5);
+ BOOST_TEST(i == 6);
+ BOOST_TEST((ref(i)--)() == 6);
+ BOOST_TEST(i == 5);
+ }
+
+ return boost::report_errors();
+}

Added: branches/proto/v4/libs/phoenix/test/scope/bug_000008.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/scope/bug_000008.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,96 @@
+/*=============================================================================
+ 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>
+
+#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/phoenix/operator.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/scope/dynamic_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/scope/dynamic_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/scope.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: branches/proto/v4/libs/phoenix/test/scope/lambda_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/scope/lambda_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -0,0 +1,179 @@
+/*=============================================================================
+ 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/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/scope.hpp>
+#include <boost/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
+ );
+ }
+
+ {
+ int x = (let(_a = lambda[val(1)])[_a])()();
+ BOOST_TEST(x == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: branches/proto/v4/libs/phoenix/test/scope/let_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/scope/let_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/scope.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/statement/exceptions.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/statement/exceptions.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/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: branches/proto/v4/libs/phoenix/test/statement/if_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/statement/if_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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: branches/proto/v4/libs/phoenix/test/statement/loops_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/statement/loops_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/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);
+ 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: branches/proto/v4/libs/phoenix/test/statement/switch_tests.cpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/libs/phoenix/test/statement/switch_tests.cpp 2008-05-11 20:13:35 EDT (Sun, 11 May 2008)
@@ -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/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);
+
+ 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