-
Notifications
You must be signed in to change notification settings - Fork 24
added tests for completions being called and fixed an issue with let #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+153
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // tests/beman/execution/include/test/completion_test.hpp -*-C++-*- | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #ifndef INCLUDED_TESTS_BEMAN_EXECUTION_INCLUDE_TEST_COMPLETION_TEST | ||
| #define INCLUDED_TESTS_BEMAN_EXECUTION_INCLUDE_TEST_COMPLETION_TEST | ||
|
|
||
| #include <beman/execution/detail/common.hpp> | ||
| #include <test/execution.hpp> | ||
| #ifdef BEMAN_HAS_IMPORT_STD | ||
| import std; | ||
| #else | ||
| #include <concepts> | ||
| #include <cstddef> | ||
| #include <functional> | ||
| #include <utility> | ||
| #include <type_traits> | ||
| #endif | ||
| #ifdef BEMAN_HAS_MODULES | ||
| import beman.execution.detail.completion_signatures; | ||
| import beman.execution.detail.connect; | ||
| import beman.execution.detail.env_of_t; | ||
| import beman.execution.detail.get_completion_signatures; | ||
| import beman.execution.detail.get_env; | ||
| import beman.execution.detail.operation_state; | ||
| import beman.execution.detail.receiver; | ||
| import beman.execution.detail.sender; | ||
| import beman.execution.detail.set_error; | ||
| import beman.execution.detail.set_stopped; | ||
| import beman.execution.detail.set_value; | ||
| import beman.execution.detail.start; | ||
| #else | ||
| #include <beman/execution/detail/completion_signatures.hpp> | ||
| #include <beman/execution/detail/connect.hpp> | ||
| #include <beman/execution/detail/env_of_t.hpp> | ||
| #include <beman/execution/detail/get_completion_signatures.hpp> | ||
| #include <beman/execution/detail/get_env.hpp> | ||
| #include <beman/execution/detail/operation_state.hpp> | ||
| #include <beman/execution/detail/receiver.hpp> | ||
| #include <beman/execution/detail/sender.hpp> | ||
| #include <beman/execution/detail/set_error.hpp> | ||
| #include <beman/execution/detail/set_stopped.hpp> | ||
| #include <beman/execution/detail/set_value.hpp> | ||
| #include <beman/execution/detail/start.hpp> | ||
| #endif | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| namespace test { | ||
| struct completion_test_base { | ||
| virtual auto complete() const noexcept -> void = 0; | ||
| }; | ||
| template <typename> | ||
| struct completion_test_function; | ||
|
|
||
| template <typename... T> | ||
| struct completion_test_function<::beman::execution::set_value_t(T...)> : completion_test_base { | ||
| auto set_value(T...) const noexcept -> void { this->complete(); } | ||
| }; | ||
| template <typename E> | ||
| struct completion_test_function<::beman::execution::set_error_t(E)> : completion_test_base { | ||
| auto set_error(E) const noexcept -> void { this->complete(); } | ||
| }; | ||
| template <> | ||
| struct completion_test_function<::beman::execution::set_stopped_t()> : completion_test_base { | ||
| auto set_stopped() const noexcept -> void { this->complete(); } | ||
| }; | ||
|
|
||
| template <typename> | ||
| struct completion_test_receiver; | ||
| template <typename... Sigs> | ||
| struct completion_test_receiver<::beman::execution::completion_signatures<Sigs...>> | ||
| : completion_test_function<Sigs>... {}; | ||
|
|
||
| template <::beman::execution::sender Sender> | ||
| struct completion_test { | ||
| using sender_concept = ::beman::execution::sender_t; | ||
| template <typename...> | ||
| static consteval auto get_completion_signatures() noexcept { | ||
| return ::beman::execution::completion_signatures<::beman::execution::set_value_t()>(); | ||
| } | ||
|
|
||
| template <::beman::execution::receiver Receiver> | ||
| struct state { | ||
| using operation_state_concept = ::beman::execution::operation_state_t; | ||
| struct inner_receiver | ||
| : test::completion_test_receiver< | ||
| decltype(::beman::execution::get_completion_signatures<Sender, | ||
| ::beman::execution::env_of_t<Receiver>>())> { | ||
| using receiver_concept = ::beman::execution::receiver_t; | ||
| state* st; | ||
| auto get_env() const noexcept -> ::beman::execution::env_of_t<Receiver> { | ||
| return ::beman::execution::get_env(this->st->receiver); | ||
| } | ||
| auto complete() const noexcept -> void override { | ||
| ::beman::execution::set_value(std::move(this->st->receiver)); | ||
| } | ||
|
dietmarkuehl marked this conversation as resolved.
|
||
| inner_receiver(state* s) : st(s) {} | ||
| }; | ||
| using inner_state_t = | ||
| decltype(::beman::execution::connect(std::declval<Sender>(), std::declval<inner_receiver>())); | ||
|
|
||
| std::remove_cvref_t<Receiver> receiver; | ||
| inner_state_t inner_state; | ||
|
|
||
| template <::beman::execution::receiver R, ::beman::execution::sender S> | ||
| state(R&& r, S&& s) | ||
| : receiver(std::forward<R>(r)), | ||
| inner_state(::beman::execution::connect(std::forward<S>(s), inner_receiver(this))) {} | ||
| auto start() noexcept { ::beman::execution::start(this->inner_state); } | ||
| }; | ||
|
|
||
| Sender sender; | ||
|
|
||
| template <::beman::execution::receiver Receiver> | ||
| auto connect(Receiver&& r) && { | ||
| return state<Receiver>{std::forward<Receiver>(r), std::move(this->sender)}; | ||
| } | ||
| }; | ||
|
|
||
| template <::beman::execution::sender Sender> | ||
| completion_test(Sender&& sender) -> completion_test<std::remove_cvref_t<Sender>>; | ||
| } // namespace test | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| #endif | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.