From 44cc5dfcbea91ef419c55a70c67c87b3a44e7a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 10 Mar 2010 07:32:19 +0100 Subject: asn1 tests: Modernize guard tests --- lib/asn1/test/asn1_app_test.erl | 12 ++++++------ lib/asn1/test/asn1_appup_test.erl | 30 ++++++++++++++--------------- lib/asn1/test/asn1_wrapper.erl | 10 +++++----- lib/asn1/test/testContextSwitchingTypes.erl | 4 ++-- lib/asn1/test/testINSTANCE_OF.erl | 12 ++++++------ lib/asn1/test/testMegaco.erl | 2 +- lib/asn1/test/testNBAPsystem.erl | 2 +- lib/asn1/test/testPrimStrings.erl | 2 +- lib/asn1/test/testTimer.erl | 4 ++-- lib/asn1/test/test_undecoded_rest.erl | 4 ++-- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/asn1/test/asn1_app_test.erl b/lib/asn1/test/asn1_app_test.erl index d7e4e5d52a..f0caa9e530 100644 --- a/lib/asn1/test/asn1_app_test.erl +++ b/lib/asn1/test/asn1_app_test.erl @@ -40,7 +40,7 @@ all(suite) -> app_init(suite) -> []; app_init(doc) -> []; -app_init(Config) when list(Config) -> +app_init(Config) when is_list(Config) -> case is_app(asn1) of {ok, AppFile} -> io:format("AppFile: ~n~p~n", [AppFile]), @@ -62,7 +62,7 @@ is_app(App) -> app_fin(suite) -> []; app_fin(doc) -> []; -app_fin(Config) when list(Config) -> +app_fin(Config) when is_list(Config) -> Config. @@ -72,7 +72,7 @@ fields(suite) -> []; fields(doc) -> []; -fields(Config) when list(Config) -> +fields(Config) when is_list(Config) -> AppFile = key1search(app_file, Config), Fields = [vsn, description, modules, registered, applications], case check_fields(Fields, AppFile, []) of @@ -103,7 +103,7 @@ modules(suite) -> []; modules(doc) -> []; -modules(Config) when list(Config) -> +modules(Config) when is_list(Config) -> AppFile = key1search(app_file, Config), Mods = key1search(modules, AppFile), EbinList = get_ebin_mods(asn1), @@ -174,7 +174,7 @@ exportall(suite) -> []; exportall(doc) -> []; -exportall(Config) when list(Config) -> +exportall(Config) when is_list(Config) -> AppFile = key1search(app_file, Config), Mods = key1search(modules, AppFile), check_export_all(Mods). @@ -207,7 +207,7 @@ app_depend(suite) -> []; app_depend(doc) -> []; -app_depend(Config) when list(Config) -> +app_depend(Config) when is_list(Config) -> AppFile = key1search(app_file, Config), Apps = key1search(applications, AppFile), check_apps(Apps). diff --git a/lib/asn1/test/asn1_appup_test.erl b/lib/asn1/test/asn1_appup_test.erl index c12b7c9ba9..95af3fd57c 100644 --- a/lib/asn1/test/asn1_appup_test.erl +++ b/lib/asn1/test/asn1_appup_test.erl @@ -37,7 +37,7 @@ all(suite) -> appup_init(suite) -> []; appup_init(doc) -> []; -appup_init(Config) when list(Config) -> +appup_init(Config) when is_list(Config) -> AppFile = file_name(asn1, ".app"), AppupFile = file_name(asn1, ".appup"), [{app_file, AppFile}, {appup_file, AppupFile}|Config]. @@ -50,7 +50,7 @@ file_name(App, Ext) -> appup_fin(suite) -> []; appup_fin(doc) -> []; -appup_fin(Config) when list(Config) -> +appup_fin(Config) when is_list(Config) -> Config. @@ -60,7 +60,7 @@ appup(suite) -> []; appup(doc) -> "perform a simple check of the appup file"; -appup(Config) when list(Config) -> +appup(Config) when is_list(Config) -> AppupFile = key1search(appup_file, Config), AppFile = key1search(app_file, Config), Modules = modules(AppFile), @@ -147,14 +147,14 @@ check_instructions(UpDown, [Instr|Instrs], AllInstr, Good, Bad, Modules) -> %% A new module is added check_instruction(up, {add_module, Module}, _, Modules) - when atom(Module) -> + when is_atom(Module) -> d("check_instruction -> entry when up-add_module instruction with" "~n Module: ~p", [Module]), check_module(Module, Modules); %% An old module is re-added check_instruction(down, {add_module, Module}, _, Modules) - when atom(Module) -> + when is_atom(Module) -> d("check_instruction -> entry when down-add_module instruction with" "~n Module: ~p", [Module]), case (catch check_module(Module, Modules)) of @@ -168,7 +168,7 @@ check_instruction(down, {add_module, Module}, _, Modules) %% - the module has been removed from the app-file. %% - check that no module depends on this (removed) module check_instruction(up, {remove, {Module, Pre, Post}}, _, Modules) - when atom(Module), atom(Pre), atom(Post) -> + when is_atom(Module), is_atom(Pre), is_atom(Post) -> d("check_instruction -> entry when up-remove instruction with" "~n Module: ~p" "~n Pre: ~p" @@ -184,7 +184,7 @@ check_instruction(up, {remove, {Module, Pre, Post}}, _, Modules) %% Removing a module on downgrade: the module exist %% in the app-file. check_instruction(down, {remove, {Module, Pre, Post}}, AllInstr, Modules) - when atom(Module), atom(Pre), atom(Post) -> + when is_atom(Module), is_atom(Pre), is_atom(Post) -> d("check_instruction -> entry when down-remove instruction with" "~n Module: ~p" "~n Pre: ~p" @@ -200,7 +200,7 @@ check_instruction(down, {remove, {Module, Pre, Post}}, AllInstr, Modules) check_instruction(_, {load_module, Module, Pre, Post, Depend}, AllInstr, Modules) - when atom(Module), atom(Pre), atom(Post), list(Depend) -> + when is_atom(Module), is_atom(Pre), is_atom(Post), is_list(Depend) -> d("check_instruction -> entry when load_module instruction with" "~n Module: ~p" "~n Pre: ~p" @@ -214,7 +214,7 @@ check_instruction(_, {load_module, Module, Pre, Post, Depend}, check_instruction(_, {update, Module, Change, Pre, Post, Depend}, AllInstr, Modules) - when atom(Module), atom(Pre), atom(Post), list(Depend) -> + when is_atom(Module), is_atom(Pre), is_atom(Post), is_list(Depend) -> d("check_instruction -> entry when update instruction with" "~n Module: ~p" "~n Change: ~p" @@ -230,7 +230,7 @@ check_instruction(_, {update, Module, Change, Pre, Post, Depend}, check_instruction(_, {apply, {Module, Function, Args}}, _AllInstr, Modules) - when atom(Module), atom(Function), list(Args) -> + when is_atom(Module), is_atom(Function), is_list(Args) -> d("check_instruction -> entry when apply instruction with" "~n Module: ~p" "~n Function: ~p" @@ -275,13 +275,13 @@ instruction_module(Instr) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -check_version(V) when list(V) -> +check_version(V) when is_list(V) -> ok; check_version(V) -> error({bad_version, V}). -check_module(M, Modules) when atom(M) -> +check_module(M, Modules) when is_atom(M) -> case lists:member(M,Modules) of true -> ok; @@ -293,7 +293,7 @@ check_module(M, _) -> check_apply(Module,Function,Args) -> case (catch Module:module_info()) of - Info when list(Info) -> + Info when is_list(Info) -> check_exported(Function,Args,Info); {'EXIT',{undef,_}} -> error({not_existing_module,Module}) @@ -312,11 +312,11 @@ check_exported(Function,Args,Info) -> error({bad_export,Info}) end. -check_module_depend(M, [], _) when atom(M) -> +check_module_depend(M, [], _) when is_atom(M) -> d("check_module_depend -> entry with" "~n M: ~p", [M]), ok; -check_module_depend(M, Deps, Modules) when atom(M), list(Deps) -> +check_module_depend(M, Deps, Modules) when is_atom(M), is_list(Deps) -> d("check_module_depend -> entry with" "~n M: ~p" "~n Deps: ~p" diff --git a/lib/asn1/test/asn1_wrapper.erl b/lib/asn1/test/asn1_wrapper.erl index 553f0b062c..b1719b03d9 100644 --- a/lib/asn1/test/asn1_wrapper.erl +++ b/lib/asn1/test/asn1_wrapper.erl @@ -26,7 +26,7 @@ encode(Module,Type,Value) -> case asn1rt:encode(Module,Type,Value) of - {ok,X} when binary(X) -> + {ok,X} when is_binary(X) -> {ok, binary_to_list(X)}; {ok,X} -> {ok, binary_to_list(list_to_binary(X))}; @@ -38,21 +38,21 @@ decode(Module,Type,Bytes) -> case Module:encoding_rule() of ber -> asn1rt:decode(Module,Type,Bytes); - ber_bin when binary(Bytes) -> + ber_bin when is_binary(Bytes) -> asn1rt:decode(Module,Type,Bytes); ber_bin -> asn1rt:decode(Module,Type,list_to_binary(Bytes)); - ber_bin_v2 when binary(Bytes) -> + ber_bin_v2 when is_binary(Bytes) -> asn1rt:decode(Module,Type,Bytes); ber_bin_v2 -> asn1rt:decode(Module,Type,list_to_binary(Bytes)); per -> asn1rt:decode(Module,Type,Bytes); - per_bin when binary(Bytes) -> + per_bin when is_binary(Bytes) -> asn1rt:decode(Module,Type,Bytes); per_bin -> asn1rt:decode(Module,Type,list_to_binary(Bytes)); - uper_bin when binary(Bytes) -> + uper_bin when is_binary(Bytes) -> asn1rt:decode(Module,Type,Bytes); uper_bin -> asn1rt:decode(Module,Type,list_to_binary(Bytes)) diff --git a/lib/asn1/test/testContextSwitchingTypes.erl b/lib/asn1/test/testContextSwitchingTypes.erl index 2160122dfe..615f98c9b2 100644 --- a/lib/asn1/test/testContextSwitchingTypes.erl +++ b/lib/asn1/test/testContextSwitchingTypes.erl @@ -71,13 +71,13 @@ check_EXTERNAL_Idef({Alt,_}) when Alt=='context-negotiation'; ok; check_EXTERNAL_Idef(I) -> {error,"failed on identification alternative",I}. -check_EXTERNAL_DVD(DVD) when list(DVD) -> +check_EXTERNAL_DVD(DVD) when is_list(DVD) -> ok; check_EXTERNAL_DVD(asn1_NOVALUE) -> ok; check_EXTERNAL_DVD(DVD) -> {error,"failed on data-value-descriptor alternative",DVD}. -check_EXTERNAL_DV(DV) when list(DV) -> +check_EXTERNAL_DV(DV) when is_list(DV) -> ok; check_EXTERNAL_DV(DV) -> {error,"failed on data-value alternative",DV}. diff --git a/lib/asn1/test/testINSTANCE_OF.erl b/lib/asn1/test/testINSTANCE_OF.erl index 0e2a704934..9f8a871a63 100644 --- a/lib/asn1/test/testINSTANCE_OF.erl +++ b/lib/asn1/test/testINSTANCE_OF.erl @@ -73,17 +73,17 @@ test_encdec(_Erule,{lastName,{'GeneralName_lastName',{2,3,4}, test_encdec(Erule,Res) -> {error,{Erule,Res}}. -wrap(ber,Int) when list(Int) -> +wrap(ber,Int) when is_list(Int) -> binary_to_list(list_to_binary(Int)); -wrap(per,Int) when list(Int) -> +wrap(per,Int) when is_list(Int) -> binary_to_list(list_to_binary(Int)); -wrap(ber_bin,Int) when list(Int) -> +wrap(ber_bin,Int) when is_list(Int) -> list_to_binary(Int); -wrap(ber_bin_v2,Int) when list(Int) -> +wrap(ber_bin_v2,Int) when is_list(Int) -> list_to_binary(Int); -wrap(per_bin,Int) when list(Int) -> +wrap(per_bin,Int) when is_list(Int) -> list_to_binary(Int); -wrap(uper_bin,Int) when list(Int) -> +wrap(uper_bin,Int) when is_list(Int) -> list_to_binary(Int); wrap(_,Int) -> Int. diff --git a/lib/asn1/test/testMegaco.erl b/lib/asn1/test/testMegaco.erl index 094e2d9e5c..48c1361965 100644 --- a/lib/asn1/test/testMegaco.erl +++ b/lib/asn1/test/testMegaco.erl @@ -163,7 +163,7 @@ read_msg(File) -> end. -request(Mid, TransId, ContextId, CmdReq) when list(CmdReq) -> +request(Mid, TransId, ContextId, CmdReq) when is_list(CmdReq) -> Actions = [#'ActionRequest'{contextId = ContextId, commandRequests = CmdReq}], Req = {transactions, diff --git a/lib/asn1/test/testNBAPsystem.erl b/lib/asn1/test/testNBAPsystem.erl index 66f64162eb..5c2fe0267c 100644 --- a/lib/asn1/test/testNBAPsystem.erl +++ b/lib/asn1/test/testNBAPsystem.erl @@ -299,7 +299,7 @@ protocolIEs_051107() -> compare(V,V) -> ok; -compare(V,L) when list(L) -> +compare(V,L) when is_list(L) -> compare(V,list_to_binary(L)); compare(_,_) -> false. diff --git a/lib/asn1/test/testPrimStrings.erl b/lib/asn1/test/testPrimStrings.erl index 2ab4f0817f..ed55cce45d 100644 --- a/lib/asn1/test/testPrimStrings.erl +++ b/lib/asn1/test/testPrimStrings.erl @@ -930,7 +930,7 @@ utf8_string(_Rules) -> ?line {ok,Bin13} = asn1_wrapper:decode('PrimStrings','UTF',Bytes13), ?line {ok,LongVal} = wrapper_utf8_binary_to_list(Bin13). -wrapper_utf8_binary_to_list(L) when list(L) -> +wrapper_utf8_binary_to_list(L) when is_list(L) -> asn1rt:utf8_binary_to_list(list_to_binary(L)); wrapper_utf8_binary_to_list(B) -> asn1rt:utf8_binary_to_list(B). diff --git a/lib/asn1/test/testTimer.erl b/lib/asn1/test/testTimer.erl index eac294c73c..004bfbf0b0 100644 --- a/lib/asn1/test/testTimer.erl +++ b/lib/asn1/test/testTimer.erl @@ -146,7 +146,7 @@ go(Config,Enc) -> Bytes = case Enc of ber_bin -> list_to_binary(B); - per_bin when list(B) -> + per_bin when is_list(B) -> list_to_binary(B); per_bin -> B; @@ -179,7 +179,7 @@ encode(0, _Module,_Type,_Value) -> encode(N, Module,Type,Value) -> ?line {ok,B} = asn1rt:encode(Module,Type,Value), _B2 = if - list(B) -> list_to_binary(B); + is_list(B) -> list_to_binary(B); true -> B end, encode(N-1, Module,Type,Value). diff --git a/lib/asn1/test/test_undecoded_rest.erl b/lib/asn1/test/test_undecoded_rest.erl index 0649957a1c..193cdd8860 100644 --- a/lib/asn1/test/test_undecoded_rest.erl +++ b/lib/asn1/test/test_undecoded_rest.erl @@ -39,9 +39,9 @@ test(Opt) -> ?line {ok,Msg} = asn1ct:value('P-Record','PersonnelRecord'), ?line {ok,Bytes} = asn1_wrapper:encode('P-Record','PersonnelRecord',Msg), Bytes2 = - fun(B) when list(B) -> + fun(B) when is_list(B) -> B ++ [55,55,55]; - (B) when binary(B) -> + (B) when is_binary(B) -> concat_binary([B,<<55,55,55>>]) end (Bytes), -- cgit v1.2.3