From befc18e6aeb5313f5e3c98c9e3f3fb2a9214f4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 1 Feb 2012 17:04:44 +0100 Subject: 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. --- erts/emulator/test/bif_SUITE.erl | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'erts/emulator') 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]. -- cgit v1.2.3