Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/boost/sml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3224,13 +3224,13 @@ struct transition_sa<state<S2>, A> : transition<state<internal>, state<S2>, fron
}
};
template <class S2, class E>
struct transition<state<S2>, front::event<E>> {
struct transition<state<S2>, front::event<E>> : transition<state<internal>, state<S2>, front::event<E>, always, none> {
constexpr transition(const state<S2> &, const front::event<E> &)
: transition<state<internal>, state<S2>, front::event<E>, always, none>{always{}, none{}} {}
template <class T>
constexpr auto operator=(const T &) const {
return transition<T, state<S2>, front::event<E>, always, none>{always{}, none{}};
}
const state<S2> &s2;
front::event<E> e;
};
template <class E, class G>
struct transition_eg<front::event<E>, G> {
Expand Down
5 changes: 5 additions & 0 deletions test/ft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/issue_552_sub_sm_dep_identity.cpp)
add_test(test_issue_552_sub_sm_dep_identity test_issue_552_sub_sm_dep_identity)
endif()

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/issue_317_bare_internal_transition.cpp)
add_executable(test_issue_317_bare_internal_transition issue_317_bare_internal_transition.cpp)
add_test(test_issue_317_bare_internal_transition test_issue_317_bare_internal_transition)
endif()

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/issue_473_defer_anonymous.cpp)
add_executable(test_issue_473_defer_anonymous issue_473_defer_anonymous.cpp)
add_test(test_issue_473_defer_anonymous test_issue_473_defer_anonymous)
Expand Down
65 changes: 65 additions & 0 deletions test/ft/issue_317_bare_internal_transition.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// cppcheck-suppress missingIncludeSystem
#include <boost/sml.hpp>

namespace sml = boost::sml;

namespace {
struct ignored {};
struct leave {};
struct come_back {};

struct counters {
int entries = 0;
int exits = 0;
};
struct count_entry {
void operator()(counters &c) const { ++c.entries; }
};
struct count_exit {
void operator()(counters &c) const { ++c.exits; }
};

const auto idle = sml::state<class idle_317>;
const auto busy = sml::state<class busy_317>;
} // namespace

test bare_row_on_initial_state_consumes_event_without_exit_or_entry = [] {
struct c {
auto operator()() const noexcept {
using namespace sml;
return make_transition_table(*idle + event<ignored>, idle + event<leave> = busy, busy + event<come_back> = idle,
idle + sml::on_entry<_> / count_entry{}, idle + sml::on_exit<_> / count_exit{});
}
};
counters calls{};
sml::sm<c> sm{calls};
expect(1 == calls.entries);

expect(sm.process_event(ignored{}));
expect(sm.is(idle));
expect(1 == calls.entries);
expect(0 == calls.exits);

expect(!sm.process_event(come_back{}));
expect(sm.is(idle));
};

test bare_row_on_non_initial_state_consumes_event_without_exit_or_entry = [] {
struct c {
auto operator()() const noexcept {
using namespace sml;
return make_transition_table(*idle + event<leave> = busy, busy + event<ignored>, busy + sml::on_entry<_> / count_entry{},
busy + sml::on_exit<_> / count_exit{});
}
};
counters calls{};
sml::sm<c> sm{calls};
expect(sm.process_event(leave{}));
expect(sm.is(busy));
expect(1 == calls.entries);

expect(sm.process_event(ignored{}));
expect(sm.is(busy));
expect(1 == calls.entries);
expect(0 == calls.exits);
};
Loading