diff --git a/include/continuable/detail/core/base.hpp b/include/continuable/detail/core/base.hpp index 66fad45..083a2cc 100644 --- a/include/continuable/detail/core/base.hpp +++ b/include/continuable/detail/core/base.hpp @@ -293,16 +293,6 @@ constexpr void invoke_no_except(T&& callable, Args&&... args) noexcept { std::forward(callable)(std::forward(args)...); } -template -void invoke_void_no_except(identity, - T&& /*callable*/) noexcept { - // Don't invoke the next failure handler when being in an exception handler -} -template -void invoke_void_no_except(identity, T&& callable) noexcept { - std::forward(callable)(); -} - template constexpr auto make_invoker(T&& invoke, identity) { return invoker, identity>(std::forward(invoke)); @@ -373,9 +363,8 @@ inline auto invoker_of(identity) { CONTINUABLE_BLOCK_TRY_BEGIN invoke_callback(std::forward(callback), std::forward(args)...); - invoke_void_no_except( - identity...>{}, - std::forward(next_callback)); + + invoke_no_except(std::forward(next_callback)); CONTINUABLE_BLOCK_TRY_END }, identity<>{}); diff --git a/test/unit-test/async/test-continuable-async.cpp b/test/unit-test/async/test-continuable-async.cpp index 84a7c48..dc235b3 100644 --- a/test/unit-test/async/test-continuable-async.cpp +++ b/test/unit-test/async/test-continuable-async.cpp @@ -194,3 +194,15 @@ TYPED_TEST(single_dimension_tests, token_remap_ignore) { ASSERT_TRUE(value.is_value()); } + +TYPED_TEST(single_dimension_tests, wait_test_issue_46) { + bool handled = false; + make_exceptional_continuable(supply_test_exception()) + .fail([&]{ + EXPECT_FALSE(handled); + handled = true; + }) + .apply(cti::transforms::wait()); + + ASSERT_TRUE(handled); +} \ No newline at end of file diff --git a/test/unit-test/multi/test-continuable-base-errors.cpp b/test/unit-test/multi/test-continuable-base-errors.cpp index 35f1641..f7fea7d 100644 --- a/test/unit-test/multi/test-continuable-base-errors.cpp +++ b/test/unit-test/multi/test-continuable-base-errors.cpp @@ -39,7 +39,7 @@ TYPED_TEST(single_dimension_tests, are_yielding_error_result) { get_test_exception_proto()); } -TYPED_TEST(single_dimension_tests, are_never_completed_after_error_handled) { +TYPED_TEST(single_dimension_tests, are_completed_after_error_handled) { auto handled = std::make_shared(false); auto continuation = this->supply_exception(supply_test_exception()) .fail([handled](cti::exception_t) { @@ -47,10 +47,23 @@ TYPED_TEST(single_dimension_tests, are_never_completed_after_error_handled) { *handled = true; }); - ASSERT_ASYNC_INCOMPLETION(std::move(continuation)); + ASSERT_ASYNC_COMPLETION(std::move(continuation)); ASSERT_TRUE(*handled); } +TYPED_TEST(single_dimension_tests, are_recoverable_after_error_handled) { + auto recovered = std::make_shared(false); + auto continuation = this->supply_exception(supply_test_exception()) + .fail([](cti::exception_t){}) + .then([recovered]{ + ASSERT_FALSE(*recovered); + *recovered = true; + }); + + ASSERT_ASYNC_COMPLETION(std::move(continuation)); + ASSERT_TRUE(*recovered); +} + TYPED_TEST(single_dimension_tests, fail_is_accepting_plain_continuables) { auto handled = std::make_shared(false); auto handler = this->supply().then([handled] { @@ -61,7 +74,7 @@ TYPED_TEST(single_dimension_tests, fail_is_accepting_plain_continuables) { auto continuation = this->supply_exception(supply_test_exception()).fail(std::move(handler)); - ASSERT_ASYNC_INCOMPLETION(std::move(continuation)); + ASSERT_ASYNC_COMPLETION(std::move(continuation)); ASSERT_TRUE(*handled); } @@ -109,13 +122,13 @@ TYPED_TEST(single_dimension_tests, are_flow_error_accepting) { *handled = true; })); - ASSERT_ASYNC_INCOMPLETION(std::move(continuation)); + ASSERT_ASYNC_COMPLETION(std::move(continuation)); ASSERT_TRUE(*handled); } TYPED_TEST(single_dimension_tests, are_exceptions_partial_applyable) { bool handled = false; - ASSERT_ASYNC_INCOMPLETION( + ASSERT_ASYNC_COMPLETION( this->supply_exception(supply_test_exception()).fail([&]() -> void { EXPECT_FALSE(handled); handled = true; diff --git a/test/unit-test/multi/test-continuable-base-multipath.cpp b/test/unit-test/multi/test-continuable-base-multipath.cpp index 89c72d5..2121ddc 100644 --- a/test/unit-test/multi/test-continuable-base-multipath.cpp +++ b/test/unit-test/multi/test-continuable-base-multipath.cpp @@ -170,10 +170,12 @@ TYPED_TEST(single_dimension_tests, multipath_exception_is_continuable) { TYPED_TEST(single_dimension_tests, multipath_exception_is_autocanceled) { bool caught = false; - ASSERT_ASYNC_INCOMPLETION( + ASSERT_ASYNC_COMPLETION( this->supply_exception(supply_test_exception()).fail([&](exception_t) { EXPECT_FALSE(caught); caught = true; + }).fail([](exception_t){ + FAIL(); })); ASSERT_TRUE(caught); }