From 749b33c586bcb492c8c422188a545d1fa8ae0031 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov <0x7fffff@guattari.ru> Date: Thu, 25 Aug 2022 01:38:09 +0400 Subject: [async_function] Static coroutines --- source/test/unittests/async_function.test.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'source/test/unittests/async_function.test.c') diff --git a/source/test/unittests/async_function.test.c b/source/test/unittests/async_function.test.c index 1ff3031..5816bfc 100644 --- a/source/test/unittests/async_function.test.c +++ b/source/test/unittests/async_function.test.c @@ -3,31 +3,37 @@ #define KIT_TEST_FILE async_function #include "../../kit_test/test.h" -CORO(int, test_foo) { +AF_STATE(int, test_foo); +static AF_DECL(test_foo); + +CORO_IMPL(test_foo) { AF_RETURN(42); } CORO_END -CORO(int, test_bar) { +AF_STATE(int, test_bar); +static AF_DECL(test_bar); + +CORO_IMPL(test_bar) { AF_YIELD_VOID; AF_RETURN(42); } CORO_END -CORO(int, test_gen, int i; int min; int max;) { +STATIC_CORO(int, test_gen, int i; int min; int max;) { for (af i = af min; af i < af max; af i++) AF_YIELD(af i); AF_RETURN(af max); } CORO_END -CORO_VOID(test_task) { +STATIC_CORO_VOID(test_task) { AF_YIELD_VOID; AF_YIELD_VOID; AF_RETURN_VOID; } CORO_END -CORO_VOID(test_nest_task, AF_TYPE(test_task) promise;) { +STATIC_CORO_VOID(test_nest_task, AF_TYPE(test_task) promise;) { AF_INIT(af promise, test_task); AF_AWAIT(af promise); AF_AWAIT(af promise); @@ -35,13 +41,13 @@ CORO_VOID(test_nest_task, AF_TYPE(test_task) promise;) { } CORO_END -CORO(int, test_nest_generator, AF_TYPE(test_gen) promise;) { +STATIC_CORO(int, test_nest_generator, AF_TYPE(test_gen) promise;) { AF_INIT(af promise, test_gen, .min = 1, .max = 3); AF_YIELD_AWAIT(af promise); } CORO_END -CORO(int, test_join_multiple, AF_TYPE(test_bar) promises[3];) { +STATIC_CORO(int, test_join_multiple, AF_TYPE(test_bar) promises[3];) { for (int i = 0; i < 3; i++) AF_INIT(af promises[i], test_bar, .return_value = 0); AF_RESUME_AND_JOIN_ALL(af promises); @@ -51,7 +57,8 @@ CORO(int, test_join_multiple, AF_TYPE(test_bar) promises[3];) { } CORO_END -CORO(int, test_await_multiple, AF_TYPE(test_bar) promises[3];) { +STATIC_CORO(int, test_await_multiple, + AF_TYPE(test_bar) promises[3];) { for (int i = 0; i < 3; i++) AF_INIT(af promises[i], test_bar, .return_value = 0); AF_AWAIT_ALL(af promises); -- cgit v1.2.3