[erl-frontend] Add some list tests

Summary: Add some tests for lists: nil, cons, and some basic pattern matching. We can extend this suite later with more features on lists (e.g. concatenation).

Reviewed By: skcho

Differential Revision: D29844279

fbshipit-source-id: 62c8b92c3
master
Akos Hajdu 3 years ago committed by Facebook GitHub Bot
parent 89ba2cc163
commit f15a68083c

@ -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_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_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/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_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_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] 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]

@ -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.
Loading…
Cancel
Save