[erl-frontend] Add tests related to variables

Summary: Basic tests for variables and their assignments.

Reviewed By: mmarescotti

Differential Revision: D29964611

fbshipit-source-id: c22b3565c
master
Akos Hajdu 3 years ago committed by Facebook GitHub Bot
parent 722049f72b
commit 97fde8643c

@ -59,3 +59,7 @@ codetoanalyze/erlang/features/src/tuples.erl, test_second_Bad/0, -24, NO_MATCHIN
codetoanalyze/erlang/features/src/tuples.erl, test_third_Bad/0, -36, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/tuples.erl, third/1, 0, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [*** LATENT ***,no matching function clause here]
codetoanalyze/erlang/features/src/tuples.erl, warn/1, 0, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [*** LATENT ***,no matching function clause here]
codetoanalyze/erlang/features/src/variables.erl, test2_Bad/0, -13, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/variables.erl, test3_Bad/0, -24, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here]
codetoanalyze/erlang/features/src/variables.erl, test5_Bad/0, 2, NO_MATCH_OF_RHS, no_bucket, ERROR, [no match of RHS here]
codetoanalyze/erlang/features/src/variables.erl, warn/1, 0, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [*** LATENT ***,no matching function clause here]

@ -0,0 +1,59 @@
% 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(variables).
-export([
test1_Ok/0,
test2_Bad/0,
test3_Bad/0,
test4_Ok/0,
test5_Bad/0
]).
% Call this method with warn(1) to trigger a warning to expect
warn(0) -> ok.
test1_Ok() ->
X = 2,
Y = X,
Z = 3,
case Y of
2 -> ok
end,
case Z of
3 -> ok
end.
test2_Bad() ->
X = 2,
Y = X,
Z = 3,
case Y of
2 -> warn(1)
end,
case Z of
3 -> ok
end.
test3_Bad() ->
X = 2,
Y = X,
Z = 3,
case Y of
2 -> ok
end,
case Z of
3 -> warn(1)
end.
test4_Ok() ->
X = 2,
2 = X,
ok.
test5_Bad() ->
X = 2,
3 = X,
ok.
Loading…
Cancel
Save