diff options
author | Björn Gustavsson <[email protected]> | 2016-05-02 14:53:33 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-05-02 14:54:30 +0200 |
commit | 3b513ac820ab529a565d8caf3972982f204e8b88 (patch) | |
tree | aebe18de7b52d569a3687e1583b254c36420ec05 | |
parent | d32a045349d5f9156142aa57a932b6a270052d29 (diff) | |
download | otp-3b513ac820ab529a565d8caf3972982f204e8b88.tar.gz otp-3b513ac820ab529a565d8caf3972982f204e8b88.tar.bz2 otp-3b513ac820ab529a565d8caf3972982f204e8b88.zip |
code_SUITE: Make on_load_binary/1 clearer by using merl
-rw-r--r-- | lib/kernel/test/code_SUITE.erl | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl index 383eab94fe..a0b72925f7 100644 --- a/lib/kernel/test/code_SUITE.erl +++ b/lib/kernel/test/code_SUITE.erl @@ -1184,22 +1184,17 @@ on_load_binary(_) -> register(Master, self()), %% Construct, compile and pretty-print. - Mod = on_load_binary, + Mod = ?FUNCTION_NAME, File = atom_to_list(Mod) ++ ".erl", - Forms = [{attribute,1,file,{File,1}}, - {attribute,1,module,Mod}, - {attribute,2,export,[{ok,0}]}, - {attribute,3,on_load,{init,0}}, - {function,5,init,0, - [{clause,5,[],[], - [{op,6,'!', - {atom,6,Master}, - {tuple,6,[{atom,6,Mod},{call,6,{atom,6,self},[]}]}}, - {'receive',7,[{clause,8,[{atom,8,go}],[],[{atom,8,ok}]}]}]}]}, - {function,11,ok,0,[{clause,11,[],[],[{atom,11,true}]}]}], - Forms1 = erl_parse:new_anno(Forms), - {ok,Mod,Bin} = compile:forms(Forms1, [report]), - [io:put_chars(erl_pp:form(F)) || F <- Forms1], + Tree = ?Q(["-module('@Mod@').\n", + "-export([ok/0]).\n", + "-on_load({init,0}).\n", + "init() ->\n", + " '@Master@' ! {on_load_binary,self()},\n", + " receive go -> ok end.\n", + "ok() -> true.\n"]), + {ok,Mod,Bin} = merl:compile(Tree), + merl:print(Tree), {Pid1,Ref1} = spawn_monitor(fun() -> code:load_binary(Mod, File, Bin), |