aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2016-03-01 08:31:58 +0100
committerRaimo Niskanen <[email protected]>2016-03-02 08:21:56 +0100
commit9dfb4e6cf574870ac6e6a5a2a507c989c64e7525 (patch)
tree04fca4bcdfefa8ea4b960b07b324f266baba600d /lib
parenta0c69303c971b4c65e5cd450dbe7de680aa58181 (diff)
downloadotp-9dfb4e6cf574870ac6e6a5a2a507c989c64e7525.tar.gz
otp-9dfb4e6cf574870ac6e6a5a2a507c989c64e7525.tar.bz2
otp-9dfb4e6cf574870ac6e6a5a2a507c989c64e7525.zip
Change code_change/4 to {ok,State,Data}
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/doc/src/gen_statem.xml4
-rw-r--r--lib/stdlib/src/gen_statem.erl4
-rw-r--r--lib/stdlib/test/gen_statem_SUITE.erl15
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>&nbsp;&nbsp;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};