Commit 4cdba90f authored by Dominik Charousset's avatar Dominik Charousset

made spawn unit test more verbose

parent e5c88dfb
...@@ -484,6 +484,7 @@ int main() { ...@@ -484,6 +484,7 @@ int main() {
await_all_others_done(); await_all_others_done();
CPPA_IF_VERBOSE(cout << "ok" << endl); CPPA_IF_VERBOSE(cout << "ok" << endl);
CPPA_IF_VERBOSE(cout << "test sync send with factory spawned actor ... " << flush);
auto sync_testee_factory = factory::event_based( auto sync_testee_factory = factory::event_based(
[&]() { [&]() {
self->become ( self->become (
...@@ -510,25 +511,39 @@ int main() { ...@@ -510,25 +511,39 @@ int main() {
); );
} }
); );
CPPA_CHECK(true);
auto sync_testee = sync_testee_factory.spawn(); auto sync_testee = sync_testee_factory.spawn();
self->monitor(sync_testee);
send(sync_testee, "hi"); send(sync_testee, "hi");
receive ( receive (
on("whassup?") >> []() { on("whassup?") >> [&] {
CPPA_CHECK(true);
// this is NOT a reply, it's just an asynchronous message // this is NOT a reply, it's just an asynchronous message
send(self->last_sender(), "a lot!"); send(self->last_sender(), "a lot!");
reply("nothing"); reply("nothing");
} }
); );
receive ( receive (
on("goodbye!") >> []() { } on("goodbye!") >> [&] {
CPPA_CHECK(true);
}
);
CPPA_CHECK(true);
receive (
on(atom("DOWN"), exit_reason::normal) >> [&] {
CPPA_CHECK(self->last_sender() == sync_testee);
}
); );
await_all_others_done(); await_all_others_done();
CPPA_IF_VERBOSE(cout << "ok" << endl);
receive_response(sync_send(sync_testee, "!?")) ( receive_response(sync_send(sync_testee, "!?")) (
others() >> [&]() { others() >> [&]() {
CPPA_ERROR("'sync_testee' still alive?"); CPPA_ERROR("'sync_testee' still alive?");
}, },
after(chrono::milliseconds(5)) >> []() { } after(chrono::milliseconds(5)) >> [&] {
CPPA_CHECK(true);
}
); );
auto inflater = factory::event_based( auto inflater = factory::event_based(
...@@ -547,10 +562,12 @@ int main() { ...@@ -547,10 +562,12 @@ int main() {
auto bob = inflater.spawn("Bob", joe); auto bob = inflater.spawn("Bob", joe);
send(bob, 1, "hello actor"); send(bob, 1, "hello actor");
receive ( receive (
on(4, "hello actor") >> []() { on(4, "hello actor") >> [&] {
CPPA_CHECK(true);
// done // done
}, },
others() >> [] { others() >> [&] {
CPPA_ERROR("unexpected result");
cerr << "unexpected: " << to_string(self->last_dequeued()) << endl; cerr << "unexpected: " << to_string(self->last_dequeued()) << endl;
} }
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment