Skip to content

Commit

Permalink
Replace 'or'/'and' with 'orelse'/'andalso' in test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
richcarl committed Feb 3, 2025
1 parent 06e7496 commit 875a5eb
Show file tree
Hide file tree
Showing 17 changed files with 244 additions and 244 deletions.
6 changes: 3 additions & 3 deletions lib/crypto/test/crypto_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ cipher_info_prop_aead_attr(Config) when is_list(Config) ->
case lists:foldl(fun(C,Ok) ->
case crypto:cipher_info(C) of
#{prop_aead := true} ->
true and Ok;
true andalso Ok;
_ ->
false
end
Expand All @@ -1532,7 +1532,7 @@ cipher_info_prop_aead_attr(Config) when is_list(Config) ->
case lists:foldl(fun(C,Ok) ->
case crypto:cipher_info(C) of
#{prop_aead := false} ->
true and Ok;
true andalso Ok;
_ ->
false
end
Expand Down Expand Up @@ -2093,7 +2093,7 @@ rand_uniform_aux_test(N) ->

crypto_rand_uniform(L,H) ->
R1 = (L-1) + rand:uniform(H-L),
case (R1 >= L) and (R1 < H) of
case R1 >= L andalso R1 < H of
true ->
ok;
false ->
Expand Down
2 changes: 1 addition & 1 deletion lib/ssh/test/ssh_options_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ really_do_hostkey_fingerprint_check(Config, HashAlg) ->
end,
ct:log("check ~p == ~p (~p) and ~n~p~n in ~p (~p)~n",
[PeerName,Host,HostCheck,FP,FPs,FPCheck]),
HostCheck and FPCheck
HostCheck andalso FPCheck
end,

ssh_test_lib:connect(Host, Port, [{silently_accept_hosts,
Expand Down
16 changes: 8 additions & 8 deletions lib/ssh/test/ssh_pubkey_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,11 @@ ssh_list_public_key(Config) when is_list(Config) ->
["openssh_rsa_pub", "openssh_dsa_pub", "openssh_ecdsa_pub"]),

true =
(chk_decode(Data_openssh, Expect_openssh, openssh_key) and
chk_decode(Data_ssh2, Expect_ssh2, rfc4716_key) and
chk_decode(Data_openssh, Expect_openssh, public_key) and
chk_decode(Data_ssh2, Expect_ssh2, public_key) and
chk_encode(Expect_openssh, openssh_key) and
(chk_decode(Data_openssh, Expect_openssh, openssh_key) andalso
chk_decode(Data_ssh2, Expect_ssh2, rfc4716_key) andalso
chk_decode(Data_openssh, Expect_openssh, public_key) andalso
chk_decode(Data_ssh2, Expect_ssh2, public_key) andalso
chk_encode(Expect_openssh, openssh_key) andalso
chk_encode(Expect_ssh2, rfc4716_key)
).

Expand Down Expand Up @@ -702,7 +702,7 @@ ssh_known_hosts(Config) when is_list(Config) ->

Value1 = proplists:get_value(hostnames, Attributes1, undefined),
Value2 = proplists:get_value(hostnames, Attributes2, undefined),
true = (Value1 =/= undefined) and (Value2 =/= undefined),
true = Value1 =/= undefined andalso Value2 =/= undefined,

Encoded = ssh_file:encode(Decoded, known_hosts),
Decoded = ssh_file:decode(Encoded, known_hosts).
Expand All @@ -717,7 +717,7 @@ ssh1_known_hosts(Config) when is_list(Config) ->

Value1 = proplists:get_value(hostnames, Attributes1, undefined),
Value2 = proplists:get_value(hostnames, Attributes2, undefined),
true = (Value1 =/= undefined) and (Value2 =/= undefined),
true = Value1 =/= undefined andalso Value2 =/= undefined,

Comment ="dhopson@VMUbuntu-DSH comment with whitespaces",
Comment = proplists:get_value(comment, Attributes3),
Expand Down Expand Up @@ -761,7 +761,7 @@ ssh1_auth_keys(Config) when is_list(Config) ->

Value1 = proplists:get_value(bits, Attributes2, undefined),
Value2 = proplists:get_value(bits, Attributes3, undefined),
true = (Value1 =/= undefined) and (Value2 =/= undefined),
true = Value1 =/= undefined andalso Value2 =/= undefined,

Comment2 = Comment3 = "dhopson@VMUbuntu-DSH",
Comment4 = Comment5 ="dhopson@VMUbuntu-DSH comment with whitespaces",
Expand Down
2 changes: 1 addition & 1 deletion lib/stdlib/test/beam_lib_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ verify_error(S, R) ->

%% Also make sure that formatted message is not just the term printed.
Handled = beam_lib:format_error(R) =/= io_lib:format("~p~n", [R]),
true = ((FM > 0) or (BM > 0)) and Handled.
true = (FM > 0 orelse BM > 0) andalso Handled.

ver(S, {error, beam_lib, R}) ->
[S|_] = tuple_to_list(R),
Expand Down
17 changes: 9 additions & 8 deletions lib/stdlib/test/binary_module_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -745,12 +745,13 @@ encode_decode_loop(Range, X) ->
R = binary:decode_unsigned(make_unaligned(PaddedLittle),little),
S = binref:decode_unsigned(PaddedLittle,little),
T = binref:decode_unsigned(PaddedBig),
case (((A =:= B) and (B =:= C) and (C =:= D)) and
((E =:= F)) and
((N =:= G) and (G =:= H) and (H =:= I) and
(I =:= J) and (J =:= K) and (K =:= L) and (L =:= M)) and
((M =:= O) and (O =:= P) and (P =:= Q) and (Q =:= R) and
(R =:= S) and (S =:= T)))of
case (A =:= B andalso B =:= C andalso C =:= D)
andalso (E =:= F) andalso (N =:= G andalso G =:= H andalso H =:= I
andalso I =:= J andalso J =:= K
andalso K =:= L andalso L =:= M)
andalso (M =:= O andalso O =:= P andalso P =:= Q
andalso Q =:= R andalso R =:= S andalso S =:= T)
of
true ->
encode_decode_loop(Range,X-1);
_ ->
Expand Down Expand Up @@ -1302,7 +1303,7 @@ do_split_comp(N,H,Opts) ->
A = ?MASK_ERROR(binref:split(H,N,Opts)),
D = ?MASK_ERROR(binary:split(H,binary:compile_pattern(N),Opts)),
if
(A =/= [N]) and is_list(A) ->
A =/= [N] andalso is_list(A) ->
put(success_counter,get(success_counter)+1);
true ->
ok
Expand Down Expand Up @@ -1350,7 +1351,7 @@ do_replace_comp(N,H,R,Opts) ->
A = ?MASK_ERROR(binref:replace(H,N,R,Opts)),
D = ?MASK_ERROR(binary:replace(H,binary:compile_pattern(N),R,Opts)),
if
(A =/= N) and is_binary(A) ->
A =/= N andalso is_binary(A) ->
put(success_counter,get(success_counter)+1);
true ->
ok
Expand Down
12 changes: 6 additions & 6 deletions lib/stdlib/test/binref.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ match(Haystack,{Needles},Options) ->
match(Haystack,Needles,Options);
match(Haystack,Needles,Options) ->
try
true = is_binary(Haystack) and is_list(Needles), % badarg, not function_clause
true = is_binary(Haystack) andalso is_list(Needles), % badarg, not function_clause
case get_opts_match(Options,nomatch) of
nomatch ->
mloop(Haystack,Needles);
Expand All @@ -61,7 +61,7 @@ matches(Haystack,{Needles},Options) ->
matches(Haystack,Needles,Options);
matches(Haystack,Needles,Options) ->
try
true = is_binary(Haystack) and is_list(Needles), % badarg, not function_clause
true = is_binary(Haystack) andalso is_list(Needles), % badarg, not function_clause
case get_opts_match(Options,nomatch) of
nomatch ->
msloop(Haystack,Needles);
Expand Down Expand Up @@ -377,7 +377,7 @@ list_to_bin(List) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
longest_common_prefix(LB) ->
try
true = is_list(LB) and (length(LB) > 0), % Make badarg instead of function clause
true = is_list(LB) andalso length(LB) > 0, % Make badarg instead of function clause
do_longest_common_prefix(LB,0)
catch
_:_ ->
Expand Down Expand Up @@ -412,7 +412,7 @@ do_lcp([Bin|T],X,Ch) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
longest_common_suffix(LB) ->
try
true = is_list(LB) and (length(LB) > 0), % Make badarg instead of function clause
true = is_list(LB) andalso length(LB) > 0, % Make badarg instead of function clause
do_longest_common_suffix(LB,0)
catch
_:_ ->
Expand Down Expand Up @@ -474,7 +474,7 @@ copy(Subject) ->
copy(Subject,1).
copy(Subject,N) ->
try
true = is_integer(N) and (N >= 0) and is_binary(Subject), % Badarg, not function clause
true = is_integer(N) andalso N >= 0 andalso is_binary(Subject), % Badarg, not function clause
erlang:list_to_binary(lists:duplicate(N,Subject))
catch
_:_ ->
Expand All @@ -488,7 +488,7 @@ encode_unsigned(Unsigned) ->
encode_unsigned(Unsigned,big).
encode_unsigned(Unsigned,Endian) ->
try
true = is_integer(Unsigned) and (Unsigned >= 0),
true = is_integer(Unsigned) andalso Unsigned >= 0,
if
Unsigned =:= 0 ->
<<0>>;
Expand Down
8 changes: 4 additions & 4 deletions lib/stdlib/test/erl_eval_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,10 @@ simple_cases(Config) when is_list(Config) ->
"(2#101 band 2#10101) bor (2#110 bxor 2#010).", 5),
check(fun() -> (2#1 bsl 4) + (2#10000 bsr 3) end,
"(2#1 bsl 4) + (2#10000 bsr 3).", 18),
check(fun() -> ((1<3) and ((1 =:= 2) or (1 =/= 2))) xor (1=<2) end,
"((1<3) and ((1 =:= 2) or (1 =/= 2))) xor (1=<2).", false),
check(fun() -> (a /= b) or (2 > 4) or (3 >= 3) end,
"(a /= b) or (2 > 4) or (3 >= 3).", true),
check(fun() -> (1<3 andalso (1 =:= 2 orelse 1 =/= 2)) xor (1=<2) end,
"(1<3 andalso (1 =:= 2 orelse 1 =/= 2)) xor (1=<2).", false),
check(fun() -> a /= b orelse 2 > 4 orelse 3 >= 3 end,
"a /= b orelse 2 > 4 orelse 3 >= 3.", true),
check(fun() -> "hej" ++ "san" =/= "hejsan" -- "san" end,
"\"hej\" ++ \"san\" =/= \"hejsan\" -- \"san\".", true),
check(fun() -> (bnot 1) < -0 end, "(bnot (+1)) < -0.", true),
Expand Down
6 changes: 3 additions & 3 deletions lib/stdlib/test/erl_lint_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ unused_vars_warn_fun(Config) when is_list(Config) ->
E;
a([A,B,C,D,E]) -> % E unused.
fun() ->
(C == <<A:A>>) andalso (<<17:B>> == D)
C == <<A:A>> andalso <<17:B>> == D
end.
">>,
[warn_unused_vars],
Expand Down Expand Up @@ -1949,8 +1949,8 @@ guard(Config) when is_list(Config) ->
{guard7,
<<"-record(apa,{}).
t() ->
[X || X <- [1,#apa{},3], (3+is_record(X, apa)) orelse
(is_record(X, apa)*2)].
[X || X <- [1,#apa{},3], 3+is_record(X, apa) orelse
is_record(X, apa)*2].
">>,
[],
[]},
Expand Down
2 changes: 1 addition & 1 deletion lib/stdlib/test/erl_pp_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ pp_expr(List, Options) when is_list(List) ->
if
PP1 =:= PP2 -> % same line numbers
case
(test_max_line(PP1) =:= ok) and (test_new_line(PPneg) =:= ok)
test_max_line(PP1) =:= ok andalso test_new_line(PPneg) =:= ok
of
true ->
ok;
Expand Down
4 changes: 2 additions & 2 deletions lib/stdlib/test/ets_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5400,8 +5400,8 @@ info_do(Opts) ->
end, set, Opts),
PublicOrCurr =
fun(Curr) ->
case lists:member({write_concurrency, false}, Opts) or
lists:member(private, Opts) or
case lists:member({write_concurrency, false}, Opts) orelse
lists:member(private, Opts) orelse
lists:member(protected, Opts) of
true -> Curr;
false -> public
Expand Down
24 changes: 12 additions & 12 deletions lib/stdlib/test/id_transform_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -341,29 +341,29 @@ t2(A) when reference(A); reference(A) ->
t2(A) when tuple(A); tuple(A) ->
tuple.

t3(A) when is_atom(A) or is_atom(A) ->
t3(A) when is_atom(A) ; is_atom(A) ->
is_atom;
t3(A) when is_binary(A) or is_binary(A) ->
t3(A) when is_binary(A) ; is_binary(A) ->
is_binary;
t3(A) when is_float(A) or is_float(A) ->
t3(A) when is_float(A) ; is_float(A) ->
is_float;
t3(A) when is_function(A) or is_function(A) ->
t3(A) when is_function(A) ; is_function(A) ->
is_function;
t3(A) when is_integer(A) or is_integer(A) ->
t3(A) when is_integer(A) ; is_integer(A) ->
is_integer;
t3(A) when is_list(A) or is_list(A) ->
t3(A) when is_list(A) ; is_list(A) ->
is_list;
t3(A) when is_number(A) or is_number(A) ->
t3(A) when is_number(A) ; is_number(A) ->
is_number;
t3(A) when is_pid(A) or is_pid(A) ->
t3(A) when is_pid(A) ; is_pid(A) ->
is_pid;
t3(A) when is_port(A) or is_port(A) ->
t3(A) when is_port(A) ; is_port(A) ->
is_port;
t3(A) when is_record(A, apa) or is_record(A, apa) ->
t3(A) when is_record(A, apa) ; is_record(A, apa) ->
is_record;
t3(A) when is_reference(A) or is_reference(A) ->
t3(A) when is_reference(A) ; is_reference(A) ->
is_reference;
t3(A) when is_tuple(A) or is_tuple(A) ->
t3(A) when is_tuple(A) ; is_tuple(A) ->
is_tuple;
t3(A) when record(A, apa) ->
foo;
Expand Down
2 changes: 1 addition & 1 deletion lib/stdlib/test/io_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,7 @@ g_choice_small(S) when is_list(S) ->
El = length(ES),
I = list_to_integer(IS),
if
El =/= 0, ((I > 9) or (I < -9)) ->
El =/= 0, I > 9 orelse I < -9 ->
throw(too_many_digits_before_the_dot);
El =/= 0, I =:= 0 ->
throw(zero_before_the_dot);
Expand Down
4 changes: 2 additions & 2 deletions lib/stdlib/test/ms_transform_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -778,12 +778,12 @@ float_1_function(Config) when is_list(Config) ->
MS1 = compile_and_run
(<<"ets:fun2ms(fun(X) -> float(X) end)">>),
[F1] = RunMS([3], MS1),
true = is_float(F1) and (F1 == 3),
true = is_float(F1) andalso F1 == 3,

MS1b = compile_and_run
(<<"dbg:fun2ms(fun(X) -> float(X) end)">>),
[F2] = RunMS([3], MS1b),
true = is_float(F2) and (F2 == 3),
true = is_float(F2) andalso F2 == 3,

MS2 = compile_and_run
(<<"ets:fun2ms(fun(X) when is_pid(X) or float(X) -> true end)">>),
Expand Down
Loading

0 comments on commit 875a5eb

Please sign in to comment.