[erl-frontend] Add more tests to check for tuple sizes

Summary: Some more tests to make sure we consider the size of tuples when pattern matching.

Reviewed By: mmarescotti

Differential Revision: D30132889

fbshipit-source-id: 74ae4d1a1
master
Akos Hajdu 3 years ago committed by Facebook GitHub Bot
parent 01d670299f
commit 50c3f0ba64

@ -39,6 +39,8 @@ codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple2_Bad/0, 2, NO
codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple3_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple3_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here]
codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple4_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple4_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here]
codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple5_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple5_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here]
codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple6_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here]
codetoanalyze/erlang/nonmatch/src/records.erl, test_match_as_tuple7_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here]
codetoanalyze/erlang/nonmatch/src/records.erl, test_match_field2_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/nonmatch/src/records.erl, test_match_field2_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here]
codetoanalyze/erlang/nonmatch/src/records.erl, test_match_field3_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/nonmatch/src/records.erl, test_match_field3_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here]
codetoanalyze/erlang/nonmatch/src/records.erl, test_match_field4_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/nonmatch/src/records.erl, test_match_field4_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here]
@ -62,3 +64,4 @@ codetoanalyze/erlang/nonmatch/src/tuples.erl, test_nested3_Bad/0, 2, NO_MATCH_OF
codetoanalyze/erlang/nonmatch/src/tuples.erl, test_nested4_Bad/0, 2, NO_MATCH_OF_RHS, no_bucket, ERROR, [no match of RHS here] codetoanalyze/erlang/nonmatch/src/tuples.erl, test_nested4_Bad/0, 2, NO_MATCH_OF_RHS, no_bucket, ERROR, [no match of RHS here]
codetoanalyze/erlang/nonmatch/src/tuples.erl, test_size2_Bad/0, -5, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `accepts_tuple_of_two/1`,no matching function clause here] codetoanalyze/erlang/nonmatch/src/tuples.erl, test_size2_Bad/0, -5, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `accepts_tuple_of_two/1`,no matching function clause here]
codetoanalyze/erlang/nonmatch/src/tuples.erl, test_size3_Bad/0, -8, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `accepts_tuple_of_two/1`,no matching function clause here] codetoanalyze/erlang/nonmatch/src/tuples.erl, test_size3_Bad/0, -8, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `accepts_tuple_of_two/1`,no matching function clause here]
codetoanalyze/erlang/nonmatch/src/tuples.erl, test_size4_Bad/0, -11, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `accepts_tuple_of_two/1`,no matching function clause here]

@ -30,6 +30,8 @@
test_match_as_tuple3_Bad/0, test_match_as_tuple3_Bad/0,
test_match_as_tuple4_Bad/0, test_match_as_tuple4_Bad/0,
test_match_as_tuple5_Bad/0, test_match_as_tuple5_Bad/0,
test_match_as_tuple6_Bad/0,
test_match_as_tuple7_Bad/0,
test_bad_record_access_Bad/0, test_bad_record_access_Bad/0,
test_bad_record_update_Bad/0, test_bad_record_update_Bad/0,
test_nested1_Ok/0, test_nested1_Ok/0,
@ -147,6 +149,18 @@ test_match_as_tuple5_Bad() ->
{person, 123, 45, 999999} -> ok {person, 123, 45, 999999} -> ok
end. end.
test_match_as_tuple6_Bad() ->
P = #person{name = 123, phone = 45, address = 6789},
case P of
{person, _, _} -> ok
end.
test_match_as_tuple7_Bad() ->
P = #person{name = 123, phone = 45, address = 6789},
case P of
{person, _, _, _, _} -> ok
end.
test_bad_record_access_Bad() -> test_bad_record_access_Bad() ->
P = #person{name = 123, phone = 45, address = 6789}, P = #person{name = 123, phone = 45, address = 6789},
P#rabbit.name. P#rabbit.name.

@ -9,6 +9,7 @@
test_size1_Ok/0, test_size1_Ok/0,
test_size2_Bad/0, test_size2_Bad/0,
test_size3_Bad/0, test_size3_Bad/0,
test_size4_Bad/0,
test_elements1_Ok/0, test_elements1_Ok/0,
test_elements2_Bad/0, test_elements2_Bad/0,
test_elements3_Bad/0, test_elements3_Bad/0,
@ -38,6 +39,9 @@ test_size2_Bad() ->
test_size3_Bad() -> test_size3_Bad() ->
accepts_tuple_of_two({1}). accepts_tuple_of_two({1}).
test_size4_Bad() ->
accepts_tuple_of_two({}).
test_elements1_Ok() -> test_elements1_Ok() ->
T = {1, 2}, T = {1, 2},
{1, 2} = T, {1, 2} = T,

Loading…
Cancel
Save