From bf4335d602731e387476a65b7c7262c5216a5170 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Fri, 3 Mar 2017 13:34:09 +0100 Subject: [PATCH] Store the result of expect completion tests on the heap --- include/continuable/continuable-testing.hpp | 8 +++--- test/unit-test/test-continuable-base.cpp | 31 +++++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/include/continuable/continuable-testing.hpp b/include/continuable/continuable-testing.hpp index b29a852..3a3b518 100644 --- a/include/continuable/continuable-testing.hpp +++ b/include/continuable/continuable-testing.hpp @@ -42,10 +42,10 @@ inline namespace abi_v1 { namespace detail { namespace testing { template void expect_async_completion(C&& continuable) { - bool called = false; - std::forward(continuable).then([&](auto&&... args) { - ASSERT_FALSE(called); - called = true; + auto called = std::make_shared(false); + std::forward(continuable).then([called](auto&&... args) { + ASSERT_FALSE(*called); + *called = true; // Workaround for our known GCC bug. util::unused(std::forward(args)...); diff --git a/test/unit-test/test-continuable-base.cpp b/test/unit-test/test-continuable-base.cpp index 14cdfda..8e7076c 100644 --- a/test/unit-test/test-continuable-base.cpp +++ b/test/unit-test/test-continuable-base.cpp @@ -58,21 +58,36 @@ template auto assert_invocation(T* me) { [](auto&& /*callback*/) mutable { FAIL(); }); } -TYPED_TEST(single_dimension_tests, are_incomplete_when_released) { - auto chain = this->supply(); - chain.release(); - EXPECT_ASYNC_INCOMPLETE(std::move(chain)); +TYPED_TEST(single_dimension_tests, are_incomplete_when_frozen) { + { + auto chain = this->supply(); + chain.freeze(); + EXPECT_ASYNC_INCOMPLETE(std::move(chain)); + } + + { + auto chain = this->supply(); + chain.freeze(); + EXPECT_ASYNC_INCOMPLETE(std::move(chain).then(this->supply())); + } } -TYPED_TEST(single_dimension_tests, are_not_dispatched_when_released) { +TYPED_TEST(single_dimension_tests, are_not_dispatched_when_frozen) { auto chain = assert_invocation(this); - chain.release(); + chain.freeze(); EXPECT_ASYNC_INCOMPLETE(std::move(chain)); } TYPED_TEST(single_dimension_tests, are_not_finished_when_not_continued) { - auto chain = create_incomplete(this); - EXPECT_ASYNC_INCOMPLETE(std::move(chain)); + { + auto chain = create_incomplete(this); + EXPECT_ASYNC_INCOMPLETE(std::move(chain)); + } + + { + auto chain = create_incomplete(this); + EXPECT_ASYNC_INCOMPLETE(std::move(chain).then(this->supply())); + } } TYPED_TEST(single_dimension_tests, are_chainable) {