aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/gen_statem_SUITE.erl31
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/stdlib/test/gen_statem_SUITE.erl b/lib/stdlib/test/gen_statem_SUITE.erl
index 321573b721..268b45a0e7 100644
--- a/lib/stdlib/test/gen_statem_SUITE.erl
+++ b/lib/stdlib/test/gen_statem_SUITE.erl
@@ -44,10 +44,10 @@ all() ->
groups() ->
[{start, [],
[start1, start2, start3, start4, start5, start6, start7,
- start8, start9, start10, start11, start12]},
+ start8, start9, start10, start11, start12, next_events]},
{start_handle_event, [],
[start1, start2, start3, start4, start5, start6, start7,
- start8, start9, start10, start11, start12]},
+ start8, start9, start10, start11, start12, next_events]},
{stop, [],
[stop1, stop2, stop3, stop4, stop5, stop6, stop7, stop8, stop9, stop10]},
{stop_handle_event, [],
@@ -998,6 +998,18 @@ enter_loop(Reg1, Reg2) ->
?MODULE, [], CallbackMode, state0, [])
end.
+
+%% Test the order for multiple {next_event,T,C}
+next_events(Config) ->
+ {ok,Pid} = gen_statem:start(?MODULE, start_arg(Config, []), []),
+ ok = gen_statem:cast(Pid, next_event),
+ {state,next_events,[]} = gen_statem:call(Pid, get),
+ ok = gen_statem:stop(Pid),
+ false = erlang:is_process_alive(Pid),
+ noproc =
+ ?EXPECT_FAILURE(gen_statem:stop(Pid), Reason).
+
+
%%
%% Functionality check
%%
@@ -1178,6 +1190,11 @@ idle({call,From}, {delayed_answer,T}, Data) ->
idle({call,From}, {timeout,Time}, _Data) ->
{next_state,timeout,{From,Time},
{timeout,Time,idle}};
+idle(cast, next_event, _Data) ->
+ {next_state,next_events,[a,b,c],
+ [{next_event,internal,a},
+ {next_event,internal,b},
+ {next_event,internal,c}]};
idle(Type, Content, Data) ->
case handle_common_events(Type, Content, idle, Data) of
undefined ->
@@ -1323,6 +1340,16 @@ hiber_wakeup(Type, Content, Data) ->
Result
end.
+next_events(internal, Msg, [Msg|Msgs]) ->
+ {keep_state,Msgs};
+next_events(Type, Content, Data) ->
+ case handle_common_events(Type, Content, next_events, Data) of
+ undefined ->
+ {keep_state,Data};
+ Result ->
+ Result
+ end.
+
handle_common_events({call,From}, get, State, Data) ->
{keep_state,Data,