| 1 | #include <thread> |
| 2 | #include <atomic> |
| 3 | #include <algorithm> |
| 4 | |
| 5 | #include "test.h"cxx . . $ `<file>/src/unittest/test.h`/ |
| 6 | |
| 7 | #ifndef DPP_NO_CORO |
| 8 | |
| 9 | namespacecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/ { |
| 10 | |
| 11 | namespace std_coroutine = dpp::detailcxx . . $ dpp/detail/::std_coroutine; |
| 12 | |
| 13 | template <size_t N> |
| 14 | struct test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception# : stdcxx . . $ std/::exception { |
| 15 | }; |
| 16 | |
| 17 | stdcxx . . $ std/::atomiccxx . . $ std/atomic#<int> exceptions_caughtcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/exceptions_caught. = 0cxx . . $ std/atomic#atomic(f349c77f591a7878).; |
| 18 | |
| 19 | stdcxx . . $ std/::arraycxx . . $ std/array#<stdcxx . . $ std/::atomiccxx . . $ std/atomic#<int>, 10> job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data.; |
| 20 | stdcxx . . $ std/::arraycxx . . $ std/array#<stdcxx . . $ std/::atomiccxx . . $ std/atomic#<int>, 10> task_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_data.; |
| 21 | |
| 22 | |
| 23 | struct simple_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable# { |
| 24 | test_tcxx . . $ test_t# &test_forcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#test_for.; |
| 25 | volatile int valuecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#value.{}; |
| 26 | int resultcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#result.{}; |
| 27 | |
| 28 | bool await_readycxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#await_ready(3482b152b9333168).() const noexcept { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | template <typename T> |
| 33 | void await_suspendcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#await_suspend(734cf528531c204e).(std_coroutine::coroutine_handlecxx . . $ std/__n4861/coroutine_handle#<T> handle) { |
| 34 | stdcxx . . $ std/::threadcxx . . $ std/thread# th([this, handle]() mutable { |
| 35 | auto *test = &test_forcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#test_for.; |
| 36 | stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(5)); |
| 37 | resultcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#result. = valuecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#value.; |
| 38 | try { |
| 39 | handle.resumecxx . . $ std/__n4861/coroutine_handle#resume(83f5f38750778ac8).(); |
| 40 | } catch (const stdcxx . . $ std/::exception &) { |
| 41 | /* no exception should be caught */ |
| 42 | set_statuscxx . . $ set_status(69213411294ab03e).(*test, ts_failedcxx . . $ ts_failed., "unexpected exception during resume"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 43 | } |
| 44 | }); |
| 45 | th.detachcxx . . $ std/thread#detach(49f6e7a06ebc5aa8).(); |
| 46 | } |
| 47 | |
| 48 | int await_resumecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#await_resume(ea6fe5115c70a13f).() const noexcept { |
| 49 | return resultcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#result.; |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | void sync_awaitable_funcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/sync_awaitable_fun(c984aeb66bdba57e).(stdcxx . . $ std/::functioncxx . . $ std/function#<void(int)> callback) { |
| 54 | callback(cxx . . $ std/function#`operator()`(39e0826ffb540481).42); |
| 55 | } |
| 56 | |
| 57 | void sync_awaitable_throwcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/sync_awaitable_throw(c984aeb66bdba57e).(stdcxx . . $ std/::functioncxx . . $ std/function#<void(int)> callback) { |
| 58 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<0>{}; |
| 59 | } |
| 60 | |
| 61 | void async_awaitable_wait5cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/async_awaitable_wait5(c984aeb66bdba57e).(stdcxx . . $ std/::functioncxx . . $ std/function#<void(int)> callback) { |
| 62 | stdcxx . . $ std/::threadcxx . . $ std/thread# thcxx . . $ std/thread#thread(33bc091c26643b13).([cc = stdcxx . . $ std/function#function(f869d4ee66f5babd).::movecxx . . $ std/move(e35c19a1ba7baa26).(callback)]() noexcept { |
| 63 | stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(5)); |
| 64 | cc(cxx . . $ std/function#`operator()`(39e0826ffb540481).69); |
| 65 | }); |
| 66 | th.detachcxx . . $ std/thread#detach(49f6e7a06ebc5aa8).(); |
| 67 | } |
| 68 | |
| 69 | struct job_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable# { |
| 70 | volatile int valuecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#value.{}; |
| 71 | int resultcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#result.{}; |
| 72 | |
| 73 | bool await_readycxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#await_ready(3482b152b9333168).() const noexcept { |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | template <typename T> |
| 78 | void await_suspendcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#await_suspend(734cf528531c204e).(std_coroutine::coroutine_handlecxx . . $ std/__n4861/coroutine_handle#<T> handle) { |
| 79 | stdcxx . . $ std/::threadcxx . . $ std/thread# th([this, handle]() mutable { |
| 80 | stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(5)); |
| 81 | resultcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#result. = valuecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#value.; |
| 82 | try { |
| 83 | handle.resumecxx . . $ std/__n4861/coroutine_handle#resume(83f5f38750778ac8).(); |
| 84 | } catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<42> &) { |
| 85 | /* intended exception to catch. we should have 2, one for the job_data test, one for the top-level job test */ |
| 86 | int exceptions = ++cxx . . $ std/__atomic_base#operator++(6390f2d371ad8d1d).exceptions_caughtcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/exceptions_caught.; |
| 87 | if (exceptions == 2) { |
| 88 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_JOB_OFFLINEcxx . . $ CORO_JOB_OFFLINE., ts_successcxx . . $ ts_success.); |
| 89 | } else if (exceptions > 2) { |
| 90 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_JOB_OFFLINEcxx . . $ CORO_JOB_OFFLINE., ts_failedcxx . . $ ts_failed., "resume() threw more than expected"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 91 | } |
| 92 | } catch (const stdcxx . . $ std/::exception &) { |
| 93 | /* anything else should not be caught */ |
| 94 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_JOB_OFFLINEcxx . . $ CORO_JOB_OFFLINE., ts_failedcxx . . $ ts_failed., "resume() threw an exception it shouldn't have"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 95 | } |
| 96 | }); |
| 97 | th.detachcxx . . $ std/thread#detach(49f6e7a06ebc5aa8).(); |
| 98 | } |
| 99 | |
| 100 | int await_resumecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#await_resume(ea6fe5115c70a13f).() const noexcept { |
| 101 | return resultcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#result.; |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | dpp::jobcxx . . $ dpp/job# job_offline_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_offline_test(c33884b4752ab64b).() { |
| 106 | if (int ret = co_await job_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#{42}; ret != 42) { |
| 107 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_JOB_OFFLINEcxx . . $ CORO_JOB_OFFLINE., ts_failedcxx . . $ ts_failed., "failed simple awaitable"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 108 | } |
| 109 | stdcxx . . $ std/::arraycxx . . $ std/array#<dpp::jobcxx . . $ dpp/job#, 10> jobs; |
| 110 | for (int i = 0; i < 10; ++i) { |
| 111 | jobs[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ dpp/job#`operator=`(9f5bb5e7b0275f4f). [](int i) -> dpp::jobcxx . . $ dpp/job# { |
| 112 | static stdcxx . . $ std/::atomiccxx . . $ std/atomic#<bool> passed = falsecxx . . $ std/atomic#atomic(9f0ba574c1c44ffc).; |
| 113 | if (int ret = co_await job_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_awaitable#{i}; ret != i) { |
| 114 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_JOB_OFFLINEcxx . . $ CORO_JOB_OFFLINE., ts_failedcxx . . $ ts_failed., "failed in-loop awaitable"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 115 | } |
| 116 | job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data.[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ std/__atomic_base#`operator=`(73de6b30e1938209). i; |
| 117 | for (int j = 0; j < 10; ++j) { |
| 118 | if (job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data.[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).j] != j) { |
| 119 | co_return; |
| 120 | } |
| 121 | } |
| 122 | if (passed.exchangecxx . . $ std/atomic#exchange(971f44b7eb749184).(true) == true) { // another thread came here and already passed this check, skip the exception |
| 123 | co_return; |
| 124 | } |
| 125 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<42>(); // should be caught by simple_awaitable (since this is after resume) |
| 126 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_offline_test(c33884b4752ab64b).$anonymous_type_0#`operator()`(ad53b9eaa4ba0f7a).i); |
| 127 | } |
| 128 | if (stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).(job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data..begincxx . . $ std/array#begin(258ee1c9e0a18a5c).(), job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data..endcxx . . $ std/array#end(258ee1c9e0a18a5c).(), [](int i){ return i > 0; }) != job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data..endcxx . . $ std/array#end(258ee1c9e0a18a5c).()) { |
| 129 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_JOB_OFFLINEcxx . . $ CORO_JOB_OFFLINE., ts_failedcxx . . $ ts_failed., "job should not have modified the data at this point"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 130 | } |
| 131 | |
| 132 | // verify that exceptions work as expected (dpp::job throws uncaught exceptions immediately to the caller / resumer) |
| 133 | try { |
| 134 | []() -> dpp::jobcxx . . $ dpp/job# { |
| 135 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<1>{}; |
| 136 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_offline_test(c33884b4752ab64b).$anonymous_type_1#`operator()`(e608017bfc30d23).); |
| 137 | } catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<1> &) { |
| 138 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<42>{}; // should be caught by simple_awaitable (since this is after resume) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | dpp::taskcxx . . $ dpp/task#<void> task_offline_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).() { |
| 143 | namespace time = stdcxx . . $ std/::chrono; |
| 144 | using clockcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).clock# = time::system_clockcxx . . $ std/chrono/_V2/system_clock#; |
| 145 | static auto &test = CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE.; |
| 146 | |
| 147 | if (int ret = co_await simple_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#{test, 42}; ret != 42) { |
| 148 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed simple awaitable"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 149 | } |
| 150 | |
| 151 | if (int ret = co_await []() -> dpp::taskcxx . . $ dpp/task#<int> { co_return 42; }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).$anonymous_type_2#`operator()`(a665ed50b8bb703a).); ret != 42) { |
| 152 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed simple task"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 153 | } |
| 154 | |
| 155 | stdcxx . . $ std/::arraycxx . . $ std/array#<dpp::taskcxx . . $ dpp/task#<int>, 10> tasks; |
| 156 | auto start = clockcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(3657dacbd9b4f607).(); |
| 157 | for (int i = 0; i < 10; ++i) { |
| 158 | tasks[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ dpp/task#`operator=`(837d4efec9a9b7ee). [](int i) -> dpp::taskcxx . . $ dpp/task#<int> { |
| 159 | if (int ret = co_await simple_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#{test, i}; ret != i) { |
| 160 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed in-loop awaitable"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 161 | } |
| 162 | job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data.[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ std/__atomic_base#`operator=`(73de6b30e1938209). i; |
| 163 | co_return i; |
| 164 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).$anonymous_type_3#`operator()`(fea6aa3611ce71d).i); |
| 165 | } |
| 166 | for (int i = 0; i < 10; ++i) { |
| 167 | if (co_await tasks[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] != i) { |
| 168 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed to co_await expected value"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 169 | } |
| 170 | } |
| 171 | auto diff = clockcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(3657dacbd9b4f607).() -cxx . . $ std/chrono/operator-(37d29b8d7121dc12). start; |
| 172 | if (diff > timecxx . . $ std/chrono/duration#duration(edcd8b2679e9bd1a).::secondscxx . . $ std/chrono/seconds#(10)) { // task is async so 10 parallel tasks should all take 5 seconds + some overhead |
| 173 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "parallel tasks took longer than expected"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 174 | } |
| 175 | |
| 176 | // verify that exceptions work as expected (dpp::task throws uncaught exceptions to co_await-er) |
| 177 | dpp::task task1cxx . . $ dpp/task#task(49f6e7a06ebc5aa8).; |
| 178 | dpp::task task2cxx . . $ dpp/task#task(49f6e7a06ebc5aa8).; |
| 179 | try { |
| 180 | task1 =cxx . . $ dpp/task#`operator=`(837d4efec9a9b7ee). []() -> dpp::taskcxx . . $ dpp/task#<void> { // throws after co_await |
| 181 | if (int ret = co_await simple_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#{test, 69}; ret != 69) { |
| 182 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "nested failed simple awaitable"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 183 | } |
| 184 | dpp::task task2 = []() -> dpp::taskcxx . . $ dpp/task#<void> { |
| 185 | co_await std_coroutine::suspend_nevercxx . . $ std/__n4861/suspend_never#{}; // needed to make sure the task is initialized properly |
| 186 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<1>{}; |
| 187 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).$anonymous_type_4#`operator()`(6cbe4ee28cb417b7).$anonymous_type_5#`operator()`(6cbe4ee28cb417b7).); |
| 188 | co_await task2; |
| 189 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).$anonymous_type_4#`operator()`(6cbe4ee28cb417b7).); |
| 190 | task2 =cxx . . $ dpp/task#`operator=`(837d4efec9a9b7ee). []() -> dpp::taskcxx . . $ dpp/task#<void> { // throws immediately |
| 191 | co_await std_coroutine::suspend_nevercxx . . $ std/__n4861/suspend_never#{}; // needed to make sure the task is initialized properly |
| 192 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<2>{}; |
| 193 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).$anonymous_type_6#`operator()`(6cbe4ee28cb417b7).); |
| 194 | } catch (const stdcxx . . $ std/::exception &e) { |
| 195 | /* SHOULD NOT throw. exceptions are sent when resuming from co_await */ |
| 196 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "task threw in constructor"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 197 | } |
| 198 | |
| 199 | bool success = false; |
| 200 | // test throw after co_await |
| 201 | try { |
| 202 | co_await task1; |
| 203 | } catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<1> &) { |
| 204 | success = true; |
| 205 | } |
| 206 | if (!success) { |
| 207 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE., ts_failedcxx . . $ ts_failed., "task failed to throw expected test_exception<1>"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 208 | } |
| 209 | success = false; |
| 210 | // test throw without suspending |
| 211 | try { |
| 212 | co_await task2; |
| 213 | } |
| 214 | catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<2> &) { |
| 215 | success = true; |
| 216 | } |
| 217 | if (!success) { |
| 218 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE., ts_failedcxx . . $ ts_failed., "task failed to throw expected test_exception<2>"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 219 | } |
| 220 | // test cancel (throws dpp::task_cancelled_exception) |
| 221 | auto task3 = []() -> dpp::taskcxx . . $ dpp/task#<void> { |
| 222 | auto make_task = []() -> dpp::taskcxx . . $ dpp/task#<void> { |
| 223 | for (int i = 0; i < 5; ++i) { |
| 224 | co_await dppcxx . . $ dpp/async#async(1aca2567cfc30dcc).::asynccxx . . $ dpp/async#<int>(&async_awaitable_wait5cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/async_awaitable_wait5(c984aeb66bdba57e).); |
| 225 | } |
| 226 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE., ts_failedcxx . . $ ts_failed., "failed to cancel nested task"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 227 | }; |
| 228 | stdcxx . . $ std/::arraycxx . . $ std/array#<dpp::taskcxx . . $ dpp/task#<void>, 3> tasks; |
| 229 | |
| 230 | // test cancel and catch { |
| 231 | auto start_time = clockcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(3657dacbd9b4f607).(); |
| 232 | int exceptions = 0; |
| 233 | stdcxx . . $ std/::generatecxx . . $ std/generate(4d3091562df4e52e).(tasks.begincxx . . $ std/array#begin(258ee1c9e0a18a5c).(), tasks.endcxx . . $ std/array#end(258ee1c9e0a18a5c).(), make_task); |
| 234 | for (auto &task : tasks) { |
| 235 | task.cancelcxx . . $ dpp/task#cancel(4984a3f7b2ad116d).(); |
| 236 | } |
| 237 | for (auto &task : tasks) { |
| 238 | try { |
| 239 | co_await task; |
| 240 | } |
| 241 | catch (const dpp::task_cancelled_exceptioncxx . . $ dpp/task_cancelled_exception# &) { |
| 242 | ++exceptions; |
| 243 | } |
| 244 | } |
| 245 | if (exceptions < 3 || !(clockcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(3657dacbd9b4f607).() -cxx . . $ std/chrono/operator-(37d29b8d7121dc12). start_time < stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(10))) { |
| 246 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE., ts_failedcxx . . $ ts_failed., "failed to cancel 3 nested tasks in time"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 247 | } |
| 248 | |
| 249 | // test cancel and propagate { |
| 250 | stdcxx . . $ std/::generatecxx . . $ std/generate(4d3091562df4e52e).(tasks.begincxx . . $ std/array#begin(258ee1c9e0a18a5c).(), tasks.endcxx . . $ std/array#end(258ee1c9e0a18a5c).(), make_task); |
| 251 | tasks[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).0].cancelcxx . . $ dpp/task#cancel(4984a3f7b2ad116d).(); |
| 252 | for (auto &task : tasks) { |
| 253 | co_await task; // tasks[0] should throw |
| 254 | } |
| 255 | // unreachable normally |
| 256 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE., ts_failedcxx . . $ ts_failed., "failed to exit the scope after expected dpp::task_cancelled_exception"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 257 | // } |
| 258 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).$anonymous_type_7#`operator()`(6cbe4ee28cb417b7).); |
| 259 | try { |
| 260 | co_await task3; |
| 261 | } |
| 262 | catch (const dpp::task_cancelled_exceptioncxx . . $ dpp/task_cancelled_exception# &) { |
| 263 | success = true; |
| 264 | } |
| 265 | if (!success) { |
| 266 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE., ts_failedcxx . . $ ts_failed., "failed to propagate dpp::task_cancelled_exception to caller"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 267 | } |
| 268 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<0>{}; |
| 269 | } |
| 270 | |
| 271 | dpp::coroutinecxx . . $ dpp/coroutine#<void> coroutine_offline_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coroutine_offline_test(8198ae2cf581da0b).() { |
| 272 | static auto &test = CORO_COROUTINE_OFFLINEcxx . . $ CORO_COROUTINE_OFFLINE.; |
| 273 | stdcxx . . $ std/::arraycxx . . $ std/array#<int, 3> data; |
| 274 | int num = 0; |
| 275 | |
| 276 | auto factory = [&data](int &i) -> dpp::coroutinecxx . . $ dpp/coroutine#<int> { |
| 277 | if (int ret = co_await simple_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#{test, 42}; ret != 42) { |
| 278 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed simple awaitable"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 279 | } |
| 280 | data[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] = i; |
| 281 | co_return i++; |
| 282 | }; |
| 283 | if (int ret = co_await factory(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coroutine_offline_test(8198ae2cf581da0b).$anonymous_type_8#`operator()`(322a23a6e0881ced).num); ret != 0) { |
| 284 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "coroutine 1 to set expected values"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 285 | } |
| 286 | if (int ret = co_await factory(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coroutine_offline_test(8198ae2cf581da0b).$anonymous_type_8#`operator()`(322a23a6e0881ced).num); ret != 1) { |
| 287 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "coroutine 2 to set expected values"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 288 | } |
| 289 | if (int ret = co_await factory(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coroutine_offline_test(8198ae2cf581da0b).$anonymous_type_8#`operator()`(322a23a6e0881ced).num); ret != 2) { |
| 290 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "coroutine 3 to set expected values"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 291 | } |
| 292 | if (data != stdcxx . . $ std/::to_arraycxx . . $ std/to_array(2dfd72e70766ba03).<int>({0, 1, 2})) { |
| 293 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "unexpected test data"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 294 | } |
| 295 | |
| 296 | // verify that exceptions work as expected (dpp::coroutine throws uncaught exceptions to co_await-er) |
| 297 | co_await []() -> dpp::coroutinecxx . . $ dpp/coroutine#<void> { |
| 298 | dpp::coroutinecxx . . $ dpp/coroutine#<void> nested1cxx . . $ dpp/coroutine#coroutine(49f6e7a06ebc5aa8).; |
| 299 | dpp::coroutinecxx . . $ dpp/coroutine#<void> nested2cxx . . $ dpp/coroutine#coroutine(49f6e7a06ebc5aa8).; |
| 300 | try { |
| 301 | nested1 =cxx . . $ dpp/coroutine#`operator=`(3beb3ab755c2bef2). []() -> dpp::coroutinecxx . . $ dpp/coroutine#<void> { |
| 302 | int n = rand(); |
| 303 | if (int ret = co_await simple_awaitablecxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/simple_awaitable#{test, n}; ret != n) { |
| 304 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "nested failed simple awaitable"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 305 | } |
| 306 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<1>{}; |
| 307 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coroutine_offline_test(8198ae2cf581da0b).$anonymous_type_9#`operator()`(6f70ad8f8259bec9).$anonymous_type_10#`operator()`(6f70ad8f8259bec9).); |
| 308 | nested2 =cxx . . $ dpp/coroutine#`operator=`(3beb3ab755c2bef2). []() -> dpp::coroutinecxx . . $ dpp/coroutine#<void> { |
| 309 | co_await std_coroutine::suspend_nevercxx . . $ std/__n4861/suspend_never#{}; |
| 310 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<2>{}; |
| 311 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coroutine_offline_test(8198ae2cf581da0b).$anonymous_type_9#`operator()`(6f70ad8f8259bec9).$anonymous_type_11#`operator()`(6f70ad8f8259bec9).); |
| 312 | } catch (const stdcxx . . $ std/::exception &e) { |
| 313 | /* SHOULD NOT throw. exceptions are sent when resuming from co_await */ |
| 314 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "threw before co_await"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 315 | } |
| 316 | bool success1 = false; |
| 317 | bool success2 = false; |
| 318 | try { |
| 319 | co_await nested1; |
| 320 | } catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<1> &) { |
| 321 | success1 = true; |
| 322 | } |
| 323 | try { |
| 324 | co_await nested2; |
| 325 | } catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<2> &) { |
| 326 | success2 = true; |
| 327 | } |
| 328 | if (success1 && success2) { |
| 329 | throw test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<0>{}; |
| 330 | } else { |
| 331 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed to throw at co_await"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 332 | } |
| 333 | }(cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coroutine_offline_test(8198ae2cf581da0b).$anonymous_type_9#`operator()`(6f70ad8f8259bec9).); // test_exception<0> escapes |
| 334 | } |
| 335 | |
| 336 | dpp::jobcxx . . $ dpp/job# async_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/async_test(c33884b4752ab64b).() { |
| 337 | namespace time = stdcxx . . $ std/::chrono; |
| 338 | using clockcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/async_test(c33884b4752ab64b).clock# = time::system_clockcxx . . $ std/chrono/_V2/system_clock#; |
| 339 | test_tcxx . . $ test_t# &test = CORO_ASYNC_OFFLINEcxx . . $ CORO_ASYNC_OFFLINE.; |
| 340 | try { |
| 341 | stdcxx . . $ std/::arraycxx . . $ std/array#<dpp::asynccxx . . $ dpp/async#<int>, 10> arr; |
| 342 | |
| 343 | stdcxx . . $ std/::generatecxx . . $ std/generate(4d3091562df4e52e).(arr.begincxx . . $ std/array#begin(258ee1c9e0a18a5c).(), arr.endcxx . . $ std/array#end(258ee1c9e0a18a5c).(), [] { return dppcxx . . $ dpp/async#async(1aca2567cfc30dcc).::asynccxx . . $ dpp/async#<int>{&sync_awaitable_funcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/sync_awaitable_fun(c984aeb66bdba57e).}; }); |
| 344 | for (auto &async : arr) { |
| 345 | if (int ret = co_await async; ret != 42) { |
| 346 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed to sync resume with expected value"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 347 | } |
| 348 | } |
| 349 | bool success = false; |
| 350 | try { |
| 351 | dpp::asynccxx . . $ dpp/async#<int> throwscxx . . $ dpp/async#async(1aca2567cfc30dcc).{&sync_awaitable_throwcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/sync_awaitable_throw(c984aeb66bdba57e).}; |
| 352 | } catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<0> &) { |
| 353 | success = true; |
| 354 | } |
| 355 | if (!success) { |
| 356 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed to propagate exception"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 357 | } |
| 358 | auto now = clockcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/async_test(c33884b4752ab64b).clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(3657dacbd9b4f607).(); |
| 359 | stdcxx . . $ std/::generatecxx . . $ std/generate(4d3091562df4e52e).(arr.begincxx . . $ std/array#begin(258ee1c9e0a18a5c).(), arr.endcxx . . $ std/array#end(258ee1c9e0a18a5c).(), [] { return dppcxx . . $ dpp/async#async(1aca2567cfc30dcc).::asynccxx . . $ dpp/async#<int>{&async_awaitable_wait5cxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/async_awaitable_wait5(c984aeb66bdba57e).}; }); |
| 360 | for (auto &async : arr) { |
| 361 | if (int ret = co_await async; ret != 69) { |
| 362 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "failed to async resume with expected value"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 363 | } |
| 364 | } |
| 365 | auto diff = clockcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/async_test(c33884b4752ab64b).clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(3657dacbd9b4f607).() -cxx . . $ std/chrono/operator-(37d29b8d7121dc12). now; |
| 366 | if (diff > timecxx . . $ std/chrono/duration#duration(edcd8b2679e9bd1a).::secondscxx . . $ std/chrono/seconds#(10)) { |
| 367 | // async executes asynchronously so we should be waiting 5 seconds + some overhead |
| 368 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., "parallel asyncs took more time than expected"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 369 | } |
| 370 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_successcxx . . $ ts_success.); |
| 371 | } catch (const stdcxx . . $ std/::exception &e) { |
| 372 | /* no exception should be caught here */ |
| 373 | set_statuscxx . . $ set_status(69213411294ab03e).(test, ts_failedcxx . . $ ts_failed., stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#{"unknown exception thrown: "} +cxx . . $ std/operator+(900ec9581c410ad9). e.what()); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | dpp::jobcxx . . $ dpp/job# coro_awaitable_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coro_awaitable_test(c33884b4752ab64b).() { |
| 378 | try { |
| 379 | { |
| 380 | dpp::promisecxx . . $ dpp/promise#<int> test; |
| 381 | |
| 382 | test.set_valuecxx . . $ dpp/moveable_promise#set_value(530dee76761bacf0).(42); |
| 383 | if (int res = co_await test.get_awaitablecxx . . $ dpp/moveable_promise#get_awaitable(3bc066d63172517c).(); res != 42) { |
| 384 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., "could not retrieve value set before co_await"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 385 | } |
| 386 | } |
| 387 | { |
| 388 | dpp::promisecxx . . $ dpp/promise#<int> test; |
| 389 | |
| 390 | test.set_valuecxx . . $ dpp/moveable_promise#set_value(530dee76761bacf0).(420); |
| 391 | if (int res = test.get_awaitablecxx . . $ dpp/moveable_promise#get_awaitable(3bc066d63172517c).().sync_waitcxx . . $ dpp/basic_awaitable#sync_wait(a52531b27a9fa42b).(); res != 420) { |
| 392 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., "could not retrieve value set before sync_wait"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 393 | } |
| 394 | } |
| 395 | { |
| 396 | dpp::promisecxx . . $ dpp/promise#<int> test; |
| 397 | dpp::awaitablecxx . . $ dpp/awaitable#<int> awaitablecxx . . $ dpp/awaitable#awaitable(49f6e7a06ebc5aa8).; |
| 398 | |
| 399 | awaitable =cxx . . $ dpp/awaitable#`operator=`(e832f598a895d51e). test.get_awaitablecxx . . $ dpp/moveable_promise#get_awaitable(3bc066d63172517c).(); |
| 400 | test.set_valuecxx . . $ dpp/moveable_promise#set_value(530dee76761bacf0).(420); |
| 401 | if (stdcxx . . $ std/::optionalcxx . . $ std/optional#<int> res = awaitable.sync_wait_forcxx . . $ dpp/basic_awaitable#sync_wait_for(d2d2ce0713064494).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(5)); !res || *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).res != 420) { |
| 402 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., "could not retrieve value set before sync_wait_for"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 403 | } |
| 404 | } |
| 405 | { |
| 406 | dpp::promisecxx . . $ dpp/promise#<void> test; |
| 407 | dpp::awaitable awaitable{test.get_awaitablecxx . . $ dpp/moveable_promise#get_awaitable(3bc066d63172517c).()}; |
| 408 | |
| 409 | if (bool res = awaitable.sync_wait_forcxx . . $ dpp/basic_awaitable#sync_wait_for(d2d2ce0713064494).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(5)); res) { |
| 410 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., "could not retrieve time out with sync_wait_for"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 411 | } |
| 412 | } |
| 413 | { |
| 414 | dpp::promisecxx . . $ dpp/promise#<int> test; |
| 415 | dpp::awaitable awaitable{test.get_awaitablecxx . . $ dpp/moveable_promise#get_awaitable(3bc066d63172517c).()}; |
| 416 | stdcxx . . $ std/::threadcxx . . $ std/thread# thcxx . . $ std/thread#thread(33bc091c26643b13).{[&test]() mutable { |
| 417 | stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(2)); |
| 418 | test.set_valuecxx . . $ dpp/moveable_promise#set_value(530dee76761bacf0).(69); |
| 419 | }}; |
| 420 | th.detachcxx . . $ std/thread#detach(49f6e7a06ebc5aa8).(); |
| 421 | if (stdcxx . . $ std/::optionalcxx . . $ std/optional#<int> res = awaitable.sync_wait_forcxx . . $ dpp/basic_awaitable#sync_wait_for(d2d2ce0713064494).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(5)); !res || *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).res != 69) { |
| 422 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., "could not retrieve value set after sync_wait_for"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 423 | } |
| 424 | } |
| 425 | { |
| 426 | dpp::promisecxx . . $ dpp/promise#<int> test; |
| 427 | dpp::awaitable awaitable{test.get_awaitablecxx . . $ dpp/moveable_promise#get_awaitable(3bc066d63172517c).()}; |
| 428 | stdcxx . . $ std/::threadcxx . . $ std/thread# thcxx . . $ std/thread#thread(33bc091c26643b13).{[p = stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(test)]() mutable { |
| 429 | stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(2)); |
| 430 | p.set_valuecxx . . $ dpp/moveable_promise#set_value(530dee76761bacf0).(69420); |
| 431 | }}; |
| 432 | th.detachcxx . . $ std/thread#detach(49f6e7a06ebc5aa8).(); |
| 433 | if (int res = co_await awaitable; res != 69420) { |
| 434 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., "could not retrieve value set after co_await"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 435 | } |
| 436 | } |
| 437 | { |
| 438 | dpp::promisecxx . . $ dpp/promise#<void> test; |
| 439 | dpp::awaitable awaitable{test.get_awaitablecxx . . $ dpp/moveable_promise#get_awaitable(3bc066d63172517c).()}; |
| 440 | stdcxx . . $ std/::threadcxx . . $ std/thread# thcxx . . $ std/thread#thread(33bc091c26643b13).{[p = stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(test)]() mutable { |
| 441 | stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(2)); |
| 442 | p.set_exceptioncxx . . $ dpp/moveable_promise#set_exception(116887243e1e07e2).(stdcxx . . $ std/::make_exception_ptr(dppcxx . . $ dpp/voice_exception#voice_exception(85c52e162fed56f9).::voice_exceptioncxx . . $ dpp/voice_exception#("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))); |
| 443 | }}; |
| 444 | th.detachcxx . . $ std/thread#detach(49f6e7a06ebc5aa8).(); |
| 445 | bool success = false; |
| 446 | try { |
| 447 | co_await awaitable; |
| 448 | } catch (const dpp::voice_exceptioncxx . . $ dpp/voice_exception# &) { |
| 449 | success = true; |
| 450 | } |
| 451 | if (!success) { |
| 452 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., "retrieval of an exception with co_await failed"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 453 | } |
| 454 | } |
| 455 | { |
| 456 | dpp::promisecxx . . $ dpp/promise#<void> test; |
| 457 | dpp::awaitable awaitable{test.get_awaitablecxx . . $ dpp/moveable_promise#get_awaitable(3bc066d63172517c).()}; |
| 458 | stdcxx . . $ std/::threadcxx . . $ std/thread# thcxx . . $ std/thread#thread(33bc091c26643b13).{[&test]() mutable { |
| 459 | stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(2)); |
| 460 | test.set_exceptioncxx . . $ dpp/moveable_promise#set_exception(116887243e1e07e2).(stdcxx . . $ std/::make_exception_ptr(dppcxx . . $ dpp/voice_exception#voice_exception(85c52e162fed56f9).::voice_exceptioncxx . . $ dpp/voice_exception#("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))); |
| 461 | }}; |
| 462 | th.detachcxx . . $ std/thread#detach(49f6e7a06ebc5aa8).(); |
| 463 | bool success = false; |
| 464 | try { |
| 465 | awaitable.sync_waitcxx . . $ dpp/basic_awaitable#sync_wait(a52531b27a9fa42b).(); |
| 466 | } catch (const dpp::voice_exceptioncxx . . $ dpp/voice_exception# &) { |
| 467 | success = true; |
| 468 | } |
| 469 | if (!success) { |
| 470 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., "retrieval of an exception with co_await failed"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 471 | } |
| 472 | } |
| 473 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_successcxx . . $ ts_success.); |
| 474 | } catch (const stdcxx . . $ std/::exception &e) { |
| 475 | // no exception should reach this point |
| 476 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE., ts_failedcxx . . $ ts_failed., stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#{"unknown exception thrown: "} +cxx . . $ std/operator+(900ec9581c410ad9). e.what()); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | } |
| 481 | |
| 482 | void coro_offline_testscxx . . $ coro_offline_tests(49f6e7a06ebc5aa8).() |
| 483 | { |
| 484 | start_testcxx . . $ start_test(271d3161c6a64dec).(CORO_JOB_OFFLINEcxx . . $ CORO_JOB_OFFLINE.); |
| 485 | // Initialize all job data to -1 |
| 486 | stdcxx . . $ std/::fillcxx . . $ std/fill(4a9bfaed88eccda7).(job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data..begincxx . . $ std/array#begin(258ee1c9e0a18a5c).(), job_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_data..endcxx . . $ std/array#end(258ee1c9e0a18a5c).(), -1); |
| 487 | job_offline_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/job_offline_test(c33884b4752ab64b).(); |
| 488 | |
| 489 | start_testcxx . . $ start_test(271d3161c6a64dec).(CORO_AWAITABLE_OFFLINEcxx . . $ CORO_AWAITABLE_OFFLINE.); |
| 490 | coro_awaitable_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coro_awaitable_test(c33884b4752ab64b).(); |
| 491 | |
| 492 | start_testcxx . . $ start_test(271d3161c6a64dec).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE.); |
| 493 | stdcxx . . $ std/::fillcxx . . $ std/fill(4a9bfaed88eccda7).(task_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_data..begincxx . . $ std/array#begin(258ee1c9e0a18a5c).(), task_datacxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_data..endcxx . . $ std/array#end(258ee1c9e0a18a5c).(), -1); |
| 494 | []() -> dpp::jobcxx . . $ dpp/job# { |
| 495 | dpp::task task = task_offline_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/task_offline_test(5688fa3095887389).(); |
| 496 | |
| 497 | try { |
| 498 | co_await dppcxx . . $ dpp/task#task(a069731a759ffd74).::task{stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(task)}; |
| 499 | } catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<0> &) { // exception thrown at the end of the task test |
| 500 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE., ts_successcxx . . $ ts_success.); |
| 501 | } catch (const stdcxx . . $ std/::exception &e) { // anything else should not escape |
| 502 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_TASK_OFFLINEcxx . . $ CORO_TASK_OFFLINE., ts_failedcxx . . $ ts_failed., stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#{"unknown exception thrown: "} +cxx . . $ std/operator+(900ec9581c410ad9). e.what()); |
| 503 | } |
| 504 | }(cxx . . $ coro_offline_tests(49f6e7a06ebc5aa8).$anonymous_type_12#`operator()`(e608017bfc30d23).); |
| 505 | |
| 506 | start_testcxx . . $ start_test(271d3161c6a64dec).(CORO_COROUTINE_OFFLINEcxx . . $ CORO_COROUTINE_OFFLINE.); |
| 507 | []() -> dpp::jobcxx . . $ dpp/job# { |
| 508 | dpp::coroutine task = coroutine_offline_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/coroutine_offline_test(8198ae2cf581da0b).(); |
| 509 | |
| 510 | try { |
| 511 | co_await dppcxx . . $ dpp/coroutine#coroutine(88b745da14615020).::coroutine{stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(task)}; |
| 512 | } catch (const test_exceptioncxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/test_exception#<0> &) { |
| 513 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_COROUTINE_OFFLINEcxx . . $ CORO_COROUTINE_OFFLINE., ts_successcxx . . $ ts_success.); |
| 514 | } catch (const stdcxx . . $ std/::exception &e) { // anything else should not escape |
| 515 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_COROUTINE_OFFLINEcxx . . $ CORO_COROUTINE_OFFLINE., ts_failedcxx . . $ ts_failed., stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#{"unknown exception thrown: "} +cxx . . $ std/operator+(900ec9581c410ad9). e.what()); |
| 516 | } |
| 517 | }(cxx . . $ coro_offline_tests(49f6e7a06ebc5aa8).$anonymous_type_13#`operator()`(e608017bfc30d23).); |
| 518 | |
| 519 | start_testcxx . . $ start_test(271d3161c6a64dec).(CORO_ASYNC_OFFLINEcxx . . $ CORO_ASYNC_OFFLINE.); |
| 520 | async_testcxx . . $ `$anonymous_namespace_src/unittest/coro.cpp`/async_test(c33884b4752ab64b).(); |
| 521 | } |
| 522 | |
| 523 | void event_handler_testcxx . . $ event_handler_test(a8df4c8451c92bc4).(dpp::clustercxx . . $ dpp/cluster# *bot) { |
| 524 | bot->on_message_createcxx . . $ dpp/cluster#on_message_create.(cxx . . $ dpp/event_router_t#`operator()`(7d840609c6f74506).[](dpp::message_create_tcxx . . $ dpp/message_create_t# event) -> dpp::taskcxx . . $ dpp/task#<void> { |
| 525 | if (event.msgcxx . . $ dpp/message_create_t#msg..contentcxx . . $ dpp/message#content. ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "coro test") { |
| 526 | dpp::clustercxx . . $ dpp/cluster# *bot = event.ownercxx . . $ dpp/event_dispatch_t#owner.; |
| 527 | |
| 528 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_EVENT_HANDLERcxx . . $ CORO_EVENT_HANDLER., ts_successcxx . . $ ts_success.); |
| 529 | start_testcxx . . $ start_test(271d3161c6a64dec).(CORO_API_CALLScxx . . $ CORO_API_CALLS.); |
| 530 | dpp::confirmation_callback_tcxx . . $ dpp/confirmation_callback_t# result = co_await bot->co_message_editcxx . . $ dpp/cluster#co_message_edit(2563c8d5fd3a6414).(dppcxx . . $ dpp/message#message(55ae228098ad4d0d).::messagecxx . . $ dpp/message#{event.msgcxx . . $ dpp/message_create_t#msg.}.set_contentcxx . . $ dpp/message#set_content(c72cb981026e5464).("coro 👍"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).)); |
| 531 | dpp::messagecxx . . $ dpp/message# *confirm = stdcxx . . $ std/::get_ifcxx . . $ std/get_if(a68aa1770ec1a016).<dpp::messagecxx . . $ dpp/message#>(&(result.valuecxx . . $ dpp/confirmation_callback_t#value.)); |
| 532 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_API_CALLScxx . . $ CORO_API_CALLS., (confirm == nullptr || confirm->contentcxx . . $ dpp/message#content. != "coro 👍") ? ts_failedcxx . . $ ts_failed. : ts_successcxx . . $ ts_success.); |
| 533 | |
| 534 | if (extendedcxx . . $ extended.) { |
| 535 | start_testcxx . . $ start_test(271d3161c6a64dec).(CORO_MUMBO_JUMBOcxx . . $ CORO_MUMBO_JUMBO.); |
| 536 | stdcxx . . $ std/::arraycxx . . $ std/array#<dpp::taskcxx . . $ dpp/task#<dpp::snowflakecxx . . $ dpp/snowflake#>, 3> tasks; |
| 537 | for (int i = 0; i < 3; ++i) { |
| 538 | tasks[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ dpp/task#`operator=`(837d4efec9a9b7ee). [](dpp::clustercxx . . $ dpp/cluster# *bot, dpp::snowflakecxx . . $ dpp/snowflake# channel, int i) -> dpp::taskcxx . . $ dpp/task#<dpp::snowflakecxx . . $ dpp/snowflake#> { |
| 539 | using user_membercxx . . $ event_handler_test(a8df4c8451c92bc4).$anonymous_type_14#`operator()`(f61405a2315e9500).$anonymous_type_15#`operator()`(f780a11beedc13ce).user_member# = stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::optionalcxx . . $ std/optional#<dpp::usercxx . . $ dpp/user#>, stdcxx . . $ std/::optionalcxx . . $ std/optional#<dpp::guild_membercxx . . $ dpp/guild_member#>>; |
| 540 | constexpr auto get_member_user = [](dpp::clustercxx . . $ dpp/cluster# *bot) -> dpp::taskcxx . . $ dpp/task#<user_membercxx . . $ event_handler_test(a8df4c8451c92bc4).$anonymous_type_14#`operator()`(f61405a2315e9500).$anonymous_type_15#`operator()`(f780a11beedc13ce).user_member#> { |
| 541 | stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::optionalcxx . . $ std/optional#<dpp::usercxx . . $ dpp/user#>, stdcxx . . $ std/::optionalcxx . . $ std/optional#<dpp::guild_membercxx . . $ dpp/guild_member#>> retcxx . . $ std/pair#pair(44d48473e6bc55c4).{}; |
| 542 | dpp::confirmation_callback_tcxx . . $ dpp/confirmation_callback_t# resultcxx . . $ dpp/confirmation_callback_t#confirmation_callback_t(ced63f7c635d850d).; |
| 543 | |
| 544 | try { |
| 545 | ret.secondcxx . . $ std/pair#second. =cxx . . $ std/optional#`operator=`(a631871c47728645). dpp::find_guild_membercxx . . $ dpp/find_guild_member(dc7e162ac81fc065).(TEST_GUILD_IDcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a)., TEST_USER_IDcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a).); |
| 546 | } catch (const dpp::cache_exceptioncxx . . $ dpp/cache_exception# &e) {} |
| 547 | if (!ret.secondcxx . . $ std/pair#second..has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) { |
| 548 | result =cxx . . $ dpp/confirmation_callback_t#`operator=`(46177a413ed0b668). co_await bot->co_guild_get_membercxx . . $ dpp/cluster#co_guild_get_member(9b262d3ac66f0237).(TEST_GUILD_IDcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a)., TEST_USER_IDcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a).); |
| 549 | if (!result.is_errorcxx . . $ dpp/confirmation_callback_t#is_error(50ce9a9e25b4a850).()) { |
| 550 | ret.secondcxx . . $ std/pair#second. =cxx . . $ std/optional#`operator=`(a631871c47728645). stdcxx . . $ std/::getcxx . . $ std/get(e13ef601cb0b8457).<dpp::guild_membercxx . . $ dpp/guild_member#>(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(result).valuecxx . . $ dpp/confirmation_callback_t#value.); |
| 551 | } |
| 552 | } |
| 553 | result =cxx . . $ dpp/confirmation_callback_t#`operator=`(46177a413ed0b668). co_await bot->co_user_get_cachedcxx . . $ dpp/cluster#co_user_get_cached(b9bfe20c50341c11).(TEST_USER_IDcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a).); |
| 554 | if (!result.is_errorcxx . . $ dpp/confirmation_callback_t#is_error(50ce9a9e25b4a850).()) { |
| 555 | ret.firstcxx . . $ std/pair#first. =cxx . . $ std/optional#`operator=`(a631871c47728645). stdcxx . . $ std/::getcxx . . $ std/get(e13ef601cb0b8457).<dpp::user_identifiedcxx . . $ dpp/user_identified#>(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(result).valuecxx . . $ dpp/confirmation_callback_t#value.); |
| 556 | } |
| 557 | co_return ret; |
| 558 | }; |
| 559 | auto get_member_task = get_member_user(cxx . . $ event_handler_test(a8df4c8451c92bc4).$anonymous_type_14#`operator()`(f61405a2315e9500).$anonymous_type_15#`operator()`(f780a11beedc13ce).$anonymous_type_16#`operator()`(5b2a612f623726b2).bot); |
| 560 | stdcxx . . $ std/::stringcxx . . $ std/string# content = "coro " +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(3d81e17e7a87eecc).(i); |
| 561 | dpp::confirmation_callback_tcxx . . $ dpp/confirmation_callback_t# result = co_await bot->co_message_createcxx . . $ dpp/cluster#co_message_create(2563c8d5fd3a6414).(dppcxx . . $ dpp/message#message(af8ef704783065ca).::messagecxx . . $ dpp/message#{channelcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a)., content}); |
| 562 | |
| 563 | if (result.is_errorcxx . . $ dpp/confirmation_callback_t#is_error(50ce9a9e25b4a850).()) { |
| 564 | co_return {}; |
| 565 | } |
| 566 | dpp::messagecxx . . $ dpp/message# msg = stdcxx . . $ dpp/message#message(fbaefccce6a326ce).::getcxx . . $ std/get(e13ef601cb0b8457).<dpp::messagecxx . . $ dpp/message#>(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(result).valuecxx . . $ dpp/confirmation_callback_t#value.); |
| 567 | if (msg.contentcxx . . $ dpp/message#content. != content) { |
| 568 | co_return {}; |
| 569 | } |
| 570 | user_membercxx . . $ event_handler_test(a8df4c8451c92bc4).$anonymous_type_14#`operator()`(f61405a2315e9500).$anonymous_type_15#`operator()`(f780a11beedc13ce).user_member# pair = co_await get_member_task; |
| 571 | if (!pair.firstcxx . . $ std/pair#first..has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) { |
| 572 | co_return {}; |
| 573 | } |
| 574 | const stdcxx . . $ std/::stringcxx . . $ std/string#& member_nick = pair.secondcxx . . $ std/pair#second..has_valuecxx . . $ std/optional#has_value(3482b152b9333168).() ? pair.secondcxx . . $ std/pair#second.->cxx . . $ std/optional#`operator->`(258ee1c9e0a18a5c).get_nicknamecxx . . $ dpp/guild_member#get_nickname(219584694fe2b248).() : ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 575 | const stdcxx . . $ std/::stringcxx . . $ std/string#& user_nick = pair.firstcxx . . $ std/pair#first.->cxx . . $ std/optional#`operator->`(258ee1c9e0a18a5c).usernamecxx . . $ dpp/user#username.; |
| 576 | result =cxx . . $ dpp/confirmation_callback_t#`operator=`(46177a413ed0b668). co_await bot->co_message_editcxx . . $ dpp/cluster#co_message_edit(2563c8d5fd3a6414).(msg.set_contentcxx . . $ dpp/message#set_content(c72cb981026e5464).("coro " +cxx . . $ std/operator+(42c652dfebe55ad7). (member_nick.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).() ? user_nick : member_nick) +cxx . . $ std/operator+(900ec9581c410ad9). " " +cxx . . $ std/operator+(aa1c00e85b87da6b). stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(3d81e17e7a87eecc).(i))); |
| 577 | co_return result.is_errorcxx . . $ dpp/confirmation_callback_t#is_error(50ce9a9e25b4a850).() ? dppcxx . . $ dpp/snowflake#snowflake(ced63f7c635d850d).::snowflakecxx . . $ dpp/snowflake#{} : stdcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a).::getcxx . . $ std/get(55ed64a6518b24d0).<dpp::messagecxx . . $ dpp/message#>(result.valuecxx . . $ dpp/confirmation_callback_t#value.).idcxx . . $ dpp/managed#id.; |
| 578 | }(cxx . . $ event_handler_test(a8df4c8451c92bc4).$anonymous_type_14#`operator()`(f61405a2315e9500).$anonymous_type_15#`operator()`(f780a11beedc13ce).bot, eventcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a)..msgcxx . . $ dpp/message_create_t#msg..channel_idcxx . . $ dpp/message#channel_id., i); |
| 579 | } |
| 580 | stdcxx . . $ std/::arraycxx . . $ std/array#<dpp::snowflakecxx . . $ dpp/snowflake#, 3> msg_ids; |
| 581 | stdcxx . . $ std/::arraycxx . . $ std/array#<dpp::asynccxx . . $ dpp/async#<dpp::confirmation_callback_tcxx . . $ dpp/confirmation_callback_t#>, 3> reacts; |
| 582 | for (int i = 0; i < 3; ++i) { |
| 583 | try { |
| 584 | msg_ids[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ dpp/snowflake#`operator=`(122bcd07d31bf2a4). co_await tasks[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i]; |
| 585 | |
| 586 | if (msg_ids[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] ==cxx . . $ dpp/snowflake#`operator==`(b7f99ffc707c9db7). dppcxx . . $ dpp/snowflake#snowflake(ced63f7c635d850d).::snowflakecxx . . $ dpp/snowflake#{}) { |
| 587 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_MUMBO_JUMBOcxx . . $ CORO_MUMBO_JUMBO., ts_failedcxx . . $ ts_failed., "failed to post message"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 588 | reacts[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ dpp/async#`operator=`(5545d88c415f6aca). dppcxx . . $ dpp/async#async(1aca2567cfc30dcc).::async{[](auto &&cc) { cc(dppcxx . . $ dpp/confirmation_callback_t#confirmation_callback_t(ced63f7c635d850d).::confirmation_callback_tcxx . . $ dpp/confirmation_callback_t#{}); }}; |
| 589 | } else { |
| 590 | reacts[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ dpp/async#`operator=`(5545d88c415f6aca). bot->co_message_add_reactioncxx . . $ dpp/cluster#co_message_add_reaction(4fb97adb04eace20).(msg_idscxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a).[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i], eventcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a)..msgcxx . . $ dpp/message_create_t#msg..channel_idcxx . . $ dpp/message#channel_id., "✅"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 591 | } |
| 592 | } catch (const stdcxx . . $ std/::exception &e) { |
| 593 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_MUMBO_JUMBOcxx . . $ CORO_MUMBO_JUMBO., ts_failedcxx . . $ ts_failed., "message task threw " +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#{e.what()}); |
| 594 | reacts[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i] =cxx . . $ dpp/async#`operator=`(5545d88c415f6aca). dppcxx . . $ dpp/async#async(1aca2567cfc30dcc).::async{[](auto &&cc) { cc(dppcxx . . $ dpp/confirmation_callback_t#confirmation_callback_t(ced63f7c635d850d).::confirmation_callback_tcxx . . $ dpp/confirmation_callback_t#{}); }}; |
| 595 | } |
| 596 | } |
| 597 | for (int i = 0; i < 3; ++i) { |
| 598 | try { |
| 599 | dpp::confirmation_callback_tcxx . . $ dpp/confirmation_callback_t# result = co_await reacts[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i]; |
| 600 | } catch (const stdcxx . . $ std/::exception &e) { |
| 601 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_MUMBO_JUMBOcxx . . $ CORO_MUMBO_JUMBO., ts_failedcxx . . $ ts_failed., "react task threw " +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).::stringcxx . . $ std/string#{e.what()}); |
| 602 | } |
| 603 | } |
| 604 | for (int i = 0; i < 3; ++i) { |
| 605 | bot->message_deletecxx . . $ dpp/cluster#message_delete(8674faafcd829b3c).(msg_idscxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a).[cxx . . $ std/array#`operator[]`(b18cc97d22f46aed).i], eventcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a)..msgcxx . . $ dpp/message_create_t#msg..channel_idcxx . . $ dpp/message#channel_id.); |
| 606 | } |
| 607 | set_statuscxx . . $ set_status(69213411294ab03e).(CORO_MUMBO_JUMBOcxx . . $ CORO_MUMBO_JUMBO., ts_successcxx . . $ ts_success.); |
| 608 | } |
| 609 | } |
| 610 | co_return; |
| 611 | }); |
| 612 | bot->message_createcxx . . $ dpp/cluster#message_create(1c8df330753bdf1).(dppcxx . . $ dpp/message#message(fbcd06f54f544a76).::messagecxx . . $ dpp/message#{"coro test"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).}.set_channel_idcxx . . $ dpp/message#set_channel_id(5838913a8bdb38e4).(TEST_TEXT_CHANNEL_IDcxx . . $ dpp/snowflake#snowflake(14a7ecd272f4e02a).)); |
| 613 | } |
| 614 | |
| 615 | void coro_online_testscxx . . $ coro_online_tests(a8df4c8451c92bc4).(dpp::clustercxx . . $ dpp/cluster# *bot) { |
| 616 | start_testcxx . . $ start_test(271d3161c6a64dec).(CORO_EVENT_HANDLERcxx . . $ CORO_EVENT_HANDLER.); |
| 617 | event_handler_testcxx . . $ event_handler_test(a8df4c8451c92bc4).(bot); |
| 618 | } |
| 619 | |
| 620 | #else |
| 621 | |
| 622 | void coro_offline_tests() {} |
| 623 | void coro_online_tests(dpp::cluster *bot) {} |
| 624 | |
| 625 | #endif |