1
1
// src/beman/execution26/tests/exec-recv-concepts.pass.cpp -*-C++-*-
2
2
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
+ #include < beman/execution26/detail/has_completions.hpp>
4
5
#include < beman/execution26/detail/valid_completion_for.hpp>
5
6
#include < beman/execution26/execution.hpp>
6
7
#include < test/execution.hpp>
@@ -15,17 +16,31 @@ namespace
15
16
template <typename ... T>
16
17
struct value_receiver
17
18
{
19
+ using receiver_concept = test_std::receiver_t ;
18
20
auto set_value (T...) && noexcept -> void {}
19
21
};
20
22
21
23
template <typename T>
22
24
struct error_receiver
23
25
{
26
+ using receiver_concept = test_std::receiver_t ;
24
27
auto set_error (T) && noexcept -> void {}
25
28
};
26
29
27
30
struct stopped_receiver
28
31
{
32
+ using receiver_concept = test_std::receiver_t ;
33
+ auto set_stopped () && noexcept -> void {}
34
+ };
35
+
36
+ struct multi_receiver
37
+ {
38
+ using receiver_concept = test_std::receiver_t ;
39
+
40
+ auto set_value (int ) && noexcept -> void {}
41
+ auto set_value (int , arg) && noexcept -> void {}
42
+ auto set_value (arg, arg) && noexcept -> void {}
43
+ auto set_error (error) && noexcept -> void {}
29
44
auto set_stopped () && noexcept -> void {}
30
45
};
31
46
@@ -62,9 +77,83 @@ namespace
62
77
static_assert (not test_detail::valid_completion_for<
63
78
test_std::set_value_t (), stopped_receiver>);
64
79
}
80
+
81
+ auto test_has_completions () -> void
82
+ {
83
+ static_assert (test_std::receiver<value_receiver<int >>);
84
+ static_assert (test_detail::has_completions<
85
+ value_receiver<int >,
86
+ test_std::completion_signatures<>
87
+ >);
88
+ static_assert (test_detail::has_completions<
89
+ value_receiver<int >,
90
+ test_std::completion_signatures<test_std::set_value_t (int )>
91
+ >);
92
+ static_assert (not test_detail::has_completions<
93
+ value_receiver<int >,
94
+ test_std::completion_signatures<test_std::set_value_t (int , int )>
95
+ >);
96
+
97
+ static_assert (test_std::receiver<error_receiver<int >>);
98
+ static_assert (test_detail::has_completions<
99
+ error_receiver<int >,
100
+ test_std::completion_signatures<test_std::set_error_t (int )>
101
+ >);
102
+ static_assert (not test_detail::has_completions<
103
+ error_receiver<int >,
104
+ test_std::completion_signatures<test_std::set_error_t (error)>
105
+ >);
106
+ static_assert (test_detail::has_completions<
107
+ error_receiver<error>,
108
+ test_std::completion_signatures<test_std::set_error_t (error)>
109
+ >);
110
+
111
+ static_assert (test_std::receiver<stopped_receiver>);
112
+ static_assert (not test_detail::has_completions<
113
+ error_receiver<error>,
114
+ test_std::completion_signatures<test_std::set_stopped_t ()>
115
+ >);
116
+ static_assert (test_detail::has_completions<
117
+ stopped_receiver,
118
+ test_std::completion_signatures<test_std::set_stopped_t ()>
119
+ >);
120
+
121
+ static_assert (test_std::receiver<stopped_receiver>);
122
+ static_assert (test_detail::has_completions<
123
+ multi_receiver,
124
+ test_std::completion_signatures<
125
+ test_std::set_value_t (int ),
126
+ test_std::set_value_t (int , arg),
127
+ test_std::set_value_t (arg, arg),
128
+ test_std::set_error_t (error),
129
+ test_std::set_stopped_t ()
130
+ >
131
+ >);
132
+ static_assert (not test_detail::has_completions<
133
+ multi_receiver,
134
+ test_std::completion_signatures<
135
+ test_std::set_value_t (int ),
136
+ test_std::set_value_t (arg, int ),
137
+ test_std::set_value_t (arg, arg),
138
+ test_std::set_error_t (error),
139
+ test_std::set_stopped_t ()
140
+ >
141
+ >);
142
+ static_assert (not test_detail::has_completions<
143
+ multi_receiver,
144
+ test_std::completion_signatures<
145
+ test_std::set_value_t (int ),
146
+ test_std::set_value_t (int , arg),
147
+ test_std::set_value_t (arg, arg),
148
+ test_std::set_error_t (int ),
149
+ test_std::set_stopped_t ()
150
+ >
151
+ >);
152
+ }
65
153
}
66
154
67
155
auto main () -> int
68
156
{
69
157
test_valid_completion_for ();
158
+ test_has_completions ();
70
159
}
0 commit comments