diff options
author | Igor Murashkin <iam@google.com> | 2018-03-22 14:28:07 -0700 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2018-08-09 17:04:15 -0700 |
commit | da5396314d890d66fcd38d6cc5c61ab6d37b476c (patch) | |
tree | 10110cbe185cfb37743a75e941fe149e26171134 /Rx/v2/test/subscriptions/observer.cpp | |
parent | 122c10b47aa429775a58abe86b4240bebc7da4a1 (diff) | |
download | RxCpp-da5396314d890d66fcd38d6cc5c61ab6d37b476c.tar.gz |
Rx: Add support for compiling code without exceptions (-fno-exceptions)
std::exception_ptr usage is replaced with rxcpp::util::error_ptr
which will typedef to std::exception_ptr when exceptions are enabled.
When exceptions are disabled this will typedef to an internal error
type that can retain the "what" error message.
Additionally std::current_exception() and similar usages are replaced
with rxu::current_exception which uses error_ptr instead.
Lastly all try/catch/throw keywords are replaced with either
RXCPP_TRY, RXCPP_CATCH, rxu::throw_exception or similar.
Note that try/catch/throw keywords cause a compilation error with
-fno-exceptions. Trying to access most of the std::*exception* functions
will call std::terminate at runtime.
Tests using exceptions must be disabled by passing --nothrow to the
check2 test runner.
Change-Id: I0b95ae2e323653a17c3b733d165ecf87a014c315
Diffstat (limited to 'Rx/v2/test/subscriptions/observer.cpp')
-rw-r--r-- | Rx/v2/test/subscriptions/observer.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Rx/v2/test/subscriptions/observer.cpp b/Rx/v2/test/subscriptions/observer.cpp index 57d4ad1..894e610 100644 --- a/Rx/v2/test/subscriptions/observer.cpp +++ b/Rx/v2/test/subscriptions/observer.cpp @@ -4,7 +4,7 @@ SCENARIO("subscriber traits", "[observer][traits]"){ GIVEN("given some subscriber types"){ int result = 0; auto next = [&result](int i){result += i;}; - auto error = [&result](std::exception_ptr){result += 10;}; + auto error = [&result](rxu::error_ptr){result += 10;}; auto completed = [&result](){result += 100;}; // auto ra = rx::rxu::detail::arg_resolver_n<0, rx::tag_resumption_resolution::template predicate, typename rx::tag_resumption_resolution::default_type, rx::resumption, decltype(next), decltype(error), decltype(completed), rx::rxu::detail::tag_unresolvable, rx::rxu::detail::tag_unresolvable>(rx::resumption(), next, error, completed, rx::rxu::detail::tag_unresolvable(), rx::rxu::detail::tag_unresolvable()); // auto ra = typename rx::rxu::detail::arg_resolver<rx::tag_resumption_resolution::template predicate, typename rx::tag_resumption_resolution::default_type, rx::resumption, decltype(next), decltype(error), decltype(completed)>::type(rx::resumption(), next, error, completed, rx::rxu::detail::tag_unresolvable(), rx::rxu::detail::tag_unresolvable()); @@ -45,7 +45,7 @@ SCENARIO("subscriber traits", "[observer][traits]"){ } WHEN("after error"){ THEN("subscriber result is 10"){ - scrbResult.on_error(std::current_exception()); + scrbResult.on_error(rxu::current_exception()); REQUIRE(result == 10); } } @@ -102,7 +102,7 @@ SCENARIO("subscriber behavior", "[observer][traits]"){ GIVEN("given some subscriber types"){ int result = 0; auto next = [&result](int i){result += i;}; - auto error = [&result](std::exception_ptr){result += 10;}; + auto error = [&result](rxu::error_ptr){result += 10;}; auto completed = [&result](){result += 100;}; auto dob = rx::make_subscriber<int>(rx::make_observer_dynamic<int>(next, error, completed)); auto so = rx::make_subscriber<int>(next, error, completed); @@ -143,19 +143,19 @@ SCENARIO("subscriber behavior", "[observer][traits]"){ } WHEN("after error"){ THEN("dynamic_observer result is 10"){ - dob.on_error(std::current_exception()); + dob.on_error(rxu::current_exception()); REQUIRE(result == 10); } THEN("static_observer result is 10"){ - so.on_error(std::current_exception()); + so.on_error(rxu::current_exception()); REQUIRE(result == 10); } THEN("dynamic_observer is not subscribed"){ - dob.on_error(std::current_exception()); + dob.on_error(rxu::current_exception()); REQUIRE(!dob.is_subscribed()); } THEN("static_observer is not subscribed"){ - so.on_error(std::current_exception()); + so.on_error(rxu::current_exception()); REQUIRE(!so.is_subscribed()); } } |