-
Notifications
You must be signed in to change notification settings - Fork 201
Closed
Description
Anonymous transitions in a nested state are not being executed unless on_entry event is declared in transition table.
The following test, which is a slightly modified version of this line 112, fails if we remove on_entry action in the sub_sm
test subsequent_anonymous_transitions_composite = [] {
using V = std::string;
V calls{};
using namespace sml;
struct sub_sub_sm {
auto operator()() noexcept {
// clang-format off
return make_transition_table(
*idle / [] (V& v) { v+="ss1|"; } = s1
,s1 / [] (V& v) { v+="ss2|"; } = s2
,s2 / [] (V& v) { v+="ss3|"; } = X
);
// clang-format on
}
};
struct sub_sm {
auto operator()() noexcept {
// clang-format off
return make_transition_table(
*idle / [] (V& v) { v+="s1|"; } = s1
,s1 / [] (V& v) { v+="s2|"; } = s2
,s2 / [] (V& v) { v+="s3|"; } = state<sub_sub_sm>
,state<sub_sub_sm> / [] (V& v) { v+="s4|"; } = X
// ,state<sub_sub_sm> + sml::on_entry<_>/[]{} // REMOVING THIS LINE CAUSES THE ANONYMOUS TRANSITIONS IN THE NESTED STATE MACHINE TO NOT EXECUTE
);
// clang-format on
}
};
struct composite_sm {
auto operator()() noexcept {
// clang-format off
return make_transition_table(
*idle / [] (V& v) { v+="11|"; } = s1
,s1 / [] (V& v) { v+="12|"; } = state<sub_sm>
,state<sub_sm> / [] (V& v) { v+="13|"; } = s2
,s2 / [] (V& v) { v+="14|"; } = s3
);
// clang-format on
}
};
sml::sm<composite_sm> sm{calls};
expect(sm.is<decltype(state<sub_sm>)>(X));
expect(sm.is(s3));
std::string expected("11|12|s1|s2|s3|ss1|ss2|ss3|s4|13|14|");
expect(calls == expected);
std::cout << "call order: " << calls << std::endl;
};
Test output:
result:
call order: 11|12|
expected:
call order: 11|12|s1|s2|s3|ss1|ss2|ss3|s4|13|14|
Specifications
- Version: 1.1.11
- Platform: Ubuntu 22.04
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels