From fe070a32f9f685ef4df1a5123e9328bb82e3947a Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Mon, 27 Oct 2014 13:46:57 +0100 Subject: emulator: Use module erl_anno --- erts/emulator/test/op_SUITE.erl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index ef4689b850..26f6837f19 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2011. All Rights Reserved. +%% Copyright Ericsson AB 1999-2015. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -273,7 +273,8 @@ run_test_module(Cases, GuardsOk) -> ?line Bbts = lists:foldr(fun internal_bif/2, [Ok], Es), ?line Fun3 = make_function(bif_tests, Bbts), ?line Id = {function,1,id,1,[{clause,1,[{var,1,'I'}],[],[{var,1,'I'}]}]}, - ?line Module = make_module(op_tests, [Fun1,Fun2,Fun3,Id]), + Module0 = make_module(op_tests, [Fun1,Fun2,Fun3,Id]), + Module = erl_parse:new_anno(Module0), ?line lists:foreach(fun(F) -> io:put_chars([erl_pp:form(F),"\n"]) end, Module), %% Compile, load, and run the generated module. @@ -365,13 +366,16 @@ make_module(Name, Funcs) -> make_function(Name, Body) -> {function,1,Name,0,[{clause,1,[],[],Body}]}. -eval(E) -> +eval(E0) -> + E = erl_parse:new_anno(E0), ?line case catch erl_eval:exprs(E, []) of {'EXIT',Reason} -> {'EXIT',Reason}; {value,Val,_Bs} -> Val end. -unvalue(V) -> erl_parse:abstract(V). +unvalue(V) -> + Abstr = erl_parse:abstract(V), + erl_parse:anno_to_term(Abstr). value({nil,_}) -> []; value({integer,_,X}) -> X; -- cgit v1.2.3 From 738c34d4bb8f1a3811acd00af8c6c12107f8315b Mon Sep 17 00:00:00 2001 From: Bruce Yinhe Date: Thu, 18 Jun 2015 11:31:02 +0200 Subject: Change license text to APLv2 --- erts/emulator/test/op_SUITE.erl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index 26f6837f19..6eda78a57b 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -3,16 +3,17 @@ %% %% Copyright Ericsson AB 1999-2015. All Rights Reserved. %% -%% The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved online at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. %% %% %CopyrightEnd% %% -- cgit v1.2.3 From 71ddd8c1aba0478fe5aa07bdc8f9e6a86515bb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 9 Dec 2015 15:04:28 +0100 Subject: Emulator test suite: Replace use of 'random' with 'rand' --- erts/emulator/test/op_SUITE.erl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index 6eda78a57b..65a5a4c505 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -97,10 +97,11 @@ relop_simple(Config) when is_list(Config) -> lists:foreach(fun({A,B}) -> relop_simple_do(A,B) end, Combos), - repeat(fun() -> Size = random:uniform(100), - Rnd1 = make_rand_term(Size), - {Rnd2,0} = clone_and_mutate(Rnd1, random:uniform(Size)), - relop_simple_do(Rnd1,Rnd2) + repeat(fun() -> + Size = rand:uniform(100), + Rnd1 = make_rand_term(Size), + {Rnd2,0} = clone_and_mutate(Rnd1, rand:uniform(Size)), + relop_simple_do(Rnd1,Rnd2) end, 1000), ok. @@ -158,7 +159,7 @@ cmp_emu(A,B) -> make_rand_term(1) -> make_rand_term_single(); make_rand_term(Arity) -> - case random:uniform(3) of + case rand:uniform(3) of 1 -> make_rand_list(Arity); 2 -> @@ -169,17 +170,17 @@ make_rand_term(Arity) -> end. make_rand_term_single() -> - Range = 1 bsl random:uniform(200), - case random:uniform(12) of + Range = 1 bsl rand:uniform(200), + case rand:uniform(12) of 1 -> random; 2 -> uniform; - 3 -> random:uniform(Range) - (Range div 2); - 4 -> Range * (random:uniform() - 0.5); + 3 -> rand:uniform(Range) - (Range div 2); + 4 -> Range * (rand:uniform() - 0.5); 5 -> 0; 6 -> 0.0; 7 -> make_ref(); 8 -> self(); - 9 -> term_to_binary(random:uniform(Range)); + 9 -> term_to_binary(rand:uniform(Range)); 10 -> fun(X) -> X*Range end; 11 -> fun(X) -> X/Range end; 12 -> [] @@ -188,7 +189,7 @@ make_rand_term_single() -> make_rand_term_rand_size(1) -> {make_rand_term(1), 0}; make_rand_term_rand_size(MaxArity) -> - Arity = random:uniform(MaxArity-1), + Arity = rand:uniform(MaxArity-1), {make_rand_term(Arity), MaxArity-Arity}. make_rand_list(0) -> []; -- cgit v1.2.3 From 03fcb7dabf8861e60ffab4121a909b347bccfec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 15 Feb 2016 15:33:12 +0100 Subject: Eliminate use of test_server.hrl and test_server_line.hrl As a first step to removing the test_server application as as its own separate application, change the inclusion of test_server.hrl to an inclusion of ct.hrl and remove the inclusion of test_server_line.hrl. --- erts/emulator/test/op_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index 65a5a4c505..4e15b27231 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -20,7 +20,7 @@ -module(op_SUITE). --include_lib("test_server/include/test_server.hrl"). +-include_lib("common_test/include/ct.hrl"). -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, -- cgit v1.2.3 From c062dfc485ad0d51d648701950f77ef8f51d4f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Tue, 8 Mar 2016 19:35:31 +0100 Subject: Modernize use of timetraps --- erts/emulator/test/op_SUITE.erl | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index 4e15b27231..9948c13ce2 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -22,44 +22,20 @@ -include_lib("common_test/include/ct.hrl"). --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2, - init_per_testcase/2,end_per_testcase/2, +-export([all/0, suite/0, bsl_bsr/1,logical/1,t_not/1,relop_simple/1,relop/1,complex_relop/1]). -export([]). -import(lists, [foldl/3,flatmap/2]). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap, {minutes, 3}}]. all() -> [bsl_bsr, logical, t_not, relop_simple, relop, complex_relop]. -groups() -> - []. - -init_per_suite(Config) -> - Config. - -end_per_suite(_Config) -> - ok. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - -init_per_testcase(Case, Config) when is_atom(Case), is_list(Config) -> - Dog=?t:timetrap(?t:minutes(3)), - [{watchdog, Dog}|Config]. - -end_per_testcase(_Case, Config) -> - Dog=?config(watchdog, Config), - ?t:timetrap_cancel(Dog). - %% Test the bsl and bsr operators. bsl_bsr(Config) when is_list(Config) -> Vs = [unvalue(V) || V <- [-16#8000009-2,-1,0,1,2,73,16#8000000,bad,[]]], -- cgit v1.2.3 From 9b6b82abfaae479849902ba60c4c54a526840a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Tue, 8 Mar 2016 21:01:40 +0100 Subject: Eliminate use of test_server:fail/0,1 --- erts/emulator/test/op_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index 9948c13ce2..a12066f9fa 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -296,7 +296,7 @@ run_function(Mod, Name) -> case catch Mod:Name() of {'EXIT',Reason} -> io:format("~p", [get(last)]), - ?t:fail({'EXIT',Reason}); + ct:fail({'EXIT',Reason}); _Other -> ok end. -- cgit v1.2.3 From 2b73a44c5b720a348fe8001cf024065c14e87651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Wed, 9 Mar 2016 18:58:47 +0100 Subject: Replace ?t with test_server The macro ?t is deprecated. Replace its use with 'test_server'. --- erts/emulator/test/op_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index a12066f9fa..70e0c57827 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -257,7 +257,7 @@ run_test_module(Cases, GuardsOk) -> %% Compile, load, and run the generated module. - Native = case ?t:is_native(?MODULE) of + Native = case test_server:is_native(?MODULE) of true -> [native]; false -> [] end, -- cgit v1.2.3 From 33b0c5f37b7b5baa42d4999d1a2be32470fb1bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 10 Mar 2016 17:59:23 +0100 Subject: Eliminate use of doc and suite clauses Those clause are obsolete and never used by common_test. --- erts/emulator/test/op_SUITE.erl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index 70e0c57827..e9127616a6 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -43,7 +43,7 @@ bsl_bsr(Config) when is_list(Config) -> ?line run_test_module(Cases, false), {comment,integer_to_list(length(Cases)) ++ " cases"}. -logical(doc) -> "Test the logical operators and internal BIFs."; +%% Test the logical operators and internal BIFs. logical(Config) when is_list(Config) -> Vs0 = [true,false,bad], Vs = [unvalue(V) || V <- Vs0], @@ -51,13 +51,13 @@ logical(Config) when is_list(Config) -> ?line run_test_module(Cases, false), {comment,integer_to_list(length(Cases)) ++ " cases"}. -t_not(doc) -> "Test the not operator and internal BIFs."; +%% Test the not operator and internal BIFs. t_not(Config) when is_list(Config) -> ?line Cases = [{'not',unvalue(V)} || V <- [true,false,42,bad]], ?line run_test_module(Cases, false), {comment,integer_to_list(length(Cases)) ++ " cases"}. -relop_simple(doc) -> "Test that simlpe relations between relation operators hold."; +%% Test that simlpe relations between relation operators hold. relop_simple(Config) when is_list(Config) -> Big1 = 19738924729729787487784874, Big2 = 38374938373887374983978484, @@ -207,7 +207,7 @@ purify_list([H|T], Acc) -> purify_list(T, [H|Acc]); purify_list(Other, Acc) -> [Other|Acc]. -relop(doc) -> "Test the relational operators and internal BIFs on literals."; +%% Test the relational operators and internal BIFs on literals. relop(Config) when is_list(Config) -> Big1 = -38374938373887374983978484, Big2 = 19738924729729787487784874, @@ -218,8 +218,7 @@ relop(Config) when is_list(Config) -> Ops = ['==', '/=', '=:=', '=/=', '<', '=<', '>', '>='], ?line binop(Ops, Vs). -complex_relop(doc) -> - "Test the relational operators and internal BIFs on lists and tuples."; +%% Test the relational operators and internal BIFs on lists and tuples. complex_relop(Config) when is_list(Config) -> Big = 99678557475484872464269855544643333, Float = float(Big), -- cgit v1.2.3 From 20ae6a9238d3fd09587bd3f4179a8ae25f1e3aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 10 Mar 2016 18:19:16 +0100 Subject: Remove ?line macros --- erts/emulator/test/op_SUITE.erl | 236 ++++++++++++++++++++-------------------- 1 file changed, 118 insertions(+), 118 deletions(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index e9127616a6..562cf1c92d 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -23,7 +23,7 @@ -include_lib("common_test/include/ct.hrl"). -export([all/0, suite/0, - bsl_bsr/1,logical/1,t_not/1,relop_simple/1,relop/1,complex_relop/1]). + bsl_bsr/1,logical/1,t_not/1,relop_simple/1,relop/1,complex_relop/1]). -export([]). -import(lists, [foldl/3,flatmap/2]). @@ -40,7 +40,7 @@ all() -> bsl_bsr(Config) when is_list(Config) -> Vs = [unvalue(V) || V <- [-16#8000009-2,-1,0,1,2,73,16#8000000,bad,[]]], Cases = [{Op,X,Y} || Op <- ['bsr','bsl'], X <- Vs, Y <- Vs], - ?line run_test_module(Cases, false), + run_test_module(Cases, false), {comment,integer_to_list(length(Cases)) ++ " cases"}. %% Test the logical operators and internal BIFs. @@ -48,13 +48,13 @@ logical(Config) when is_list(Config) -> Vs0 = [true,false,bad], Vs = [unvalue(V) || V <- Vs0], Cases = [{Op,X,Y} || Op <- ['and','or','xor'], X <- Vs, Y <- Vs], - ?line run_test_module(Cases, false), + run_test_module(Cases, false), {comment,integer_to_list(length(Cases)) ++ " cases"}. %% Test the not operator and internal BIFs. t_not(Config) when is_list(Config) -> - ?line Cases = [{'not',unvalue(V)} || V <- [true,false,42,bad]], - ?line run_test_module(Cases, false), + Cases = [{'not',unvalue(V)} || V <- [true,false,42,bad]], + run_test_module(Cases, false), {comment,integer_to_list(length(Cases)) ++ " cases"}. %% Test that simlpe relations between relation operators hold. @@ -66,52 +66,52 @@ relop_simple(Config) when is_list(Config) -> T1 = erlang:make_tuple(3,87), T2 = erlang:make_tuple(3,87), Terms = [-F2,Big2,-F1,-Big1,-33,-33.0,0,0.0,42,42.0,Big1,F1,Big2,F2,a,b, - {T1,a},{T2,b},[T1,Big1],[T2,Big2]], - - ?line Combos = [{V1,V2} || V1 <- Terms, V2 <- Terms], - + {T1,a},{T2,b},[T1,Big1],[T2,Big2]], + + Combos = [{V1,V2} || V1 <- Terms, V2 <- Terms], + lists:foreach(fun({A,B}) -> relop_simple_do(A,B) end, - Combos), + Combos), repeat(fun() -> - Size = rand:uniform(100), - Rnd1 = make_rand_term(Size), - {Rnd2,0} = clone_and_mutate(Rnd1, rand:uniform(Size)), - relop_simple_do(Rnd1,Rnd2) - end, - 1000), + Size = rand:uniform(100), + Rnd1 = make_rand_term(Size), + {Rnd2,0} = clone_and_mutate(Rnd1, rand:uniform(Size)), + relop_simple_do(Rnd1,Rnd2) + end, + 1000), ok. relop_simple_do(V1,V2) -> %%io:format("compare ~p\n and ~p\n",[V1,V2]), L = V1 < V2, - ?line L = not (V1 >= V2), - ?line L = V2 > V1, - ?line L = not (V2 =< V1), + L = not (V1 >= V2), + L = V2 > V1, + L = not (V2 =< V1), G = V1 > V2, - ?line G = not (V1 =< V2), - ?line G = V2 < V1, - ?line G = not (V2 >= V1), - + G = not (V1 =< V2), + G = V2 < V1, + G = not (V2 >= V1), + ID = V1 =:= V2, - ?line ID = V2 =:= V1, - ?line ID = not (V1 =/= V2), - ?line ID = not (V2 =/= V1), - + ID = V2 =:= V1, + ID = not (V1 =/= V2), + ID = not (V2 =/= V1), + EQ = V1 == V2, - ?line EQ = V2 == V1, - ?line EQ = not (V1 /= V2), - ?line EQ = not (V2 /= V1), - - ?line case {L, EQ, ID, G, cmp_emu(V1,V2)} of - { true, false, false, false, -1} -> ok; - {false, true, false, false, 0} -> ok; - {false, true, true, false, 0} -> ok; - {false, false, false, true, +1} -> ok - end. - + EQ = V2 == V1, + EQ = not (V1 /= V2), + EQ = not (V2 /= V1), + + case {L, EQ, ID, G, cmp_emu(V1,V2)} of + { true, false, false, false, -1} -> ok; + {false, true, false, false, 0} -> ok; + {false, true, true, false, 0} -> ok; + {false, false, false, true, +1} -> ok + end. + %% Emulate internal "cmp" cmp_emu(A,B) when is_tuple(A), is_tuple(B) -> SA = size(A), @@ -122,8 +122,8 @@ cmp_emu(A,B) when is_tuple(A), is_tuple(B) -> end; cmp_emu([A|TA],[B|TB]) -> case cmp_emu(A,B) of - 0 -> cmp_emu(TA,TB); - CMP -> CMP + 0 -> cmp_emu(TA,TB); + CMP -> CMP end; cmp_emu(A,B) -> %% We cheat and use real "cmp" for the primitive types. @@ -131,35 +131,35 @@ cmp_emu(A,B) -> A > B -> +1; true -> 0 end. - + make_rand_term(1) -> make_rand_term_single(); make_rand_term(Arity) -> case rand:uniform(3) of - 1 -> - make_rand_list(Arity); - 2 -> - list_to_tuple(make_rand_list(Arity)); - 3 -> - {Car,Rest} = make_rand_term_rand_size(Arity), - [Car|make_rand_term(Rest)] + 1 -> + make_rand_list(Arity); + 2 -> + list_to_tuple(make_rand_list(Arity)); + 3 -> + {Car,Rest} = make_rand_term_rand_size(Arity), + [Car|make_rand_term(Rest)] end. make_rand_term_single() -> Range = 1 bsl rand:uniform(200), case rand:uniform(12) of - 1 -> random; - 2 -> uniform; - 3 -> rand:uniform(Range) - (Range div 2); - 4 -> Range * (rand:uniform() - 0.5); - 5 -> 0; - 6 -> 0.0; - 7 -> make_ref(); - 8 -> self(); - 9 -> term_to_binary(rand:uniform(Range)); - 10 -> fun(X) -> X*Range end; - 11 -> fun(X) -> X/Range end; - 12 -> [] + 1 -> random; + 2 -> uniform; + 3 -> rand:uniform(Range) - (Range div 2); + 4 -> Range * (rand:uniform() - 0.5); + 5 -> 0; + 6 -> 0.0; + 7 -> make_ref(); + 8 -> self(); + 9 -> term_to_binary(rand:uniform(Range)); + 10 -> fun(X) -> X*Range end; + 11 -> fun(X) -> X/Range end; + 12 -> [] end. make_rand_term_rand_size(1) -> @@ -172,7 +172,7 @@ make_rand_list(0) -> []; make_rand_list(Arity) -> {Term, Rest} = make_rand_term_rand_size(Arity), [Term | make_rand_list(Rest)]. - + clone_and_mutate(Term, 0) -> {clone(Term), 0}; @@ -195,17 +195,17 @@ clone(Term) -> my_list_to_tuple(List) -> try list_to_tuple(List) catch - error:badarg -> - %%io:format("my_list_to_tuple got badarg exception.\n"), - list_to_tuple(purify_list(List)) + error:badarg -> + %%io:format("my_list_to_tuple got badarg exception.\n"), + list_to_tuple(purify_list(List)) end. - + purify_list(List) -> lists:reverse(purify_list(List, [])). purify_list([], Acc) -> Acc; purify_list([H|T], Acc) -> purify_list(T, [H|Acc]); purify_list(Other, Acc) -> [Other|Acc]. - + %% Test the relational operators and internal BIFs on literals. relop(Config) when is_list(Config) -> @@ -214,9 +214,9 @@ relop(Config) when is_list(Config) -> F1 = float(Big1), F2 = float(Big2), Vs0 = [a,b,-33,-33.0,0,0.0,42,42.0,Big1,Big2,F1,F2], - ?line Vs = [unvalue(V) || V <- Vs0], + Vs = [unvalue(V) || V <- Vs0], Ops = ['==', '/=', '=:=', '=/=', '<', '=<', '>', '>='], - ?line binop(Ops, Vs). + binop(Ops, Vs). %% Test the relational operators and internal BIFs on lists and tuples. complex_relop(Config) when is_list(Config) -> @@ -225,51 +225,51 @@ complex_relop(Config) when is_list(Config) -> Vs0 = [an_atom,42.0,42,Big,Float], Vs = flatmap(fun(X) -> [unvalue({X}),unvalue([X])] end, Vs0), Ops = ['==', '/=', '=:=', '=/=', '<', '=<', '>', '>='], - ?line binop(Ops, Vs). + binop(Ops, Vs). binop(Ops, Vs) -> - Run = fun(Op, N) -> ?line Cases = [{Op,V1,V2} || V1 <- Vs, V2 <- Vs], - ?line run_test_module(Cases, true), - N + length(Cases) end, - ?line NumCases = foldl(Run, 0, Ops), + Run = fun(Op, N) -> Cases = [{Op,V1,V2} || V1 <- Vs, V2 <- Vs], + run_test_module(Cases, true), + N + length(Cases) end, + NumCases = foldl(Run, 0, Ops), {comment,integer_to_list(NumCases) ++ " cases"}. - + run_test_module(Cases, GuardsOk) -> - ?line Es = [expr(C) || C <- Cases], - ?line Ok = unvalue(ok), - ?line Gts = case GuardsOk of - true -> - Ges = [guard_expr(C) || C <- Cases], - ?line lists:foldr(fun guard_test/2, [Ok], Ges); - false -> - [Ok] - end, - ?line Fun1 = make_function(guard_tests, Gts), - ?line Bts = lists:foldr(fun body_test/2, [Ok], Es), - ?line Fun2 = make_function(body_tests, Bts), - ?line Bbts = lists:foldr(fun internal_bif/2, [Ok], Es), - ?line Fun3 = make_function(bif_tests, Bbts), - ?line Id = {function,1,id,1,[{clause,1,[{var,1,'I'}],[],[{var,1,'I'}]}]}, + Es = [expr(C) || C <- Cases], + Ok = unvalue(ok), + Gts = case GuardsOk of + true -> + Ges = [guard_expr(C) || C <- Cases], + lists:foldr(fun guard_test/2, [Ok], Ges); + false -> + [Ok] + end, + Fun1 = make_function(guard_tests, Gts), + Bts = lists:foldr(fun body_test/2, [Ok], Es), + Fun2 = make_function(body_tests, Bts), + Bbts = lists:foldr(fun internal_bif/2, [Ok], Es), + Fun3 = make_function(bif_tests, Bbts), + Id = {function,1,id,1,[{clause,1,[{var,1,'I'}],[],[{var,1,'I'}]}]}, Module0 = make_module(op_tests, [Fun1,Fun2,Fun3,Id]), Module = erl_parse:new_anno(Module0), - ?line lists:foreach(fun(F) -> io:put_chars([erl_pp:form(F),"\n"]) end, Module), + lists:foreach(fun(F) -> io:put_chars([erl_pp:form(F),"\n"]) end, Module), %% Compile, load, and run the generated module. Native = case test_server:is_native(?MODULE) of - true -> [native]; - false -> [] - end, - ?line {ok,Mod,Code1} = compile:forms(Module, [time|Native]), - ?line code:delete(Mod), - ?line code:purge(Mod), - ?line {module,Mod} = code:load_binary(Mod, Mod, Code1), - ?line run_function(Mod, guard_tests), - ?line run_function(Mod, body_tests), - ?line run_function(Mod, bif_tests), - - ?line true = code:delete(Mod), - ?line code:purge(Mod), + true -> [native]; + false -> [] + end, + {ok,Mod,Code1} = compile:forms(Module, [time|Native]), + code:delete(Mod), + code:purge(Mod), + {module,Mod} = code:load_binary(Mod, Mod, Code1), + run_function(Mod, guard_tests), + run_function(Mod, body_tests), + run_function(Mod, bif_tests), + + true = code:delete(Mod), + code:purge(Mod), ok. @@ -293,19 +293,19 @@ guard_expr({Op,X,Y}) -> run_function(Mod, Name) -> case catch Mod:Name() of - {'EXIT',Reason} -> - io:format("~p", [get(last)]), - ct:fail({'EXIT',Reason}); - _Other -> - ok + {'EXIT',Reason} -> + io:format("~p", [get(last)]), + ct:fail({'EXIT',Reason}); + _Other -> + ok end. - + guard_test({E,Expr,Res}, Tail) -> True = unvalue(true), [save_term(Expr), {match,1,unvalue(Res), {'if',1,[{clause,1,[],[[E]],[True]}, - {clause,1,[],[[True]],[unvalue(false)]}]}}|Tail]. + {clause,1,[],[[True]],[unvalue(false)]}]}}|Tail]. body_test({E,Expr,{'EXIT',_}}, Tail) -> [save_term(Expr), @@ -331,8 +331,8 @@ internal_bif(Op, Args, Expr, Res, Tail) -> save_term(Term) -> {call,1, - {atom,1,put}, - [{atom,1,last},unvalue(Term)]}. + {atom,1,put}, + [{atom,1,last},unvalue(Term)]}. make_module(Name, Funcs) -> [{attribute,1,module,Name}, @@ -342,18 +342,18 @@ make_module(Name, Funcs) -> make_function(Name, Body) -> {function,1,Name,0,[{clause,1,[],[],Body}]}. - + eval(E0) -> E = erl_parse:new_anno(E0), - ?line case catch erl_eval:exprs(E, []) of - {'EXIT',Reason} -> {'EXIT',Reason}; - {value,Val,_Bs} -> Val - end. + case catch erl_eval:exprs(E, []) of + {'EXIT',Reason} -> {'EXIT',Reason}; + {value,Val,_Bs} -> Val + end. unvalue(V) -> Abstr = erl_parse:abstract(V), erl_parse:anno_to_term(Abstr). - + value({nil,_}) -> []; value({integer,_,X}) -> X; value({string,_,X}) -> X; -- cgit v1.2.3 From 6664eed554974336909d3ffe03f20349cc4c38fd Mon Sep 17 00:00:00 2001 From: Henrik Nord Date: Tue, 15 Mar 2016 15:19:56 +0100 Subject: update copyright-year --- erts/emulator/test/op_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index 562cf1c92d..61637421ff 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2015. All Rights Reserved. +%% Copyright Ericsson AB 1999-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. -- cgit v1.2.3 From 8a6ed0a09eb52f62e7df35d64ac5f3a09aa18edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Wed, 23 Mar 2016 19:46:14 +0100 Subject: Increase timetrap timeout for op_SUITE:bsl_bsr/1 --- erts/emulator/test/op_SUITE.erl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'erts/emulator/test/op_SUITE.erl') diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl index 562cf1c92d..cb683b9cbf 100644 --- a/erts/emulator/test/op_SUITE.erl +++ b/erts/emulator/test/op_SUITE.erl @@ -30,7 +30,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}, - {timetrap, {minutes, 3}}]. + {timetrap, {minutes, 5}}]. all() -> [bsl_bsr, logical, t_not, relop_simple, relop, @@ -39,9 +39,16 @@ all() -> %% Test the bsl and bsr operators. bsl_bsr(Config) when is_list(Config) -> Vs = [unvalue(V) || V <- [-16#8000009-2,-1,0,1,2,73,16#8000000,bad,[]]], - Cases = [{Op,X,Y} || Op <- ['bsr','bsl'], X <- Vs, Y <- Vs], - run_test_module(Cases, false), - {comment,integer_to_list(length(Cases)) ++ " cases"}. + %% Try to use less memory by splitting the cases + + Cases1 = [{Op,X,Y} || Op <- ['bsl'], X <- Vs, Y <- Vs], + N1 = length(Cases1), + run_test_module(Cases1, false), + + Cases2 = [{Op,X,Y} || Op <- ['bsr'], X <- Vs, Y <- Vs], + N2 = length(Cases2), + run_test_module(Cases2, false), + {comment,integer_to_list(N1 + N2) ++ " cases"}. %% Test the logical operators and internal BIFs. logical(Config) when is_list(Config) -> -- cgit v1.2.3