diff --git a/include/beman/execution/detail/scope_token.hpp b/include/beman/execution/detail/scope_token.hpp index edb98279..b0c0984f 100644 --- a/include/beman/execution/detail/scope_token.hpp +++ b/include/beman/execution/detail/scope_token.hpp @@ -17,7 +17,8 @@ struct token_test_env {}; struct token_test_sender { using sender_concept = ::beman::execution::sender_t; - auto get_completion_signatures(::beman::execution::detail::token_test_env) const noexcept { + template + auto get_completion_signatures(const Env&...) const noexcept { return ::beman::execution::completion_signatures<>{}; } }; diff --git a/tests/beman/execution/exec-then.test.cpp b/tests/beman/execution/exec-then.test.cpp index cb333c87..604d7022 100644 --- a/tests/beman/execution/exec-then.test.cpp +++ b/tests/beman/execution/exec-then.test.cpp @@ -5,6 +5,8 @@ #include #include +#include +#include #include #include #include @@ -22,12 +24,21 @@ struct error { }; struct non_sender {}; +struct get_value_t : test_std::forwarding_query_t { + auto operator()(const auto& e) const noexcept -> int { return e.query(*this); } +}; + struct receiver { using receiver_concept = test_std::receiver_t; auto set_error(auto&&) && noexcept -> void {} auto set_stopped() && noexcept -> void {} auto set_value(auto&&...) && noexcept -> void {} + + struct env { + auto query(const get_value_t&) const noexcept { return 42; } + }; + auto get_env() const noexcept { return env{}; } }; template @@ -214,6 +225,28 @@ auto test_then_allocator() -> void { auto state{test_std::connect(std::move(sender), memory_receiver{&resource2})}; ASSERT(resource2.count == 1u); } + +auto test_then_env() -> void { + { + receiver r{}; + auto e{test_std::get_env(r)}; + ASSERT(e.query(get_value_t{}) == 42); + ASSERT(get_value_t{}(e) == 42); + } + { + auto state{test_std::connect(test_std::read_env(get_value_t{}), receiver{})}; + test_std::start(state); + } + { + int value{0}; + auto state{test_std::connect(test_std::then(test_std::read_env(get_value_t{}), [&value](int v) { value = v; }), + receiver{})}; + ASSERT(value == 0); + test_std::start(state); + ASSERT(value == 42); + } +} + } // namespace TEST(exec_then) { @@ -230,4 +263,6 @@ TEST(exec_then) { test_then_multi_type(); test_then_value(); test_then_allocator(); + + test_then_env(); }