Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/beman/execution/detail/scope_token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename... Env>
auto get_completion_signatures(const Env&...) const noexcept {
return ::beman::execution::completion_signatures<>{};
}
};
Expand Down
35 changes: 35 additions & 0 deletions tests/beman/execution/exec-then.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <beman/execution/detail/completion_signatures_of_t.hpp>
#include <beman/execution/detail/connect.hpp>
#include <beman/execution/detail/forwarding_query.hpp>
#include <beman/execution/detail/read_env.hpp>
#include <beman/execution/detail/just.hpp>
#include <beman/execution/detail/sender.hpp>
#include <beman/execution/detail/sender_in.hpp>
Expand All @@ -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 <typename... T>
Expand Down Expand Up @@ -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) {
Expand All @@ -230,4 +263,6 @@ TEST(exec_then) {
test_then_multi_type();
test_then_value();
test_then_allocator();

test_then_env();
}
Loading