aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-02-01 17:04:44 +0100
committerBjörn Gustavsson <[email protected]>2012-02-08 10:59:03 +0100
commitbefc18e6aeb5313f5e3c98c9e3f3fb2a9214f4ec (patch)
tree84ce91d44123b6857b64a05e8d9578313319f288 /erts/emulator
parent344f187ec3488cbc7b5a3d75bd8cc08f3b4fefab (diff)
downloadotp-befc18e6aeb5313f5e3c98c9e3f3fb2a9214f4ec.tar.gz
otp-befc18e6aeb5313f5e3c98c9e3f3fb2a9214f4ec.tar.bz2
otp-befc18e6aeb5313f5e3c98c9e3f3fb2a9214f4ec.zip
Replace autoimport_SUITE with bif_SUITE:auto_imports/1
erts/test/autoimport_SUITE tested that auto-import information in erl_internal:bif/2 was consistent with the documentation. It did it by scanning erlang.xml. Since the documentation is now based on the specs in erlang.erl, we should now test consistency of the specs and erl_internal:bif/2. Since anyone that adds a new BIF runs the emulator test suite, it makes sense to do this test in bif_SUITE in the emulator test suite.
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/test/bif_SUITE.erl33
1 files changed, 31 insertions, 2 deletions
diff --git a/erts/emulator/test/bif_SUITE.erl b/erts/emulator/test/bif_SUITE.erl
index eaececdafa..3172d75e10 100644
--- a/erts/emulator/test/bif_SUITE.erl
+++ b/erts/emulator/test/bif_SUITE.erl
@@ -25,7 +25,7 @@
init_per_group/2,end_per_group/2,
init_per_testcase/2,end_per_testcase/2,
display/1, display_huge/0,
- erl_bif_types/1,specs/1,improper_bif_stubs/1,
+ erl_bif_types/1,specs/1,improper_bif_stubs/1,auto_imports/1,
t_list_to_existing_atom/1,os_env/1,otp_7526/1,
binary_to_atom/1,binary_to_existing_atom/1,
atom_to_binary/1,min_max/1]).
@@ -33,7 +33,7 @@
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [erl_bif_types, specs, improper_bif_stubs,
+ [erl_bif_types, specs, improper_bif_stubs, auto_imports,
t_list_to_existing_atom, os_env, otp_7526,
display,
atom_to_binary, binary_to_atom, binary_to_existing_atom,
@@ -213,6 +213,35 @@ improper_bif_stubs(_) ->
[check_stub(MFA, Body) || {MFA,Body} <- sofs:to_external(FuncRel)],
ok.
+auto_imports(_Config) ->
+ Path = get_code_path(),
+ {erlang,Abstr} = extract_abstract(erlang, Path),
+ SpecFuns = [Name || {attribute,_,spec,{Name,_}} <- Abstr],
+ auto_imports(SpecFuns, 0).
+
+auto_imports([{F,A}|T], Errors) ->
+ case erl_internal:bif(F, A) of
+ false ->
+ io:format("~p/~p: not auto-imported, but spec claims it "
+ "is auto-imported", [F,A]),
+ auto_imports(T, Errors+1);
+ true ->
+ auto_imports(T, Errors)
+ end;
+auto_imports([{erlang,F,A}|T], Errors) ->
+ case erl_internal:bif(F, A) of
+ false ->
+ auto_imports(T, Errors);
+ true ->
+ io:format("~p/~p: auto-imported, but "
+ "spec claims it is *not* auto-imported", [F,A]),
+ auto_imports(T, Errors+1)
+ end;
+auto_imports([], 0) ->
+ ok;
+auto_imports([], Errors) ->
+ ?t:fail({Errors,inconsistencies}).
+
extract_functions(M, Abstr) ->
[{{M,F,A},Body} || {function,_,F,A,Body} <- Abstr].