diff options
author | iam <igor.murashkin+github@gmail.com> | 2018-10-27 13:12:45 -0700 |
---|---|---|
committer | Kirk Shoop <kirk.shoop@gmail.com> | 2018-10-27 13:12:45 -0700 |
commit | 4aa52e42579cbd9e2cef6c0a6c2b0d8edf73ac5d (patch) | |
tree | 2b4a574fcd4a62d8b59174646b76c53fa9c15b2d /Rx/v2/test | |
parent | ed3fe6418276781e662e5113ee3cee1bee4f0998 (diff) | |
download | RxCpp-4aa52e42579cbd9e2cef6c0a6c2b0d8edf73ac5d.tar.gz |
Add support for compiling rxcpp with -fno-exceptions (#456)
* Minor compilation/test fixes for compiling on android
Change-Id: Id623455d32e9323355744a240c2813d0411d1dac
* 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
* update to catch2 and add RX_USE_EXCEPTIONS cmake option
* fix bugs in doxygen examples
* replace [[noreturn]] with RXCPP_NORETURN
* removes support for VS 2013
Diffstat (limited to 'Rx/v2/test')
28 files changed, 151 insertions, 112 deletions
diff --git a/Rx/v2/test/CMakeLists.txt b/Rx/v2/test/CMakeLists.txt index dcb998f..c2d1530 100644 --- a/Rx/v2/test/CMakeLists.txt +++ b/Rx/v2/test/CMakeLists.txt @@ -88,6 +88,15 @@ set(TEST_SOURCES ${TEST_DIR}/operators/zip.cpp ) +set(TEST_COMPILE_DEFINITIONS "") +set(TEST_COMMAND_ARGUMENTS "") + +if (NOT RX_USE_EXCEPTIONS) + MESSAGE( STATUS "no exceptions" ) + list(APPEND TEST_COMPILE_DEFINITIONS CATCH_CONFIG_DISABLE_EXCEPTIONS) + list(APPEND TEST_COMMAND_ARGUMENTS -e) +endif() + add_executable(rxcppv2_test ${TEST_DIR}/test.cpp ${TEST_SOURCES}) add_executable(rxcpp::tests ALIAS rxcppv2_test) @@ -98,6 +107,7 @@ set_target_properties( ) target_compile_options(rxcppv2_test PUBLIC ${RX_COMPILE_OPTIONS}) target_compile_features(rxcppv2_test PUBLIC ${RX_COMPILE_FEATURES}) +target_compile_definitions(rxcppv2_test PUBLIC ${TEST_COMPILE_DEFINITIONS}) target_include_directories(rxcppv2_test PUBLIC ${RX_SRC_DIR} ${RX_CATCH_DIR} ) @@ -110,7 +120,7 @@ foreach(ONE_TEST_SOURCE ${TEST_SOURCES}) set(ONE_TEST_FULL_NAME "rxcpp_test_${ONE_TEST_NAME}") add_executable( ${ONE_TEST_FULL_NAME} ${ONE_TEST_SOURCE} ) add_executable( rxcpp::${ONE_TEST_NAME} ALIAS ${ONE_TEST_FULL_NAME}) - target_compile_definitions(${ONE_TEST_FULL_NAME} PUBLIC "CATCH_CONFIG_MAIN") + target_compile_definitions(${ONE_TEST_FULL_NAME} PUBLIC "CATCH_CONFIG_MAIN" ${TEST_COMPILE_DEFINITIONS}) target_compile_options(${ONE_TEST_FULL_NAME} PUBLIC ${RX_COMPILE_OPTIONS}) target_compile_features(${ONE_TEST_FULL_NAME} PUBLIC ${RX_COMPILE_FEATURES}) target_include_directories(${ONE_TEST_FULL_NAME} @@ -118,7 +128,7 @@ foreach(ONE_TEST_SOURCE ${TEST_SOURCES}) ) target_link_libraries(${ONE_TEST_FULL_NAME} ${CMAKE_THREAD_LIBS_INIT}) - add_test(NAME ${ONE_TEST_NAME} COMMAND ${ONE_TEST_FULL_NAME}) + add_test(NAME ${ONE_TEST_NAME} COMMAND ${ONE_TEST_FULL_NAME} ${TEST_COMMAND_ARGUMENTS}) endforeach(ONE_TEST_SOURCE ${TEST_SOURCES}) diff --git a/Rx/v2/test/operators/buffer.cpp b/Rx/v2/test/operators/buffer.cpp index 51aba17..e1b980c 100644 --- a/Rx/v2/test/operators/buffer.cpp +++ b/Rx/v2/test/operators/buffer.cpp @@ -455,7 +455,7 @@ SCENARIO("buffer count error 2", "[buffer][operators]"){ } } -SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][!hide]"){ GIVEN("7 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-----------------| @@ -489,7 +489,7 @@ SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][h }); printf("\n"); }, - [](std::exception_ptr){ + [](rxu::error_ptr){ printf("on_error\n"); }, [](){ @@ -500,7 +500,7 @@ SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][h } } -SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_time][operators][long][!hide]"){ GIVEN("7 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-----------------| @@ -532,7 +532,7 @@ SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_t }); printf("\n"); }, - [](std::exception_ptr){ + [](rxu::error_ptr){ printf("on_error\n"); }, [](){ @@ -543,7 +543,7 @@ SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_t } } -SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| @@ -576,7 +576,7 @@ SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operat }); printf("\n"); }, - [](std::exception_ptr){ + [](rxu::error_ptr){ printf("on_error\n"); }, [](){ @@ -587,7 +587,7 @@ SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operat } } -SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| @@ -620,7 +620,7 @@ SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[b }); printf("\n"); }, - [](std::exception_ptr){ + [](rxu::error_ptr){ printf("on_error\n"); }, [](){ @@ -631,7 +631,7 @@ SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[b } } -SCENARIO("buffer with time on intervals, error", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals, error", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| @@ -667,7 +667,7 @@ SCENARIO("buffer with time on intervals, error", "[buffer_with_time][operators][ }); printf("\n"); }, - [](std::exception_ptr){ + [](rxu::error_ptr){ printf("on_error\n"); }, [](){ diff --git a/Rx/v2/test/operators/combine_latest.cpp b/Rx/v2/test/operators/combine_latest.cpp index ec47823..198fb2f 100644 --- a/Rx/v2/test/operators/combine_latest.cpp +++ b/Rx/v2/test/operators/combine_latest.cpp @@ -1465,7 +1465,7 @@ SCENARIO("combine_latest error after completed right", "[combine_latest][join][o } } -SCENARIO("combine_latest selector throws", "[combine_latest][join][operators]"){ +SCENARIO("combine_latest selector throws", "[combine_latest][join][operators][!throws]"){ GIVEN("2 hot observables of ints."){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -1491,8 +1491,25 @@ SCENARIO("combine_latest selector throws", "[combine_latest][join][operators]"){ [&]() { return o1 .combine_latest( + // Note for trying to handle this test case when exceptions are disabled + // with RXCPP_USE_EXCEPTIONS == 0: + // + // It seems that this test is in particular testing that the + // combine_latest selector (aggregate function) thrown exceptions + // are being translated into an on_error. + // + // Since there appears to be no way to give combine_latest + // an Observable that would call on_error directly (as opposed + // to a regular function that's converted into an observable), + // this test is meaningless when exceptions are disabled + // since any selectors with 'throw' will not even compile. + // + // Attempting to change this to e.g. + // o1.combineLatest(o2).map ... unconditional onError + // would defeat the purpose of the test since its the combineLatest + // implementation that's supposed to be doing the error forwarding. [&ex](int, int) -> int { - throw ex; + rxu::throw_exception(ex); }, o2 ) @@ -1528,7 +1545,7 @@ SCENARIO("combine_latest selector throws", "[combine_latest][join][operators]"){ } } -SCENARIO("combine_latest selector throws N", "[combine_latest][join][operators]"){ +SCENARIO("combine_latest selector throws N", "[combine_latest][join][operators][!throws]"){ GIVEN("N hot observables of ints."){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -1555,7 +1572,7 @@ SCENARIO("combine_latest selector throws N", "[combine_latest][join][operators]" return e[0] .combine_latest( [&ex](int, int, int, int) -> int { - throw ex; + rxu::throw_exception(ex); }, e[1], e[2], e[3] ) diff --git a/Rx/v2/test/operators/concat.cpp b/Rx/v2/test/operators/concat.cpp index 86f4a7e..88dcac7 100644 --- a/Rx/v2/test/operators/concat.cpp +++ b/Rx/v2/test/operators/concat.cpp @@ -5,7 +5,7 @@ const int static_onnextcalls = 1000000; -SCENARIO("synchronize concat ranges", "[hide][range][synchronize][concat][perf]"){ +SCENARIO("synchronize concat ranges", "[!hide][range][synchronize][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -33,7 +33,7 @@ SCENARIO("synchronize concat ranges", "[hide][range][synchronize][concat][perf]" } } -SCENARIO("observe_on concat ranges", "[hide][range][observe_on][concat][perf]"){ +SCENARIO("observe_on concat ranges", "[!hide][range][observe_on][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -61,7 +61,7 @@ SCENARIO("observe_on concat ranges", "[hide][range][observe_on][concat][perf]"){ } } -SCENARIO("serialize concat ranges", "[hide][range][serialize][concat][perf]"){ +SCENARIO("serialize concat ranges", "[!hide][range][serialize][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ diff --git a/Rx/v2/test/operators/concat_map.cpp b/Rx/v2/test/operators/concat_map.cpp index e6551d6..cfd6f4f 100644 --- a/Rx/v2/test/operators/concat_map.cpp +++ b/Rx/v2/test/operators/concat_map.cpp @@ -8,7 +8,7 @@ static const int static_tripletCount = 100; -SCENARIO("concat_transform pythagorian ranges", "[hide][range][concat_transform][pythagorian][perf]"){ +SCENARIO("concat_transform pythagorian ranges", "[!hide][range][concat_transform][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -43,7 +43,7 @@ SCENARIO("concat_transform pythagorian ranges", "[hide][range][concat_transform] .take(tripletCount) .subscribe( rxu::apply_to([&ct](int /*x*/,int /*y*/,int /*z*/){++ct;}), - [](std::exception_ptr){abort();}); + [](rxu::error_ptr){abort();}); auto finish = clock::now(); auto msElapsed = duration_cast<milliseconds>(finish.time_since_epoch()) - duration_cast<milliseconds>(start.time_since_epoch()); @@ -53,7 +53,7 @@ SCENARIO("concat_transform pythagorian ranges", "[hide][range][concat_transform] } } -SCENARIO("synchronize concat_transform pythagorian ranges", "[hide][range][concat_transform][synchronize][pythagorian][perf]"){ +SCENARIO("synchronize concat_transform pythagorian ranges", "[!hide][range][concat_transform][synchronize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -101,7 +101,7 @@ SCENARIO("synchronize concat_transform pythagorian ranges", "[hide][range][conca } } -SCENARIO("observe_on concat_transform pythagorian ranges", "[hide][range][concat_transform][observe_on][pythagorian][perf]"){ +SCENARIO("observe_on concat_transform pythagorian ranges", "[!hide][range][concat_transform][observe_on][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -150,7 +150,7 @@ SCENARIO("observe_on concat_transform pythagorian ranges", "[hide][range][concat } } -SCENARIO("serialize concat_transform pythagorian ranges", "[hide][range][concat_transform][serialize][pythagorian][perf]"){ +SCENARIO("serialize concat_transform pythagorian ranges", "[!hide][range][concat_transform][serialize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ diff --git a/Rx/v2/test/operators/filter.cpp b/Rx/v2/test/operators/filter.cpp index 70c997b..08dd6ee 100644 --- a/Rx/v2/test/operators/filter.cpp +++ b/Rx/v2/test/operators/filter.cpp @@ -212,7 +212,9 @@ SCENARIO("filter stops on error", "[where][filter][operators]"){ } } -SCENARIO("filter stops on throw from predicate", "[where][filter][operators]"){ +// filter cannot possibly catch an exception when exceptions are disabled, +// so this test is meaningless when exceptions are disabled. +SCENARIO("filter stops on throw from predicate", "[where][filter][operators][!throws]"){ GIVEN("a test hot observable of ints"){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -248,7 +250,7 @@ SCENARIO("filter stops on throw from predicate", "[where][filter][operators]"){ .filter([ex, &invoked](int x) { invoked++; if (x > 5) { - throw ex; + rxu::throw_exception(ex); } return IsPrime(x); }) diff --git a/Rx/v2/test/operators/flat_map.cpp b/Rx/v2/test/operators/flat_map.cpp index 2e01a30..e1837b0 100644 --- a/Rx/v2/test/operators/flat_map.cpp +++ b/Rx/v2/test/operators/flat_map.cpp @@ -8,7 +8,7 @@ static const int static_tripletCount = 100; -SCENARIO("pythagorian for loops", "[hide][for][pythagorian][perf]"){ +SCENARIO("pythagorian for loops", "[!hide][for][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("a for loop"){ WHEN("generating pythagorian triplets"){ @@ -45,7 +45,7 @@ SCENARIO("pythagorian for loops", "[hide][for][pythagorian][perf]"){ } } -SCENARIO("merge_transform pythagorian ranges", "[hide][range][merge_transform][pythagorian][perf]"){ +SCENARIO("merge_transform pythagorian ranges", "[!hide][range][merge_transform][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -89,7 +89,7 @@ SCENARIO("merge_transform pythagorian ranges", "[hide][range][merge_transform][p } } -SCENARIO("synchronize merge_transform pythagorian ranges", "[hide][range][merge_transform][synchronize][pythagorian][perf]"){ +SCENARIO("synchronize merge_transform pythagorian ranges", "[!hide][range][merge_transform][synchronize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -137,7 +137,7 @@ SCENARIO("synchronize merge_transform pythagorian ranges", "[hide][range][merge_ } } -SCENARIO("observe_on merge_transform pythagorian ranges", "[hide][range][merge_transform][observe_on][pythagorian][perf]"){ +SCENARIO("observe_on merge_transform pythagorian ranges", "[!hide][range][merge_transform][observe_on][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -185,7 +185,7 @@ SCENARIO("observe_on merge_transform pythagorian ranges", "[hide][range][merge_t } } -SCENARIO("serialize merge_transform pythagorian ranges", "[hide][range][merge_transform][serialize][pythagorian][perf]"){ +SCENARIO("serialize merge_transform pythagorian ranges", "[!hide][range][merge_transform][serialize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ diff --git a/Rx/v2/test/operators/group_by.cpp b/Rx/v2/test/operators/group_by.cpp index 2c7c177..645bda4 100644 --- a/Rx/v2/test/operators/group_by.cpp +++ b/Rx/v2/test/operators/group_by.cpp @@ -9,8 +9,9 @@ #include <rxcpp/operators/rx-observe_on.hpp> #include <locale> +#include <sstream> -SCENARIO("range partitioned by group_by across hardware threads to derive pi", "[hide][pi][group_by][observe_on][long][perf]"){ +SCENARIO("range partitioned by group_by across hardware threads to derive pi", "[!hide][pi][group_by][observe_on][long][perf]"){ GIVEN("a for loop"){ WHEN("partitioning pi series across all hardware threads"){ @@ -92,7 +93,7 @@ SCENARIO("range partitioned by group_by across hardware threads to derive pi", " } } -SCENARIO("range partitioned by dividing work across hardware threads to derive pi", "[hide][pi][observe_on][long][perf]"){ +SCENARIO("range partitioned by dividing work across hardware threads to derive pi", "[!hide][pi][observe_on][long][perf]"){ GIVEN("a for loop"){ WHEN("partitioning pi series across all hardware threads"){ diff --git a/Rx/v2/test/operators/lift.cpp b/Rx/v2/test/operators/lift.cpp index 7d90bce..1f58c1d 100644 --- a/Rx/v2/test/operators/lift.cpp +++ b/Rx/v2/test/operators/lift.cpp @@ -31,17 +31,17 @@ struct liftfilter } void on_next(typename dest_type::value_type v) const { bool filtered = false; - try { + RXCPP_TRY { filtered = !test(v); - } catch(...) { - dest.on_error(std::current_exception()); + } RXCPP_CATCH(...) { + dest.on_error(rxu::current_exception()); return; } if (!filtered) { dest.on_next(v); } } - void on_error(std::exception_ptr e) const { + void on_error(rxu::error_ptr e) const { dest.on_error(e); } void on_completed() const { @@ -248,10 +248,10 @@ SCENARIO("lift lambda filter stops on disposal", "[where][filter][lift][lambda][ rx::make_observer_dynamic<int>( [=](int n){ bool pass = false; - try{pass = predicate(n);} catch(...){dest.on_error(std::current_exception());}; + RXCPP_TRY {pass = predicate(n);} RXCPP_CATCH(...){dest.on_error(rxu::current_exception());}; if (pass) {dest.on_next(n);} }, - [=](std::exception_ptr e){dest.on_error(e);}, + [=](rxu::error_ptr e){dest.on_error(e);}, [=](){dest.on_completed();})); }) // forget type to workaround lambda deduction bug on msvc 2013 diff --git a/Rx/v2/test/operators/merge.cpp b/Rx/v2/test/operators/merge.cpp index 9a7f28c..917d74d 100644 --- a/Rx/v2/test/operators/merge.cpp +++ b/Rx/v2/test/operators/merge.cpp @@ -6,7 +6,7 @@ const int static_onnextcalls = 1000000; -SCENARIO("synchronize merge ranges", "[hide][range][synchronize][merge][perf]"){ +SCENARIO("synchronize merge ranges", "[!hide][range][synchronize][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -34,7 +34,7 @@ SCENARIO("synchronize merge ranges", "[hide][range][synchronize][merge][perf]"){ } } -SCENARIO("observe_on merge ranges", "[hide][range][observe_on][merge][perf]"){ +SCENARIO("observe_on merge ranges", "[!hide][range][observe_on][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -62,7 +62,7 @@ SCENARIO("observe_on merge ranges", "[hide][range][observe_on][merge][perf]"){ } } -SCENARIO("serialize merge ranges", "[hide][range][serialize][merge][perf]"){ +SCENARIO("serialize merge ranges", "[!hide][range][serialize][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ diff --git a/Rx/v2/test/operators/merge_delay_error.cpp b/Rx/v2/test/operators/merge_delay_error.cpp index b53b884..83172ec 100644 --- a/Rx/v2/test/operators/merge_delay_error.cpp +++ b/Rx/v2/test/operators/merge_delay_error.cpp @@ -3,8 +3,6 @@ #include <rxcpp/operators/rx-merge_delay_error.hpp> #include <rxcpp/operators/rx-observe_on.hpp> -const int static_onnextcalls = 1000000; - //merge_delay_error must work the very same way as `merge()` except the error handling SCENARIO("merge_delay_error completes", "[merge][join][operators]"){ diff --git a/Rx/v2/test/operators/observe_on.cpp b/Rx/v2/test/operators/observe_on.cpp index ffa85aa..aac2d40 100644 --- a/Rx/v2/test/operators/observe_on.cpp +++ b/Rx/v2/test/operators/observe_on.cpp @@ -5,7 +5,7 @@ const int static_onnextcalls = 100000; -SCENARIO("range observed on new_thread", "[hide][range][observe_on_debug][observe_on][long][perf]"){ +SCENARIO("range observed on new_thread", "[!hide][range][observe_on_debug][observe_on][long][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a range"){ WHEN("multicasting a million ints"){ diff --git a/Rx/v2/test/operators/on_error_resume_next.cpp b/Rx/v2/test/operators/on_error_resume_next.cpp index 3761094..e67b66e 100644 --- a/Rx/v2/test/operators/on_error_resume_next.cpp +++ b/Rx/v2/test/operators/on_error_resume_next.cpp @@ -30,7 +30,7 @@ SCENARIO("switch_on_error stops on completion", "[switch_on_error][on_error_resu auto res = w.start( [xs, ys, &invoked]() { return xs - .switch_on_error([ys, &invoked](std::exception_ptr) { + .switch_on_error([ys, &invoked](rxu::error_ptr) { invoked++; return ys; }) @@ -101,7 +101,7 @@ SCENARIO("on_error_resume_next stops on completion", "[on_error_resume_next][ope auto res = w.start( [xs, ys, &invoked]() { return xs - .on_error_resume_next([ys, &invoked](std::exception_ptr) { + .on_error_resume_next([ys, &invoked](rxu::error_ptr) { invoked++; return ys; }) @@ -174,7 +174,7 @@ SCENARIO("on_error_resume_next stops on error", "[on_error_resume_next][operator auto res = w.start( [xs, ys, &invoked]() { return xs - .on_error_resume_next([ys, &invoked](std::exception_ptr) { + .on_error_resume_next([ys, &invoked](rxu::error_ptr) { invoked++; return ys; }) diff --git a/Rx/v2/test/operators/publish.cpp b/Rx/v2/test/operators/publish.cpp index 87c8fff..c977597 100644 --- a/Rx/v2/test/operators/publish.cpp +++ b/Rx/v2/test/operators/publish.cpp @@ -4,7 +4,7 @@ #include <rxcpp/operators/rx-ref_count.hpp> -SCENARIO("publish range", "[hide][range][subject][publish][subject][operators]"){ +SCENARIO("publish range", "[!hide][range][subject][publish][subject][operators]"){ GIVEN("a range"){ WHEN("published"){ auto published = rxs::range<int>(0, 10).publish(); diff --git a/Rx/v2/test/operators/reduce.cpp b/Rx/v2/test/operators/reduce.cpp index 33a0644..46ad3cd 100644 --- a/Rx/v2/test/operators/reduce.cpp +++ b/Rx/v2/test/operators/reduce.cpp @@ -240,7 +240,11 @@ SCENARIO("max", "[reduce][max][operators]"){ } } -SCENARIO("max, empty", "[reduce][max][operators]"){ +// Does not work because calling max() on an empty stream throws an exception +// which will crash when exceptions are disabled. +// +// TODO: the max internal implementation should be rewritten not to throw exceptions. +SCENARIO("max, empty", "[reduce][max][operators][!throws]"){ GIVEN("a test hot observable of ints"){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -365,7 +369,10 @@ SCENARIO("min", "[reduce][min][operators]"){ } } -SCENARIO("min, empty", "[reduce][min][operators]"){ +// Does not work with exceptions disabled, min will throw when stream is empty +// and this crashes immediately. +// TODO: min implementation should be rewritten not to throw exceptions. +SCENARIO("min, empty", "[reduce][min][operators][!throws]"){ GIVEN("a test hot observable of ints"){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); diff --git a/Rx/v2/test/operators/scan.cpp b/Rx/v2/test/operators/scan.cpp index 5aa3c31..1cb38a5 100644 --- a/Rx/v2/test/operators/scan.cpp +++ b/Rx/v2/test/operators/scan.cpp @@ -3,7 +3,7 @@ #include <rxcpp/operators/rx-take.hpp> #include <rxcpp/operators/rx-scan.hpp> -SCENARIO("scan: issue 41", "[scan][operators][issue][hide]"){ +SCENARIO("scan: issue 41", "[scan][operators][issue][!hide]"){ GIVEN("map of scan of interval"){ auto sc = rxsc::make_current_thread(); auto so = rxcpp::synchronize_in_one_worker(sc); @@ -253,7 +253,7 @@ SCENARIO("scan: seed, some data", "[scan][operators]"){ } } -SCENARIO("scan: seed, accumulator throws", "[scan][operators]"){ +SCENARIO("scan: seed, accumulator throws", "[scan][operators][!throws]"){ GIVEN("a test hot observable of ints"){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -279,7 +279,7 @@ SCENARIO("scan: seed, accumulator throws", "[scan][operators]"){ return xs .scan(seed, [&](int sum, int x) { if (x == 4) { - throw ex; + rxu::throw_exception(ex); } return sum + x; }) diff --git a/Rx/v2/test/operators/subscribe_on.cpp b/Rx/v2/test/operators/subscribe_on.cpp index baa66e2..ef8a8c7 100644 --- a/Rx/v2/test/operators/subscribe_on.cpp +++ b/Rx/v2/test/operators/subscribe_on.cpp @@ -4,9 +4,11 @@ #include <rxcpp/operators/rx-subscribe_on.hpp> #include <rxcpp/operators/rx-observe_on.hpp> +#include <sstream> + static const int static_subscriptions = 50000; -SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[hide][for][just][subscribe][subscribe_on][observe_on][long][perf]"){ +SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[!hide][for][just][subscribe][subscribe_on][observe_on][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 50K times"){ @@ -46,7 +48,7 @@ SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[hide][ } } -SCENARIO("for loop subscribes to map with subscribe_on", "[hide][subscribe_on_only][for][just][subscribe][subscribe_on][long][perf]"){ +SCENARIO("for loop subscribes to map with subscribe_on", "[!hide][subscribe_on_only][for][just][subscribe][subscribe_on][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 50K times"){ diff --git a/Rx/v2/test/operators/tap.cpp b/Rx/v2/test/operators/tap.cpp index 9aad159..c9e8317 100644 --- a/Rx/v2/test/operators/tap.cpp +++ b/Rx/v2/test/operators/tap.cpp @@ -86,7 +86,7 @@ SCENARIO("tap stops on error", "[tap][operators]"){ auto res = w.start( [xs, &invoked]() { return xs - .tap([&invoked](std::exception_ptr) { + .tap([&invoked](rxu::error_ptr) { invoked++; }) // forget type to workaround lambda deduction bug on msvc 2013 diff --git a/Rx/v2/test/operators/with_latest_from.cpp b/Rx/v2/test/operators/with_latest_from.cpp index 4d03641..ae7092a 100644 --- a/Rx/v2/test/operators/with_latest_from.cpp +++ b/Rx/v2/test/operators/with_latest_from.cpp @@ -1463,7 +1463,7 @@ SCENARIO("with_latest_from error after completed right", "[with_latest_from][joi } } -SCENARIO("with_latest_from selector throws", "[with_latest_from][join][operators]"){ +SCENARIO("with_latest_from selector throws", "[with_latest_from][join][operators][!throws]"){ GIVEN("2 hot observables of ints."){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -1490,7 +1490,7 @@ SCENARIO("with_latest_from selector throws", "[with_latest_from][join][operators return o2 .with_latest_from( [&ex](int, int) -> int { - throw ex; + rxu::throw_exception(ex); }, o1 ) @@ -1526,7 +1526,7 @@ SCENARIO("with_latest_from selector throws", "[with_latest_from][join][operators } } -SCENARIO("with_latest_from selector throws N", "[with_latest_from][join][operators]"){ +SCENARIO("with_latest_from selector throws N", "[with_latest_from][join][operators][!throws]"){ GIVEN("N hot observables of ints."){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -1553,7 +1553,7 @@ SCENARIO("with_latest_from selector throws N", "[with_latest_from][join][operato return e[3] .with_latest_from( [&ex](int, int, int, int) -> int { - throw ex; + rxu::throw_exception(ex); }, e[0], e[1], e[2] ) diff --git a/Rx/v2/test/operators/zip.cpp b/Rx/v2/test/operators/zip.cpp index 1bbdd86..c048006 100644 --- a/Rx/v2/test/operators/zip.cpp +++ b/Rx/v2/test/operators/zip.cpp @@ -1185,7 +1185,7 @@ SCENARIO("zip right completes first", "[zip][join][operators]"){ } } -SCENARIO("zip selector throws", "[zip][join][operators]"){ +SCENARIO("zip selector throws", "[zip][join][operators][!throws]"){ GIVEN("2 hot observables of ints."){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -1212,7 +1212,7 @@ SCENARIO("zip selector throws", "[zip][join][operators]"){ return o1 .zip( [&ex](int, int) -> int { - throw ex; + rxu::throw_exception(ex); }, o2 ) @@ -1248,7 +1248,7 @@ SCENARIO("zip selector throws", "[zip][join][operators]"){ } } -SCENARIO("zip selector throws N", "[zip][join][operators]"){ +SCENARIO("zip selector throws N", "[zip][join][operators][!throws]"){ GIVEN("N hot observables of ints."){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -1275,7 +1275,7 @@ SCENARIO("zip selector throws N", "[zip][join][operators]"){ return e[0] .zip( [&ex](int, int, int, int) -> int { - throw ex; + rxu::throw_exception(ex); }, e[1], e[2], e[3] ) diff --git a/Rx/v2/test/sources/defer.cpp b/Rx/v2/test/sources/defer.cpp index 266380e..a8187ad 100644 --- a/Rx/v2/test/sources/defer.cpp +++ b/Rx/v2/test/sources/defer.cpp @@ -15,7 +15,7 @@ SCENARIO("defer stops on completion", "[defer][sources]"){ auto empty = rx::observable<>::empty<long>(); auto just = rx::observable<>::just(42); auto one = rx::observable<>::from(42); - auto error = rx::observable<>::error<long>(std::exception_ptr()); + auto error = rx::observable<>::error<long>(rxu::error_ptr()); auto runtimeerror = rx::observable<>::error<long>(std::runtime_error("runtime")); auto res = w.start( diff --git a/Rx/v2/test/sources/interval.cpp b/Rx/v2/test/sources/interval.cpp index 38f4ac3..9ab2fca 100644 --- a/Rx/v2/test/sources/interval.cpp +++ b/Rx/v2/test/sources/interval.cpp @@ -1,6 +1,6 @@ #include "../test.h" -SCENARIO("schedule_periodically", "[hide][periodically][scheduler][long][perf][sources]"){ +SCENARIO("schedule_periodically", "[!hide][periodically][scheduler][long][perf][sources]"){ GIVEN("schedule_periodically"){ WHEN("the period is 1sec and the initial is 2sec"){ using namespace std::chrono; @@ -21,7 +21,7 @@ SCENARIO("schedule_periodically", "[hide][periodically][scheduler][long][perf][s } } -SCENARIO("schedule_periodically by duration", "[hide][periodically][scheduler][long][perf][sources]"){ +SCENARIO("schedule_periodically by duration", "[!hide][periodically][scheduler][long][perf][sources]"){ GIVEN("schedule_periodically_duration"){ WHEN("the period is 1sec and the initial is 2sec"){ using namespace std::chrono; @@ -64,7 +64,7 @@ SCENARIO("schedule_periodically by duration", "[hide][periodically][scheduler][l } } -SCENARIO("intervals", "[hide][periodically][interval][scheduler][long][perf][sources]"){ +SCENARIO("intervals", "[!hide][periodically][interval][scheduler][long][perf][sources]"){ GIVEN("10 intervals of 1 seconds"){ WHEN("the period is 1sec and the initial is 2sec"){ using namespace std::chrono; @@ -84,7 +84,7 @@ SCENARIO("intervals", "[hide][periodically][interval][scheduler][long][perf][sou std::cout << "interval : period " << counter << ", " << nsDelta.count() << "ms delta from target time" << std::endl; if (counter == 5) {cs.unsubscribe();} }, - [](std::exception_ptr){abort();}); + [](rxu::error_ptr){abort();}); } } } diff --git a/Rx/v2/test/sources/scope.cpp b/Rx/v2/test/sources/scope.cpp index 383544b..1389344 100644 --- a/Rx/v2/test/sources/scope.cpp +++ b/Rx/v2/test/sources/scope.cpp @@ -318,7 +318,7 @@ SCENARIO("scope, dispose", "[scope][sources]"){ } } -SCENARIO("scope, throw resource selector", "[scope][sources]"){ +SCENARIO("scope, throw resource selector", "[scope][sources][!throws]"){ GIVEN("a test cold observable of ints"){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -339,7 +339,7 @@ SCENARIO("scope, throw resource selector", "[scope][sources]"){ scope( [&]() -> resource { ++resource_factory_invoked; - throw ex; + rxu::throw_exception(ex); //return resource(sc.clock()); }, [&](resource){ @@ -371,7 +371,7 @@ SCENARIO("scope, throw resource selector", "[scope][sources]"){ } } -SCENARIO("scope, throw resource usage", "[scope][sources]"){ +SCENARIO("scope, throw resource usage", "[scope][sources][!throws]"){ GIVEN("a test cold observable of ints"){ auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -396,7 +396,7 @@ SCENARIO("scope, throw resource usage", "[scope][sources]"){ }, [&](resource) -> rx::observable<int> { ++observable_factory_invoked; - throw ex; + rxu::throw_exception(ex); } ) // forget type to workaround lambda deduction bug on msvc 2013 diff --git a/Rx/v2/test/sources/timer.cpp b/Rx/v2/test/sources/timer.cpp index 9141f2e..3f46b21 100644 --- a/Rx/v2/test/sources/timer.cpp +++ b/Rx/v2/test/sources/timer.cpp @@ -1,6 +1,6 @@ #include "../test.h" -SCENARIO("timer", "[hide][periodically][timer][scheduler][long][perf][sources]"){ +SCENARIO("timer", "[!hide][periodically][timer][scheduler][long][perf][sources]"){ GIVEN("the timer of 1 sec"){ WHEN("the period is 1 sec"){ using namespace std::chrono; @@ -17,7 +17,7 @@ SCENARIO("timer", "[hide][periodically][timer][scheduler][long][perf][sources]") auto nsDelta = duration_cast<milliseconds>(sc.now() - (start + (period * counter))); std::cout << "timer : period " << counter << ", " << nsDelta.count() << "ms delta from target time" << std::endl; }, - [](std::exception_ptr){abort();}, + [](rxu::error_ptr){abort();}, [](){std::cout << "completed" << std::endl;}); } } diff --git a/Rx/v2/test/subjects/subject.cpp b/Rx/v2/test/subjects/subject.cpp index b6c6d67..09318a3 100644 --- a/Rx/v2/test/subjects/subject.cpp +++ b/Rx/v2/test/subjects/subject.cpp @@ -10,7 +10,7 @@ const int static_onnextcalls = 10000000; static int aliased = 0; -SCENARIO("for loop locks mutex", "[hide][for][mutex][long][perf]"){ +SCENARIO("for loop locks mutex", "[!hide][for][mutex][long][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("locking mutex 100 million times"){ @@ -52,7 +52,7 @@ public: } }; } -SCENARIO("for loop calls void on_next(int)", "[hide][for][asyncobserver][baseline][perf]"){ +SCENARIO("for loop calls void on_next(int)", "[!hide][for][asyncobserver][baseline][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("calling on_next 100 million times"){ @@ -137,7 +137,7 @@ public: } }; } -SCENARIO("for loop calls ready on_next(int)", "[hide][for][asyncobserver][ready][perf]"){ +SCENARIO("for loop calls ready on_next(int)", "[!hide][for][asyncobserver][ready][perf]"){ static const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("calling on_next 100 million times"){ @@ -191,7 +191,7 @@ public: onnext(v); return ready.get_future();} }; } -SCENARIO("for loop calls std::future<unit> on_next(int)", "[hide][for][asyncobserver][future][long][perf]"){ +SCENARIO("for loop calls std::future<unit> on_next(int)", "[!hide][for][asyncobserver][future][long][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("calling on_next 100 million times"){ @@ -218,7 +218,7 @@ SCENARIO("for loop calls std::future<unit> on_next(int)", "[hide][for][asyncobse } } -SCENARIO("for loop calls observer", "[hide][for][observer][perf]"){ +SCENARIO("for loop calls observer", "[!hide][for][observer][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("observing 100 million ints"){ @@ -232,7 +232,7 @@ SCENARIO("for loop calls observer", "[hide][for][observer][perf]"){ auto start = clock::now(); auto o = rx::make_observer<int>( [](int){++c;}, - [](std::exception_ptr){abort();}); + [](rxu::error_ptr){abort();}); for (int i = 0; i < onnextcalls; i++) { o.on_next(i); } @@ -244,7 +244,7 @@ SCENARIO("for loop calls observer", "[hide][for][observer][perf]"){ } } -SCENARIO("for loop calls subscriber", "[hide][for][subscriber][perf]"){ +SCENARIO("for loop calls subscriber", "[!hide][for][subscriber][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("observing 100 million ints"){ @@ -258,7 +258,7 @@ SCENARIO("for loop calls subscriber", "[hide][for][subscriber][perf]"){ auto start = clock::now(); auto o = rx::make_subscriber<int>( [](int){++c;}, - [](std::exception_ptr){abort();}); + [](rxu::error_ptr){abort();}); for (int i = 0; i < onnextcalls && o.is_subscribed(); i++) { o.on_next(i); } @@ -270,7 +270,7 @@ SCENARIO("for loop calls subscriber", "[hide][for][subscriber][perf]"){ } } -SCENARIO("range calls subscriber", "[hide][range][subscriber][perf]"){ +SCENARIO("range calls subscriber", "[!hide][range][subscriber][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a range"){ WHEN("observing 100 million ints"){ @@ -287,7 +287,7 @@ SCENARIO("range calls subscriber", "[hide][range][subscriber][perf]"){ [](int){ ++c; }, - [](std::exception_ptr){abort();}); + [](rxu::error_ptr){abort();}); auto finish = clock::now(); auto msElapsed = duration_cast<milliseconds>(finish-start); @@ -296,7 +296,7 @@ SCENARIO("range calls subscriber", "[hide][range][subscriber][perf]"){ } } -SCENARIO("for loop calls subject", "[hide][for][subject][subjects][long][perf]"){ +SCENARIO("for loop calls subject", "[!hide][for][subject][subjects][long][perf]"){ static const int& onnextcalls = static_onnextcalls; GIVEN("a for loop and a subject"){ WHEN("multicasting a million ints"){ @@ -337,7 +337,7 @@ SCENARIO("for loop calls subject", "[hide][for][subject][subjects][long][perf]") [cs](int){ cs.unsubscribe(); }, - [](std::exception_ptr){abort();})); + [](rxu::error_ptr){abort();})); } return 0; }); @@ -346,7 +346,7 @@ SCENARIO("for loop calls subject", "[hide][for][subject][subjects][long][perf]") [c, p](int){ ++(*c); }, - [](std::exception_ptr){abort();}); + [](rxu::error_ptr){abort();}); } auto start = clock::now(); @@ -370,7 +370,7 @@ SCENARIO("for loop calls subject", "[hide][for][subject][subjects][long][perf]") } } -SCENARIO("range calls subject", "[hide][range][subject][subjects][long][perf]"){ +SCENARIO("range calls subject", "[!hide][range][subject][subjects][long][perf]"){ static const int& onnextcalls = static_onnextcalls; GIVEN("a range and a subject"){ WHEN("multicasting a million ints"){ @@ -407,7 +407,7 @@ SCENARIO("range calls subject", "[hide][range][subject][subjects][long][perf]"){ [cs](int){ cs.unsubscribe(); }, - [](std::exception_ptr){abort();}); + [](rxu::error_ptr){abort();}); } return 0; }); @@ -417,7 +417,7 @@ SCENARIO("range calls subject", "[hide][range][subject][subjects][long][perf]"){ [c, p](int){ ++(*c); }, - [](std::exception_ptr){abort();} + [](rxu::error_ptr){abort();} ); } diff --git a/Rx/v2/test/subscriptions/coroutine.cpp b/Rx/v2/test/subscriptions/coroutine.cpp index bf67c55..d678714 100644 --- a/Rx/v2/test/subscriptions/coroutine.cpp +++ b/Rx/v2/test/subscriptions/coroutine.cpp @@ -24,13 +24,13 @@ SCENARIO("coroutine completes", "[coroutine]"){ w.advance_to(rxsc::test::subscribed_time); auto d = [&]() -> std::future<void> { - try { + RXCPP_TRY { for co_await (auto n : xs | rxo::as_dynamic()) { messages.push_back(on.next(w.clock(), n)); } messages.push_back(on.completed(w.clock())); - } catch (...) { - messages.push_back(on.error(w.clock(), std::current_exception())); + } RXCPP_CATCH(...) { + messages.push_back(on.error(w.clock(), rxu::current_exception())); } }(); @@ -85,13 +85,13 @@ SCENARIO("coroutine errors", "[coroutine]"){ w.advance_to(rxsc::test::subscribed_time); auto d = [&]() -> std::future<void> { - try { + RXCPP_TRY { for co_await (auto n : xs | rxo::as_dynamic()) { messages.push_back(on.next(w.clock(), n)); } messages.push_back(on.completed(w.clock())); - } catch (...) { - messages.push_back(on.error(w.clock(), std::current_exception())); + } RXCPP_CATCH(...) { + messages.push_back(on.error(w.clock(), rxu::current_exception())); } }(); 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()); } } diff --git a/Rx/v2/test/subscriptions/subscription.cpp b/Rx/v2/test/subscriptions/subscription.cpp index 2a9f15d..33218a7 100644 --- a/Rx/v2/test/subscriptions/subscription.cpp +++ b/Rx/v2/test/subscriptions/subscription.cpp @@ -6,7 +6,9 @@ #include "rxcpp/operators/rx-publish.hpp" #include "rxcpp/operators/rx-ref_count.hpp" -SCENARIO("observe subscription", "[hide]"){ +#include <sstream> + +SCENARIO("observe subscription", "[!hide]"){ GIVEN("observable of ints"){ WHEN("subscribe"){ auto observers = std::make_shared<std::list<rxcpp::subscriber<int>>>(); @@ -24,7 +26,7 @@ SCENARIO("observe subscription", "[hide]"){ static const int static_subscriptions = 10000; -SCENARIO("for loop subscribes to map", "[hide][for][just][subscribe][long][perf]"){ +SCENARIO("for loop subscribes to map", "[!hide][for][just][subscribe][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 100K times"){ @@ -69,7 +71,7 @@ SCENARIO("for loop subscribes to map", "[hide][for][just][subscribe][long][perf] } } -SCENARIO("for loop subscribes to combine_latest", "[hide][for][just][combine_latest][subscribe][long][perf]"){ +SCENARIO("for loop subscribes to combine_latest", "[!hide][for][just][combine_latest][subscribe][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 100K times"){ @@ -107,7 +109,7 @@ SCENARIO("for loop subscribes to combine_latest", "[hide][for][just][combine_lat } } -SCENARIO("synchronized range debug", "[hide][subscribe][range][synchronize_debug][synchronize][long][perf]"){ +SCENARIO("synchronized range debug", "[!hide][subscribe][range][synchronize_debug][synchronize][long][perf]"){ GIVEN("range"){ WHEN("synchronized"){ using namespace std::chrono; @@ -139,7 +141,7 @@ SCENARIO("synchronized range debug", "[hide][subscribe][range][synchronize_debug ++std::get<1>(*completionstate); std::get<2>(*completionstate).on_next(n); }, - [=](std::exception_ptr){ + [=](rxu::error_ptr){ abort(); }, [=](){ @@ -216,7 +218,7 @@ SCENARIO("synchronized range debug", "[hide][subscribe][range][synchronize_debug } } -SCENARIO("observe_on range debug", "[hide][subscribe][range][observe_on_debug][observe_on][long][perf]"){ +SCENARIO("observe_on range debug", "[!hide][subscribe][range][observe_on_debug][observe_on][long][perf]"){ GIVEN("range"){ WHEN("observed on"){ using namespace std::chrono; @@ -248,7 +250,7 @@ SCENARIO("observe_on range debug", "[hide][subscribe][range][observe_on_debug][o ++std::get<1>(*completionstate); std::get<2>(*completionstate).on_next(n); }, - [=](std::exception_ptr){ + [=](rxu::error_ptr){ abort(); }, [=](){ |