55
66#include < beman/execution/detail/completion_signatures_of_t.hpp>
77#include < beman/execution/detail/connect.hpp>
8+ #include < beman/execution/detail/forwarding_query.hpp>
9+ #include < beman/execution/detail/read_env.hpp>
810#include < beman/execution/detail/just.hpp>
911#include < beman/execution/detail/sender.hpp>
1012#include < beman/execution/detail/sender_in.hpp>
@@ -22,12 +24,21 @@ struct error {
2224};
2325struct non_sender {};
2426
27+ struct get_value_t : test_std::forwarding_query_t {
28+ auto operator ()(const auto & e) const noexcept -> int { return e.query (*this ); }
29+ };
30+
2531struct receiver {
2632 using receiver_concept = test_std::receiver_t ;
2733
2834 auto set_error (auto &&) && noexcept -> void {}
2935 auto set_stopped () && noexcept -> void {}
3036 auto set_value (auto &&...) && noexcept -> void {}
37+
38+ struct env {
39+ auto query (const get_value_t &) const noexcept { return 42 ; }
40+ };
41+ auto get_env () const noexcept { return env{}; }
3142};
3243
3344template <typename ... T>
@@ -214,6 +225,28 @@ auto test_then_allocator() -> void {
214225 auto state{test_std::connect (std::move (sender), memory_receiver{&resource2})};
215226 ASSERT (resource2.count == 1u );
216227}
228+
229+ auto test_then_env () -> void {
230+ {
231+ receiver r{};
232+ auto e{test_std::get_env (r)};
233+ ASSERT (e.query (get_value_t {}) == 42 );
234+ ASSERT (get_value_t {}(e) == 42 );
235+ }
236+ {
237+ auto state{test_std::connect (test_std::read_env (get_value_t {}), receiver{})};
238+ test_std::start (state);
239+ }
240+ {
241+ int value{0 };
242+ auto state{test_std::connect (test_std::then (test_std::read_env (get_value_t {}), [&value](int v) { value = v; }),
243+ receiver{})};
244+ ASSERT (value == 0 );
245+ test_std::start (state);
246+ ASSERT (value == 42 );
247+ }
248+ }
249+
217250} // namespace
218251
219252TEST (exec_then) {
@@ -230,4 +263,6 @@ TEST(exec_then) {
230263 test_then_multi_type ();
231264 test_then_value ();
232265 test_then_allocator ();
266+
267+ test_then_env ();
233268}
0 commit comments