summaryrefslogtreecommitdiff
path: root/lib/compiler/test/bs_match_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compiler/test/bs_match_SUITE.erl')
-rw-r--r--lib/compiler/test/bs_match_SUITE.erl50
1 files changed, 42 insertions, 8 deletions
diff --git a/lib/compiler/test/bs_match_SUITE.erl b/lib/compiler/test/bs_match_SUITE.erl
index e935fe98ff..b477109f45 100644
--- a/lib/compiler/test/bs_match_SUITE.erl
+++ b/lib/compiler/test/bs_match_SUITE.erl
@@ -48,7 +48,8 @@
exceptions_after_match_failure/1,
bad_phi_paths/1,many_clauses/1,
combine_empty_segments/1,hangs_forever/1,
- bs_saved_position_units/1,empty_matches/1]).
+ bs_saved_position_units/1,empty_matches/1,
+ trim_bs_start_match_resume/1]).
-export([coverage_id/1,coverage_external_ignore/2]).
@@ -87,7 +88,8 @@ groups() ->
matching_meets_apply,bs_start_match2_defs,
exceptions_after_match_failure,bad_phi_paths,
many_clauses,combine_empty_segments,hangs_forever,
- bs_saved_position_units,empty_matches]}].
+ bs_saved_position_units,empty_matches,
+ trim_bs_start_match_resume]}].
init_per_suite(Config) ->
test_lib:recompile(?MODULE),
@@ -849,6 +851,8 @@ coverage(Config) when is_list(Config) ->
{<<"abc">>,<<"tag">>} = coverage_trim_3([<<"abc","tag">>], 3),
+ <<57348:16/native>> = coverage_trim_4(<<"abc">>),
+
%% Cover code in beam_ssa_codegen.
ok = coverage_beam_ssa_codegen(<<2>>),
@@ -980,6 +984,15 @@ coverage_trim_3(CipherTextFragment, TagLen) ->
iolist_to_binary(CipherTextFragment),
{CipherText, CipherTag}.
+coverage_trim_4(Bin) ->
+ << <<X:16>> || <<X:8>> <= Bin >>,
+ try
+ <<57348:16/native>>
+ catch
+ _:_ ->
+ error
+ end.
+
printable_char($a) -> true;
printable_char(_) -> false.
@@ -1478,10 +1491,11 @@ haystack_2(Haystack) ->
fc({'EXIT',{function_clause,_}}) -> ok;
fc({'EXIT',{{case_clause,_},_}}) when ?MODULE =:= bs_match_inline_SUITE -> ok.
-fc(Name, Args, {'EXIT',{function_clause,[{?MODULE,Name,Args,_}|_]}}) -> ok;
-fc(_, Args, {'EXIT',{{case_clause,ActualArgs},_}})
+fc(Name, Args, {'EXIT',{function_clause,[{?MODULE,Name,Args,_}|_]}}) ->
+ ok;
+fc(Name, Args, {'EXIT',{function_clause,[{?MODULE,_,Args,_}|_]}})
when ?MODULE =:= bs_match_inline_SUITE ->
- Args = tuple_to_list(ActualArgs).
+ ok.
%% Cover the clause handling bs_context to binary in
%% beam_block:initialized_regs/2.
@@ -1633,9 +1647,9 @@ mos_int_receive(Msg) ->
Res.
mos_int_fun(B) ->
- L = ignore_me,
- F = fun ([<<L,I:L,X:32>>]) -> {I,X};
- ([<<L,I:L,X:64>>]) -> {I,X}
+ _L = ignore_me,
+ F = fun ([<<_L,I:_L,X:32>>]) -> {I,X};
+ ([<<_L,I:_L,X:64>>]) -> {I,X}
end,
F(B).
@@ -2434,6 +2448,11 @@ empty_matches(Config) when is_list(Config) ->
<<Zero:0/unit:1>> = id(<<>>),
0 = id(Zero),
+ ok = em_4(<<>>, <<>>),
+ {'EXIT',{function_clause,[_|_]}} = catch em_4(<<>>, <<0:1>>),
+ {'EXIT',{function_clause,[_|_]}} = catch em_4(<<0:1>>, <<>>),
+ {'EXIT',{function_clause,[_|_]}} = catch em_4(<<0:1>>, <<0:1>>),
+
ok.
em_1(Bytes) ->
@@ -2457,6 +2476,21 @@ em_3(<<V:0/binary,Rest/bits>>) ->
em_3_1(I) -> I.
+%% GH-6426/OTP-xxxxx
+em_4(<<X:0, _:X>>, <<Y:0, _:Y>>) ->
+ ok.
+
+%% beam_trim would sometimes crash when bs_start_match4 had {atom,resume} as
+%% its fail label.
+trim_bs_start_match_resume(Config) when is_list(Config) ->
+ <<Context/binary>> = id(<<>>),
+ <<>> = trim_bs_start_match_resume_1(Context),
+ ok.
+
+trim_bs_start_match_resume_1(<<Context/binary>>) ->
+ _ = id(Context),
+ Context.
+
id(I) -> I.
expand_and_squeeze(Config) when is_list(Config) ->