diff --git a/test/public_function/contracts.hpp b/test/public_function/contracts.hpp index feb85f4..1195d42 100644 --- a/test/public_function/contracts.hpp +++ b/test/public_function/contracts.hpp @@ -74,6 +74,7 @@ result_type& t::f(s_type& s, boost::contract::virtual_* v) { .postcondition([&] (result_type const& result) { out << Id << "::f::post" << std::endl; BOOST_CONTRACT_ASSERT(z.value == old_z->value + old_s->value); + std::clog << Id << "::f::post OUT" << std::endl; BOOST_CONTRACT_ASSERT(s.value.find(old_z->value) != std::string::npos); BOOST_CONTRACT_ASSERT(result.value == old_s->value); @@ -89,6 +90,15 @@ result_type& t::f(s_type& s, boost::contract::virtual_* v) { return result; } +struct u { + u() { std::cout << "!!!!! u default ctor" << std::endl; } + u(u const&) { std::cout << "!!!!! u copy ctor" << std::endl; } + ~u() { std::cout << "!!!!! u dtor" << std::endl; } +private: + u& operator=(u const&); + +}; + // Test base with other bases, multiple inheritance, and no subcontracting from // protected and private bases (even if fully contracted). struct c @@ -109,7 +119,9 @@ struct c typedef boost::contract::test::detail::counter y_type; y_type y; - c() { y.value = "c"; } + c() : uu() { y.value = "c"; } + + u uu; virtual result_type& f(s_type& s, boost::contract::virtual_* v = 0) /* override */ { @@ -117,6 +129,7 @@ struct c boost::contract::old_ptr old_y = BOOST_CONTRACT_OLD(v, y_type::eval(y)); boost::contract::old_ptr old_s; + boost::contract::old_ptr old_u; boost::contract::check c = boost::contract::public_function< override_f>(v, result, &c::f, this, s) .precondition([&] { @@ -126,9 +139,12 @@ struct c .old([&] { out << "c::f::old" << std::endl; old_s = BOOST_CONTRACT_OLD(v, s_type::eval(s)); + // TODO: Fix bug for this old_u... + old_u = BOOST_CONTRACT_OLD(v, uu); }) .postcondition([&] (result_type const& result) { out << "c::f::post" << std::endl; + std::clog << "c::f::post OUT" << std::endl; BOOST_CONTRACT_ASSERT(y.value == old_y->value + old_s->value); BOOST_CONTRACT_ASSERT(s.value.find(old_y->value) != std::string::npos); diff --git a/test/public_function/contracts-old_value_bug.hpp b/test/public_function/contracts.hpp.ok similarity index 94% rename from test/public_function/contracts-old_value_bug.hpp rename to test/public_function/contracts.hpp.ok index 70740b5..feb85f4 100644 --- a/test/public_function/contracts-old_value_bug.hpp +++ b/test/public_function/contracts.hpp.ok @@ -74,7 +74,6 @@ result_type& t::f(s_type& s, boost::contract::virtual_* v) { .postcondition([&] (result_type const& result) { out << Id << "::f::post" << std::endl; BOOST_CONTRACT_ASSERT(z.value == old_z->value + old_s->value); - std::clog << Id << "::f::post OUT" << std::endl; BOOST_CONTRACT_ASSERT(s.value.find(old_z->value) != std::string::npos); BOOST_CONTRACT_ASSERT(result.value == old_s->value); @@ -90,15 +89,6 @@ result_type& t::f(s_type& s, boost::contract::virtual_* v) { return result; } -struct u { - u() { std::cout << "!!!!! u default ctor" << std::endl; } - u(u const&) { std::cout << "!!!!! u copy ctor" << std::endl; } - ~u() { std::cout << "!!!!! u dtor" << std::endl; } -private: - u& operator=(u const&); - -}; - // Test base with other bases, multiple inheritance, and no subcontracting from // protected and private bases (even if fully contracted). struct c @@ -119,9 +109,7 @@ struct c typedef boost::contract::test::detail::counter y_type; y_type y; - c() : uu() { y.value = "c"; } - - u uu; + c() { y.value = "c"; } virtual result_type& f(s_type& s, boost::contract::virtual_* v = 0) /* override */ { @@ -129,7 +117,6 @@ struct c boost::contract::old_ptr old_y = BOOST_CONTRACT_OLD(v, y_type::eval(y)); boost::contract::old_ptr old_s; - boost::contract::old_ptr old_u; boost::contract::check c = boost::contract::public_function< override_f>(v, result, &c::f, this, s) .precondition([&] { @@ -139,11 +126,9 @@ struct c .old([&] { out << "c::f::old" << std::endl; old_s = BOOST_CONTRACT_OLD(v, s_type::eval(s)); - old_u = BOOST_CONTRACT_OLD(v, uu); }) .postcondition([&] (result_type const& result) { out << "c::f::post" << std::endl; - std::clog << "c::f::post OUT" << std::endl; BOOST_CONTRACT_ASSERT(y.value == old_y->value + old_s->value); BOOST_CONTRACT_ASSERT(s.value.find(old_y->value) != std::string::npos);