Skip to content

Commit 30bfa8f

Browse files
committed
added missing token tests
1 parent 7227374 commit 30bfa8f

File tree

1 file changed

+45
-31
lines changed

1 file changed

+45
-31
lines changed

tests/beman/execution/exec-scope-simple-counting.test.cpp

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,59 +18,54 @@ auto general() -> void {
1818
using scope = test_std::simple_counting_scope;
1919
using token = scope::token;
2020

21-
//-dk:TODO static_assert(requires(token const& tok){ { tok.wrap(test_std::just(10)) } noexcept ->
22-
//std::same_as<decltype(test_std::just(1))>; }); -dk:TODO static_assert(requires(token const& tok){ {
23-
//tok.try_associate() } noexcept -> std::same_as<bool>; });
24-
static_assert(requires(const token& tok) { tok.try_associate(); });
25-
//-dk:TODO static_assert(requires(token const& tok){ { tok.disassociate() } noexcept; });
21+
//static_assert(requires(token const& tok){ { tok.wrap(test_std::just(10)) } noexcept; });
22+
static_assert(requires(token const& tok){ { tok.try_associate() } noexcept -> std::same_as<bool>; });
23+
static_assert(requires(token const& tok){ tok.try_associate(); });
24+
static_assert(requires(token const& tok){ { tok.disassociate() } noexcept; });
2625

2726
static_assert(noexcept(scope{}));
28-
static_assert(!std::is_move_constructible_v<scope>);
29-
static_assert(!std::is_copy_constructible_v<scope>);
30-
static_assert(requires(scope sc) {
31-
{ sc.get_token() } noexcept -> std::same_as<token>;
32-
});
33-
static_assert(requires(scope sc) {
34-
{ sc.close() } noexcept -> std::same_as<void>;
35-
});
36-
static_assert(requires(scope sc) {
37-
{ sc.join() } noexcept;
38-
});
27+
static_assert(! std::is_move_constructible_v<scope>);
28+
static_assert(! std::is_copy_constructible_v<scope>);
29+
static_assert(requires(scope sc){ { sc.get_token() } noexcept -> std::same_as<token>; });
30+
static_assert(requires(scope sc){ { sc.close() } noexcept -> std::same_as<void>; });
31+
static_assert(requires(scope sc){ { sc.join() } noexcept; });
3932
}
4033

4134
struct join_receiver {
4235
using receiver_concept = test_std::receiver_t;
4336

4437
struct env {
45-
auto query(const test_std::get_scheduler_t&) const noexcept -> test::inline_scheduler { return {}; }
38+
auto query(test_std::get_scheduler_t const&) const noexcept -> test::inline_scheduler {
39+
return {};
40+
}
4641
};
4742

4843
bool& called;
49-
auto set_value() && noexcept { this->called = true; }
50-
auto get_env() const noexcept -> env { return {}; }
44+
auto set_value() && noexcept { this->called = true; }
45+
auto get_env() const noexcept -> env { return {}; }
5146
};
5247

5348
auto ctor() -> void {
5449
{
5550
test_std::simple_counting_scope scope;
5651
}
57-
test::death([] {
52+
test::death([]{
5853
test_std::simple_counting_scope scope;
5954
scope.get_token().try_associate();
6055
});
61-
test::death([] {
56+
test::death([]{
6257
test_std::simple_counting_scope scope;
6358
scope.get_token().try_associate();
6459
bool called{false};
6560
auto state(test_std::connect(scope.join(), join_receiver{called}));
6661
test_std::start(state);
6762
});
68-
test::death([] {
63+
test::death([]{
6964
test_std::simple_counting_scope scope;
7065
scope.get_token().try_associate();
7166
scope.close();
7267
});
73-
test::death([] {
68+
test::death([]{
7469
test_std::simple_counting_scope scope;
7570
scope.get_token().try_associate();
7671
bool called{false};
@@ -91,15 +86,15 @@ auto ctor() -> void {
9186
auto mem() -> void {
9287
{
9388

94-
test_std::simple_counting_scope scope;
95-
test_std::simple_counting_scope::token token{scope.get_token()};
89+
test_std::simple_counting_scope scope;
90+
test_std::simple_counting_scope::token token{scope.get_token()};
9691

97-
ASSERT(true == token.try_associate());
98-
token.disassociate();
99-
scope.close();
100-
ASSERT(false == token.try_associate());
92+
ASSERT(true == token.try_associate());
93+
token.disassociate();
94+
scope.close();
95+
ASSERT(false == token.try_associate());
10196

102-
test_std::sync_wait(scope.join());
97+
test_std::sync_wait(scope.join());
10398
}
10499
{
105100
test_std::simple_counting_scope scope;
@@ -115,11 +110,30 @@ auto mem() -> void {
115110
ASSERT(called == true);
116111
}
117112
}
113+
auto token() -> void {
114+
test_std::simple_counting_scope scope;
115+
auto const tok{scope.get_token()};
116+
auto sndr{tok.wrap(test_std::just(10))};
117+
static_assert(std::same_as<decltype(sndr), decltype(test_std::just(10))>);
118+
119+
ASSERT(true == tok.try_associate());
120+
bool called{false};
121+
auto state(test_std::connect(scope.join(), join_receiver(called)));
122+
test_std::start(state);
123+
ASSERT(false == called);
124+
scope.close();
125+
ASSERT(false == called);
126+
ASSERT(false == tok.try_associate());
127+
ASSERT(false == called);
128+
tok.disassociate();
129+
ASSERT(true == called);
130+
}
118131

119-
} // namespace
132+
}
120133

121134
TEST(exec_scope_simple_counting) {
122135
general();
123136
ctor();
124137
mem();
138+
token();
125139
}

0 commit comments

Comments
 (0)