[erl-frontend] Add tests for non-exhaistive case expressions

Summary: Add some test cases to potentially non-exhaustive case clauses.

Reviewed By: rgrig

Differential Revision: D29555525

fbshipit-source-id: f710e93e6
master
Akos Hajdu 4 years ago committed by Facebook GitHub Bot
parent a46bd3f55a
commit 5093fe4614

@ -1,5 +1,8 @@
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, assert_empty/1, 0, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, assert_second_is_nil/1, 0, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, case_simple/1, 1, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, case_test_simple3_Bad/0, -14, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `case_simple/1`,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, case_test_tail3_Bad/0, -15, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `tail_with_case/1`,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, fp_list_match_test_secondnil1_Ok/0, -17, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `assert_second_is_nil/1`,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, fp_list_match_test_secondnil2_Ok/0, -20, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `assert_second_is_nil/1`,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, fp_match_test_c_Ok/0, 1, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [no pattern match here]
@ -11,6 +14,7 @@ codetoanalyze/erlang/nonmatch/src/nonmatch.erl, list_match_test_tail3_Bad/0, -8,
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, match_test_b_Bad/0, 1, CONSTANT_ADDRESS_DEREFERENCE, no_bucket, WARNING, [in call to `two/0`,is the constant 2,assigned,returned,return from call to `two/0`,invalid access occurs here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, match_test_b_Bad/0, 1, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, match_test_e_Bad/0, -42, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `tail/1`,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, match_test_g_Bad/0, 7, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `only_accepts_one/1`,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, match_test_g_Bad/0, 32, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [calling context starts here,in call to `only_accepts_one/1`,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, only_accepts_one/1, 0, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, tail/1, 0, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here]
codetoanalyze/erlang/nonmatch/src/nonmatch.erl, tail_with_case/1, 1, NONEXHAUSTIVE_PATTERN_MATCH, no_bucket, ERROR, [*** LATENT ***,no pattern match here]

@ -21,7 +21,13 @@
fp_match_test_d_Ok/0,
match_test_e_Bad/0,
match_test_f_Ok/0,
match_test_g_Bad/0
match_test_g_Bad/0,
case_test_simple1_Ok/0,
case_test_simple2_Ok/0,
case_test_simple3_Bad/0,
case_test_tail1_Ok/0,
case_test_tail2_Ok/0,
case_test_tail3_Bad/0
]).
tail([_ | Xs]) -> Xs.
@ -79,6 +85,31 @@ match_test_g_Bad() ->
X = 2,
only_accepts_one(X).
case_simple(X) ->
case X of
0 -> zero;
1 -> one
end.
tail_with_case(X) ->
case X of
[_|T] -> T
end.
case_test_simple1_Ok() ->
case_simple(0).
case_test_simple2_Ok() ->
case_simple(1).
case_test_simple3_Bad() ->
case_simple(2).
case_test_tail1_Ok() ->
tail_with_case([1, 2]).
case_test_tail2_Ok() ->
tail_with_case([1]).
case_test_tail3_Bad() ->
tail_with_case([]).
%% internal
%% These functions are used to fool the compiler, which would warn if these were inlined.

Loading…
Cancel
Save