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,23 @@ struct error {
2224};
2325struct non_sender {};
2426
27+ struct get_value_t : test_std::forwarding_query_t {
28+ auto operator ()(auto const & e) const noexcept -> int {
29+ return e.query (*this );
30+ }
31+ };
32+
2533struct receiver {
2634 using receiver_concept = test_std::receiver_t ;
2735
2836 auto set_error (auto &&) && noexcept -> void {}
2937 auto set_stopped () && noexcept -> void {}
3038 auto set_value (auto &&...) && noexcept -> void {}
39+
40+ struct env {
41+ auto query (get_value_t const &) const noexcept { return 42 ; }
42+ };
43+ auto get_env () const noexcept { return env{}; }
3144};
3245
3346template <typename ... T>
@@ -214,6 +227,31 @@ auto test_then_allocator() -> void {
214227 auto state{test_std::connect (std::move (sender), memory_receiver{&resource2})};
215228 ASSERT (resource2.count == 1u );
216229}
230+
231+ auto test_then_env () -> void {
232+ {
233+ receiver r{};
234+ auto e{test_std::get_env (r)};
235+ ASSERT (e.query (get_value_t {}) == 42 );
236+ ASSERT (get_value_t {}(e) == 42 );
237+ }
238+ {
239+ auto state{test_std::connect (test_std::read_env (get_value_t {}), receiver{})};
240+ test_std::start (state);
241+ }
242+ {
243+ int value{0 };
244+ auto state{test_std::connect (
245+ test_std::then (test_std::read_env (get_value_t {}),
246+ [&value](int v){ value = v; }),
247+ receiver{})
248+ };
249+ ASSERT (value == 0 );
250+ test_std::start (state);
251+ ASSERT (value == 42 );
252+ }
253+ }
254+
217255} // namespace
218256
219257TEST (exec_then) {
@@ -230,4 +268,6 @@ TEST(exec_then) {
230268 test_then_multi_type ();
231269 test_then_value ();
232270 test_then_allocator ();
271+
272+ test_then_env ();
233273}
0 commit comments