22constexpr struct PropA :
public stdexec::__query<PropA> {
25constexpr struct PropB :
public stdexec::__query<PropB> {
29 :
public stdexec::__query<FwdPropC>
30 , stdexec::forwarding_query_t {
31 using stdexec::__query<
FwdPropC>::operator();
35 :
public stdexec::__query<FwdPropD>
36 , stdexec::forwarding_query_t {
37 using stdexec::__query<
FwdPropD>::operator();
41TEST(forwarding, queryable) {
43 auto env = stdexec::env{
44 stdexec::prop{
prop_a, 123},
48 static_assert(stdexec::__queryable_with<
decltype(env),
PropA>);
49 static_assert(stdexec::__queryable_with<
decltype(env),
FwdPropC>);
51 auto fwd_env = stdexec::__fwd_env(stdexec::__fwd_env(env));
56 stdexec::__env::__fwd<
57 stdexec::env<stdexec::prop<Tests::Impl::PropA, int>, stdexec::prop<Tests::Impl::FwdPropC, int>> &
61 static_assert(!stdexec::__queryable_with<
decltype(fwd_env),
PropA>);
62 static_assert(stdexec::__queryable_with<
decltype(fwd_env),
FwdPropC>);
69TEST(upsert, set_prop_in_empty_env) {
72 static_assert(std::same_as<
decltype(new_env),
const stdexec::env<stdexec::prop<PropA, int>, stdexec::env<>>>);
74 constexpr auto value =
prop_a(new_env);
76 static_assert(value == 42);
80TEST(upsert, replace_prop_in_single_prop) {
82 auto env = stdexec::prop{
prop_a, 123};
86 auto value =
prop_a(new_env);
88 static_assert(std::same_as<
decltype(new_env), stdexec::prop<Tests::Impl::PropA, double>>);
95TEST(upsert, replace_prop_in_env_with_single_prop) {
97 auto env = stdexec::env{
98 stdexec::prop{
prop_a, 123},
103 auto value =
prop_a(new_env);
105 static_assert(std::same_as<
decltype(new_env), stdexec::env<stdexec::prop<Tests::Impl::PropA, double>>>);
112TEST(upsert, add_prop_to_another_prop) {
114 auto env = stdexec::prop{
prop_b, 123};
118 static_assert(std::same_as<
120 stdexec::env<stdexec::prop<Tests::Impl::PropA, double>, stdexec::prop<Tests::Impl::PropB, int>>
123 auto value =
prop_a(new_env);
130TEST(upsert, replace_prop_in_env_with_two_props) {
132 auto env = stdexec::env{
133 stdexec::prop{
prop_b, 123},
134 stdexec::prop{
prop_a, 123},
139 static_assert(std::same_as<
141 stdexec::env<stdexec::prop<Tests::Impl::PropB, int>, stdexec::prop<Tests::Impl::PropA, double>>
144 auto value =
prop_a(new_env);
151TEST(upsert, replace_prop_in_forwarding_env_with_two_props) {
153 auto env = stdexec::__fwd_env(
164 stdexec::__env::__fwd<
165 stdexec::env<stdexec::prop<Tests::Impl::FwdPropD, int>, stdexec::prop<Tests::Impl::FwdPropC, double>>
180TEST(upsert, add_prop_to_env_with_multiple_props) {
182 auto env = stdexec::env{
183 stdexec::prop{
prop_b, 123},
193 stdexec::prop<Tests::Impl::PropA, double>,
194 stdexec::env<stdexec::prop<Tests::Impl::PropB, int>, stdexec::prop<Tests::Impl::FwdPropC, int>>
198 return prop_a(new_env) == 42.;
203TEST(upsert, add_fwd_prop_to_forwarding_env) {
205 auto env = stdexec::__fwd_env(
212 static_assert(std::same_as<
215 stdexec::prop<Tests::Impl::FwdPropC, double>,
216 stdexec::__env::__fwd<stdexec::env<stdexec::prop<Tests::Impl::FwdPropD, int>>>
225TEST(upsert, upsert_with_move_only) {
227 auto env = stdexec::prop{
prop_a, 123};
229 struct MoveOnly :
public stdexec::__move_only {
231 constexpr explicit MoveOnly(
int value_)
238 static_assert(std::same_as<
240 stdexec::env<stdexec::prop<Tests::Impl::PropB, MoveOnly>, stdexec::prop<Tests::Impl::PropA, int>>
243 return prop_b(new_env).value == 42;
252TEST(upsert, chain_multiple_upserts) {
254 auto env = stdexec::env{
255 stdexec::prop{
prop_a, 1.},
263 static_assert(std::same_as<
decltype(new_env), stdexec::env<stdexec::prop<Tests::Impl::PropA, double>>>);
265 return prop_a(new_env) == 4.;
275TEST(upsert, ref_join_upsert) {
276 double fwd_prop_c_value = 42.;
278 auto env = stdexec::prop{
fwd_prop_c, std::ref(fwd_prop_c_value)};
279 auto env_ref_join = stdexec::__env::__join(stdexec::prop{
prop_b, 2}, stdexec::__fwd_env(env));
282 static_assert(std::same_as<
283 decltype(env_ref_join),
285 stdexec::prop<Tests::Impl::PropB, int>,
286 stdexec::__env::__fwd<stdexec::prop<Tests::Impl::FwdPropC, double &> &>
290 static_assert(std::same_as<
291 std::remove_const_t<
decltype(env_ref_join_upsert)>,
293 stdexec::prop<Tests::Impl::PropB, double>,
294 stdexec::__env::__fwd<stdexec::prop<Tests::Impl::FwdPropC, double &> &>
298 ASSERT_EQ(
prop_b(env_ref_join_upsert), 3.);
299 ASSERT_EQ(
fwd_prop_c(env_ref_join_upsert), 42.);
301 fwd_prop_c_value = 666.;
302 ASSERT_EQ(
fwd_prop_c(env_ref_join_upsert), 666.);
305 ASSERT_EQ(
fwd_prop_c(env_ref_join_upsert), 3.14);