Skip to content

Commit 2f3c9bd

Browse files
committed
Improve code coverage
1 parent b1ae6ff commit 2f3c9bd

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

lib/compiler/src/beam_ssa_type.erl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,8 +2749,6 @@ infer_integer_get_range(Arg, Ts) ->
27492749
case concrete_type(Arg, Ts) of
27502750
#t_integer{elements={_,_}=R} ->
27512751
R;
2752-
#t_number{elements={Min,Max}=R}
2753-
when is_integer(Min), is_integer(Max) -> R;
27542752
_ ->
27552753
{'-inf','+inf'}
27562754
end.

lib/compiler/src/beam_validator.erl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,8 +2374,6 @@ infer_integer_get_range(Arg, Vst) ->
23742374
case get_term_type(Arg, Vst) of
23752375
#t_integer{elements={_,_}=R} ->
23762376
R;
2377-
#t_number{elements={Min,Max}=R}
2378-
when is_integer(Min), is_integer(Max) -> R;
23792377
_ ->
23802378
{'-inf','+inf'}
23812379
end.

lib/compiler/test/guard_SUITE.erl

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,6 +3446,16 @@ is_integer_3_guard(_Config) ->
34463446
2 = is_integer_3_guard_5(id(2), id(0), id(9)),
34473447
false = is_integer_3_guard_5(id(1024), id(0), id(9)),
34483448

3449+
false = is_integer_3_guard_6(id(0), id(1), id(-1)),
3450+
true = is_integer_3_guard_6(id(0), id(0), id(1)),
3451+
3452+
false = is_integer_3_guard_7(id(0), id(1), id(9)),
3453+
true = is_integer_3_guard_7(id(1), id(1), id(9)),
3454+
3455+
true = is_integer_3_guard_8(id(17), id(12), id(20)),
3456+
false = is_integer_3_guard_8(id(0), id(12), id(20)),
3457+
true = is_integer_3_guard_8(id(5), id(1), id(20)),
3458+
34493459
ok.
34503460

34513461
is_integer_3_guard_1(X, LB, UB) when is_integer(X, LB, UB) ->
@@ -3463,18 +3473,40 @@ is_integer_3_guard_3(X) when not is_integer(X, 1, 1024) ->
34633473
is_integer_3_guard_3(X) ->
34643474
not is_integer(X, 1, 1024).
34653475

3466-
is_integer_3_guard_4(X, LB, UB) when 0 =< LB, UB < 10, is_integer(X, LB, UB) ->
3467-
is_integer_id(X);
3476+
is_integer_3_guard_4(X, LB, UB) when 0 =< LB, UB < 10,
3477+
is_integer(X, LB, UB) ->
3478+
is_integer_3_guard_4_id(X);
34683479
is_integer_3_guard_4(X, LB, UB) ->
34693480
is_integer(X, LB, UB).
34703481

3471-
is_integer_3_guard_5(X, LB, UB) when 0 =< LB, is_integer(UB),
3482+
is_integer_3_guard_4_id(I) -> I.
3483+
3484+
is_integer_3_guard_5(X, LB, UB) when 0 =< LB, is_integer(UB),
34723485
UB < 10, is_integer(X, LB, UB) ->
3473-
is_integer_id(X);
3486+
is_integer_3_guard_5_id(X);
34743487
is_integer_3_guard_5(X, LB, UB) ->
34753488
is_integer(X, LB, UB).
34763489

3477-
is_integer_id(I) -> I.
3490+
is_integer_3_guard_5_id(I) -> I.
3491+
3492+
%% Test incorrect order of bounds.
3493+
is_integer_3_guard_6(X, LB, UB) when 10 =< LB, UB < 0, is_integer(X, LB, UB) ->
3494+
is_integer(X, LB, UB);
3495+
is_integer_3_guard_6(X, LB, UB) ->
3496+
is_integer(X, LB, UB).
3497+
3498+
is_integer_3_guard_7(X, LB, UB) when is_number(UB), UB < 10, is_integer(X, LB, UB) ->
3499+
is_integer(X, LB, UB);
3500+
is_integer_3_guard_7(X, LB, UB) ->
3501+
is_integer(X, LB, UB).
3502+
3503+
is_integer_3_guard_8(X, LB, UB) when is_number(LB), LB > 10, is_integer(X, LB, UB) ->
3504+
is_integer_3_guard_8_id(X),
3505+
is_integer(X, LB, UB);
3506+
is_integer_3_guard_8(X, LB, UB) ->
3507+
is_integer(X, LB, UB).
3508+
3509+
is_integer_3_guard_8_id(I) -> I.
34783510

34793511
%% Call this function to turn off constant propagation.
34803512
id(I) -> I.

0 commit comments

Comments
 (0)