Reverted to 194

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@199 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2011-01-18 08:20:39 +00:00
parent de3b33ba9b
commit 2c5ec08093
3 changed files with 53 additions and 35 deletions

View file

@ -13,7 +13,6 @@
#include "constraints.hpp"
#include "operators.hpp"
#include "format.hpp"
#include "lambda.hpp"
#include <boost/function.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/concept_check.hpp>
@ -31,8 +30,8 @@ namespace detail
BOOST_CONCEPT_USAGE( FunctorCompatible )
{
boost::require_boolean_expr(
// if an error is generated by the line below it means
// an argument passed to 'with' was of the wrong type.
// if an error is generated by the line below it means an argument
// passed to 'with' was of the wrong type.
functor_accepts( actual_argument_type )
);
}
@ -49,8 +48,8 @@ namespace detail
BOOST_CONCEPT_USAGE( EqualityComparable )
{
boost::require_boolean_expr(
// if an error is generated by the line below it means
// an argument passed to 'with' was of the wrong type.
// if an error is generated by the line below it means an argument
// passed to 'with' was of the wrong type.
actual_argument_type == expected_argument_type
);
}
@ -69,7 +68,7 @@ namespace detail
BOOST_DEDUCED_TYPENAME boost::enable_if<
BOOST_DEDUCED_TYPENAME detail::is_functor< Functor >
>::type* = 0 )
: desc_( bind( &serialize< Functor >, _1, f ) )
: desc_( mock::format( f ) )
{
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Functor, Actual > ));
f_ = f;
@ -81,18 +80,18 @@ namespace detail
BOOST_DEDUCED_TYPENAME boost::disable_if<
BOOST_DEDUCED_TYPENAME detail::is_functor< Expected >
>::type* = 0 )
: desc_( bind( &serialize< Expected >, _1, expected ) )
: desc_( mock::format( expected ) )
{
BOOST_CONCEPT_ASSERT(( EqualityComparable< Expected, Actual > ));
f_ = mock::equal( expected ).f_;
if( ! f_ )
std::invalid_argument( "invalid constraint" );
}
template< typename Constraint >
explicit check( const constraint< Constraint >& ph )
: desc_( bind( &serialize< Constraint >, _1, ph.f_ ) )
template< typename Functor >
explicit check( const constraint< Functor >& ph )
: desc_( mock::format( ph.f_ ) )
{
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Constraint, Actual > ));
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Functor, Actual > ));
f_ = ph.f_;
if( ! f_ )
std::invalid_argument( "invalid constraint" );
@ -105,20 +104,12 @@ namespace detail
friend std::ostream& operator<<( std::ostream& s, const check& c )
{
c.desc_( s );
return s;
}
private:
template< typename T >
static void serialize( std::ostream& s, T t )
{
s << mock::format( t );
return s << c.desc_;
}
private:
boost::function< bool( Actual ) > f_;
boost::function< void( std::ostream& ) > desc_;
std::string desc_;
};
}
}

View file

@ -13,8 +13,9 @@
#ifdef MOCK_USE_BOOST_BIND
#include <boost/bind.hpp>
#else
#include <boost/spirit/home/phoenix/bind.hpp>
#include <boost/spirit/home/phoenix/core/argument.hpp>
#include <boost/spirit/home/phoenix/statement/throw.hpp>
#include <boost/spirit/home/phoenix/operator/self.hpp>
#include <boost/spirit/home/phoenix/core/nothing.hpp>
#endif
#include <boost/function.hpp>
@ -22,13 +23,8 @@ namespace mock
{
namespace detail
{
#ifdef MOCK_USE_BOOST_BIND
using boost::bind;
#else
using boost::phoenix::bind;
using boost::phoenix::arg_names::_1;
#endif
#ifdef MOCK_USE_BOOST_BIND
template< typename Result, typename Signature >
struct lambda
{
@ -38,21 +34,21 @@ namespace detail
template< typename T >
static functor_type make_val( T t )
{
return bind( &do_identity< T >, t );
return boost::bind( &do_identity< T >, t );
}
template< typename T >
static functor_type make_val( boost::reference_wrapper< T > t )
{
return bind( &do_ref_identity< T >, t.get_pointer() );
return boost::bind( &do_ref_identity< T >, t.get_pointer() );
}
template< typename T >
static functor_type make_throw( T t )
{
return bind( &do_throw< T >, t );
return boost::bind( &do_throw< T >, t );
}
static functor_type make_nothing()
{
return bind( &do_nothing );
return boost::bind( &do_nothing );
}
template< typename T >
@ -74,6 +70,37 @@ namespace detail
{
}
};
#else
template< typename Result, typename Signature >
struct lambda
{
typedef BOOST_DEDUCED_TYPENAME
boost::function< Signature > functor_type;
template< typename T >
static functor_type make_val( T t )
{
return boost::phoenix::val( t );
}
template< typename T >
static functor_type make_val( boost::reference_wrapper< T > t )
{
return *boost::phoenix::val( t.get_pointer() );
}
template< typename T >
static functor_type make_throw( T t )
{
return boost::phoenix::throw_( t );
}
static functor_type make_nothing()
{
return boost::phoenix::nothing;
}
};
#endif
}
}

View file

@ -98,9 +98,9 @@ namespace detail
template< typename Functor >
const constraint< detail::not_< Functor > >
operator!( const constraint< Functor >& c )
operator!( const constraint< Functor >& ph )
{
return detail::not_< Functor >( c.f_ );
return detail::not_< Functor >( ph.f_ );
}
}