diff --git a/infer/tests/codetoanalyze/erlang/features/issues.exp b/infer/tests/codetoanalyze/erlang/features/issues.exp index 990ba1fef..e3df79dd3 100644 --- a/infer/tests/codetoanalyze/erlang/features/issues.exp +++ b/infer/tests/codetoanalyze/erlang/features/issues.exp @@ -27,6 +27,9 @@ codetoanalyze/erlang/features/src/comparison.erl, test_less_Bad/0, 3, NO_TRUE_BR codetoanalyze/erlang/features/src/comparison.erl, test_less_Bad2/0, 3, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] codetoanalyze/erlang/features/src/comparison.erl, test_not_equal_Bad/0, 3, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] codetoanalyze/erlang/features/src/comparison.erl, test_not_equal_Bad2/0, 3, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] +codetoanalyze/erlang/features/src/lists.erl, test_cons1_Bad/0, 4, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] +codetoanalyze/erlang/features/src/lists.erl, test_cons2_Bad/0, 4, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] +codetoanalyze/erlang/features/src/lists.erl, test_nil_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/features/src/logic.erl, test_and00_Bad/0, 1, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] codetoanalyze/erlang/features/src/logic.erl, test_and01_Bad/0, 1, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] codetoanalyze/erlang/features/src/logic.erl, test_and10_Bad/0, 1, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] diff --git a/infer/tests/codetoanalyze/erlang/features/src/lists.erl b/infer/tests/codetoanalyze/erlang/features/src/lists.erl new file mode 100644 index 000000000..c5916699d --- /dev/null +++ b/infer/tests/codetoanalyze/erlang/features/src/lists.erl @@ -0,0 +1,67 @@ +% Copyright (c) Facebook, Inc. and its affiliates. +% +% This source code is licensed under the MIT license found in the +% LICENSE file in the root directory of this source tree. + +-module(lists). + +-export([ + test_nil_Ok/0, + test_nil_Bad/0, + test_cons1_Ok/0, + test_cons1_Bad/0, + test_cons2_Ok/0, + test_cons2_Bad/0 +]). + +test_nil_Ok() -> + Nil = [], + case Nil of + [] -> ok + end. + +test_nil_Bad() -> + NotNil = [1], + case NotNil of + [] -> ok + end. + +test_cons1_Ok() -> + Nil = [], + L2 = [2 | Nil], + L1 = [1 | L2], + case L1 of + [1, 2] -> ok + end. + +test_cons1_Bad() -> + Nil = [], + L2 = [3 | Nil], + L1 = [1 | L2], + case L1 of + [1, 2] -> ok + end. + +test_cons2_Ok() -> + L = [1, 2, 3], + case L of + [1 | L2] -> + case L2 of + [2 | T] -> + case T of + [3] -> ok + end + end + end. + +test_cons2_Bad() -> + L = [1, 100000, 3], + case L of + [1 | L2] -> + case L2 of + [2 | T] -> + case T of + [3] -> ok + end + end + end.