Skip to content

Commit

Permalink
Add (failing) unit test for boost-ext#562
Browse files Browse the repository at this point in the history
While events triggered via `process()` from a sub state are correctly handled
in the parent state, events triggered via `back::process` are not.
Also, the event triggered via `back::process` is not known to the parent machine,
causing a compiler error: `no matching function for call to ‘get_id<int, e2>(...)`
  • Loading branch information
rhaschke committed Mar 18, 2023
1 parent 5a323c5 commit 4be9dd6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/ft/actions_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,41 @@ test process_event_from_substate = [] {
expect(1 == c_.a_called);
};

test back_process_event_from_substate = [] {
struct sub {
auto operator()() const noexcept {
using namespace sml;
auto back_process = [](back::process<e2> process) { process(e2{}); };
// clang-format off
return make_transition_table(
* s1 + event<e1> / (back_process, process(e3{}))
, X + event<e2> = X // BUG: event not known otherwise
);
// clang-format on
}
};

struct c {
auto operator()() noexcept {
using namespace sml;
// clang-format off
return make_transition_table(
* state<sub> + event<e2> / [this] { received += "e2|"; }
, state<sub> + event<e3> / [this] { received += "e3|"; }
);
// clang-format on
}

std::string received;
};

sml::sm<c, sml::process_queue<std::queue>> sm;
sm.process_event(e1{});

const c& c_ = sm;
expect(c_.received == "e2|e3|"); // BUG: only e3 is received
};

test queue_process_events = [] {
struct c {
std::vector<int> calls;
Expand Down

0 comments on commit 4be9dd6

Please sign in to comment.