aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-06-27 17:08:26 +0200
committerSverker Eriksson <[email protected]>2017-06-27 17:08:26 +0200
commit86bcdcb3db79ac2d1faa387bbe194924e966dd69 (patch)
treeb0f2e3e7fbbe0b661276667ddb75f75a6456f203 /erts/emulator/test
parent040bdce67f88d833bfb59adae130a4ffb4c180f0 (diff)
downloadotp-86bcdcb3db79ac2d1faa387bbe194924e966dd69.tar.gz
otp-86bcdcb3db79ac2d1faa387bbe194924e966dd69.tar.bz2
otp-86bcdcb3db79ac2d1faa387bbe194924e966dd69.zip
erts: Make apply throw 'badarg' if Args is not a list
instead of a strange 'undef' exception.
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/fun_SUITE.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/erts/emulator/test/fun_SUITE.erl b/erts/emulator/test/fun_SUITE.erl
index e4640909aa..7d29ebec52 100644
--- a/erts/emulator/test/fun_SUITE.erl
+++ b/erts/emulator/test/fun_SUITE.erl
@@ -22,6 +22,7 @@
-export([all/0, suite/0,
bad_apply/1,bad_fun_call/1,badarity/1,ext_badarity/1,
+ bad_arglist/1,
equality/1,ordering/1,
fun_to_port/1,t_phash/1,t_phash2/1,md5/1,
refc/1,refc_ets/1,refc_dist/1,
@@ -39,6 +40,7 @@ suite() ->
all() ->
[bad_apply, bad_fun_call, badarity, ext_badarity,
+ bad_arglist,
equality, ordering, fun_to_port, t_phash,
t_phash2, md5, refc, refc_ets, refc_dist,
const_propagation, t_arity, t_is_function2, t_fun_info,
@@ -107,6 +109,18 @@ bad_call_fc(Fun) ->
ct:fail({bad_result,Other})
end.
+% Test erlang:apply with non-proper arg-list
+bad_arglist(Config) when is_list(Config) ->
+ Fun = fun(A,B) -> A+B end,
+ {'EXIT', {badarg,_}} = (catch apply(Fun, 17)),
+ {'EXIT', {badarg,_}} = (catch apply(Fun, [17|18])),
+ {'EXIT', {badarg,_}} = (catch apply(Fun, [17,18|19])),
+ {'EXIT', {badarg,_}} = (catch apply(lists,seq, 17)),
+ {'EXIT', {badarg,_}} = (catch apply(lists,seq, [17|18])),
+ {'EXIT', {badarg,_}} = (catch apply(lists,seq, [17,18|19])),
+ ok.
+
+
%% Call and apply valid funs with wrong number of arguments.
badarity(Config) when is_list(Config) ->