diff --git a/src/libraries/turtle/action.hpp b/src/libraries/turtle/action.hpp index 5e1b61d..20b2ab0 100644 --- a/src/libraries/turtle/action.hpp +++ b/src/libraries/turtle/action.hpp @@ -11,6 +11,9 @@ #include "config.hpp" #include +#include +#include +#include #include #include #include @@ -40,7 +43,7 @@ namespace detail template< typename Y > void returns( const boost::reference_wrapper< Y >& r ) { - f_ = boost::phoenix::val( r ); + f_ = *boost::phoenix::val( r.get_pointer() ); } void calls( const functor_type& f ) @@ -53,7 +56,7 @@ namespace detail template< typename Exception > void throws( Exception e ) { - f_ = boost::phoenix::bind( &throw_exception< Exception >, e ); + f_ = boost::phoenix::throw_( e ); } const functor_type& functor() const @@ -62,13 +65,6 @@ namespace detail } private: - - template< typename Exception > - static Result throw_exception( const Exception& e ) - { - throw e; - } - boost::shared_ptr< result_type > r_; functor_type f_; }; @@ -100,7 +96,7 @@ namespace detail template< typename Exception > void throws( Exception e ) { - f_ = boost::phoenix::bind( &throw_exception< Exception >, e ); + f_ = boost::phoenix::throw_( e ); } const functor_type& functor() const @@ -109,12 +105,6 @@ namespace detail } private: - template< typename Exception > - static Result* throw_exception( const Exception& e ) - { - throw e; - } - functor_type f_; }; @@ -126,7 +116,7 @@ namespace detail public: action() - : f_( boost::phoenix::bind( ¬hing ) ) + : f_( boost::phoenix::nothing ) {} void calls( const functor_type& f ) @@ -139,7 +129,7 @@ namespace detail template< typename Exception > void throws( Exception e ) { - f_ = boost::phoenix::bind( &throw_exception< Exception >, e ); + f_ = boost::phoenix::throw_( e ); } const functor_type& functor() const @@ -148,15 +138,6 @@ namespace detail } private: - static void nothing() - {} - - template< typename Exception > - static void throw_exception( const Exception& e ) - { - throw e; - } - functor_type f_; }; @@ -192,7 +173,7 @@ namespace detail template< typename Exception > void throws( Exception e ) { - f_ = boost::phoenix::bind( &throw_exception< Exception >, e ); + f_ = boost::phoenix::throw_( e ); r_.reset(); } @@ -221,12 +202,6 @@ namespace detail f_ = boost::phoenix::val( boost::ref( r_ ) ); } - template< typename Exception > - static std::auto_ptr< Result > throw_exception( const Exception& e ) - { - throw e; - } - mutable std::auto_ptr< Result > r_; functor_type f_; }; diff --git a/src/tests/turtle_test/integration_test.cpp b/src/tests/turtle_test/integration_test.cpp index 845e523..714338b 100644 --- a/src/tests/turtle_test/integration_test.cpp +++ b/src/tests/turtle_test/integration_test.cpp @@ -16,6 +16,7 @@ #include #include +#include #include namespace @@ -293,3 +294,19 @@ BOOST_AUTO_TEST_CASE( failed_sequence_in_mocked_destructor_does_not_throw ) m.my_method(); } } + +namespace +{ + MOCK_CLASS( boost_optional ) + { + MOCK_METHOD_EXT( method, 0, boost::optional< my_observer& >(), method ) + }; +} + +BOOST_AUTO_TEST_CASE( boost_optional_on_base_class_reference_as_return_type ) +{ + boost_optional b; + my_mock_observer o; + MOCK_EXPECT( b, method ).once().returns( boost::ref( o ) ); + b.method(); +}