1
+ // src/Beman/Execution26/tests/exec-sched.pass.cpp -*-C++-*-
2
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
+
4
+ #include < Beman/Execution26/detail/scheduler.hpp>
5
+ #include < test/execution.hpp>
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ namespace
10
+ {
11
+ struct bad_env
12
+ {
13
+ auto query (test_std::get_completion_scheduler_t <test_std::set_value_t > const &) const noexcept
14
+ {
15
+ return 0 ;
16
+ }
17
+ };
18
+
19
+ template <typename Scheduler>
20
+ struct env
21
+ {
22
+ auto query (test_std::get_completion_scheduler_t <test_std::set_value_t > const &) const noexcept
23
+ {
24
+ return Scheduler{};
25
+ }
26
+ };
27
+
28
+ template <typename Env>
29
+ struct sender
30
+ {
31
+ using sender_concept = test_std::sender_t ;
32
+ auto get_env () const noexcept { return Env{}; }
33
+ };
34
+
35
+ struct no_scheduler_concept
36
+ {
37
+ auto schedule () -> sender<env<no_scheduler_concept>> { return {}; }
38
+ auto operator == (no_scheduler_concept const &) const -> bool = default ;
39
+ };
40
+
41
+ struct not_queryable
42
+ {
43
+ using scheduler_concept = test_std::scheduler_t ;
44
+ ~not_queryable () = delete ;
45
+ auto schedule () -> sender<env<not_queryable>> { return {}; }
46
+ auto operator == (not_queryable const &) const -> bool = default ;
47
+ };
48
+
49
+ struct no_schedule
50
+ {
51
+ using scheduler_concept = test_std::scheduler_t ;
52
+ auto operator == (no_schedule const &) const -> bool = default ;
53
+ };
54
+
55
+ struct not_equality_comparable
56
+ {
57
+ using scheduler_concept = test_std::scheduler_t ;
58
+ auto schedule () -> sender<env<not_equality_comparable>> { return {}; }
59
+ };
60
+
61
+ struct not_copy_constructible
62
+ {
63
+ using scheduler_concept = test_std::scheduler_t ;
64
+ not_copy_constructible (not_copy_constructible const &) = delete ;
65
+ auto schedule () -> sender<env<not_copy_constructible>> { return {}; }
66
+ auto operator == (not_copy_constructible const &) const -> bool = default ;
67
+ };
68
+
69
+ struct scheduler
70
+ {
71
+ using scheduler_concept = test_std::scheduler_t ;
72
+ auto schedule () -> sender<env<scheduler>> { return {}; }
73
+ auto operator == (scheduler const &) const -> bool = default ;
74
+ };
75
+
76
+ struct bad_completion_scheduler
77
+ {
78
+ using scheduler_concept = test_std::scheduler_t ;
79
+ auto schedule () -> sender<env<scheduler>> { return {}; }
80
+ auto operator == (bad_completion_scheduler const &) const -> bool = default ;
81
+ };
82
+ }
83
+
84
+ auto main () -> int
85
+ {
86
+ static_assert (test_std::sender<sender<env<scheduler>>>);
87
+ static_assert (std::same_as<env<scheduler>, decltype (test_std::get_env (sender<env<scheduler>>{}))>);
88
+ static_assert (std::same_as<int , decltype (test_std::get_completion_scheduler<test_std::set_value_t >(bad_env{}))>);
89
+
90
+ static_assert (not test_std::scheduler<int >);
91
+ static_assert (not test_std::scheduler<no_scheduler_concept>);
92
+ static_assert (not test_std::scheduler<not_queryable>);
93
+ static_assert (not test_std::scheduler<no_schedule>);
94
+ static_assert (not test_std::scheduler<not_equality_comparable>);
95
+ static_assert (not test_std::scheduler<not_copy_constructible>);
96
+ static_assert (not test_std::scheduler<bad_completion_scheduler>);
97
+ static_assert (test_std::scheduler<scheduler>);
98
+ }
0 commit comments