diff options
-rw-r--r-- | lib/stdlib/doc/src/gen_statem.xml | 4 | ||||
-rw-r--r-- | lib/stdlib/src/gen_statem.erl | 4 | ||||
-rw-r--r-- | lib/stdlib/test/gen_statem_SUITE.erl | 15 |
3 files changed, 16 insertions, 7 deletions
diff --git a/lib/stdlib/doc/src/gen_statem.xml b/lib/stdlib/doc/src/gen_statem.xml index 04b80d29ac..01be3099c1 100644 --- a/lib/stdlib/doc/src/gen_statem.xml +++ b/lib/stdlib/doc/src/gen_statem.xml @@ -241,7 +241,7 @@ stop() -> terminate(_Reason, _State, _Data) -> void. code_change(_Vsn, State, Data, _Extra) -> - {ok,{State,Data}}. + {ok,State,Data}. init([]) -> %% Set the callback mode and initial state + data. %% Data is used only as a counter. @@ -1359,7 +1359,7 @@ ok <v> Vsn = term()</v> <v>OldState = NewState = term()</v> <v>Extra = term()</v> - <v>Result = {ok,{NewState,NewData}} | Reason</v> + <v>Result = {ok,NewState,NewData} | Reason</v> <v> OldState = NewState = <seealso marker="#type-state">state()</seealso> diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl index 17d361efc2..cc09efc140 100644 --- a/lib/stdlib/src/gen_statem.erl +++ b/lib/stdlib/src/gen_statem.erl @@ -200,7 +200,7 @@ OldState :: state(), OldData :: data(), Extra :: term()) -> - {ok, {NewState :: state(), NewData :: data()}}. + {ok, NewState :: state(), NewData :: data()}. %% Format the callback module state in some sensible that is %% often condensed way. For StatusOption =:= 'normal' the perferred @@ -619,7 +619,7 @@ system_code_change( Result -> Result end of - {ok,{NewState,NewData}} -> + {ok,NewState,NewData} -> {ok, S#{ state := NewState, diff --git a/lib/stdlib/test/gen_statem_SUITE.erl b/lib/stdlib/test/gen_statem_SUITE.erl index f605f0c7b9..573a64bbb7 100644 --- a/lib/stdlib/test/gen_statem_SUITE.erl +++ b/lib/stdlib/test/gen_statem_SUITE.erl @@ -55,7 +55,7 @@ groups() -> {abnormal, [], [abnormal1, abnormal2]}, {abnormal_handle_event, [], [abnormal1, abnormal2]}, {sys, [], - [sys1, + [sys1, code_change, call_format_status, error_format_status, terminate_crash_format, get_state, replace_state]}, @@ -633,6 +633,15 @@ sys1(Config) -> sys:resume(Pid), stop_it(Pid). +code_change(Config) -> + {ok,Pid} = gen_statem:start(?MODULE, start_arg(Config, []), []), + {idle,data} = sys:get_state(Pid), + sys:suspend(Pid), + sys:change_code(Pid, ?MODULE, old_vsn, extra), + sys:resume(Pid), + {idle,{old_vsn,data,extra}} = sys:get_state(Pid), + stop_it(Pid). + call_format_status(Config) -> {ok,Pid} = gen_statem:start(?MODULE, start_arg(Config, []), []), Status = sys:get_status(Pid), @@ -1550,8 +1559,8 @@ wrap_result(Result) -> -code_change(_OldVsn, State, Data, _Extra) -> - {ok,State,Data}. +code_change(OldVsn, State, Data, Extra) -> + {ok,State,{OldVsn,Data,Extra}}. format_status(terminate, [_Pdict,State,Data]) -> {formatted,State,Data}; |