Skip to content

Commit

Permalink
Add test on recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-dequenne-sonarsource committed May 8, 2024
1 parent 48b661c commit a88d53e
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,19 @@ def foo():
""").typeV2().unwrappedType()).isEqualTo(INT_TYPE);
}

@Test
void recursive_function() {
FileInput fileInput = inferTypes("""
def my_recursive_func(n):
...
my_recursive_func(n-1)
""");
FunctionDef functionDef = ((FunctionDef) fileInput.statements().statements().get(0));
FunctionType functionType = (FunctionType) functionDef.name().typeV2();
CallExpression call = (CallExpression) PythonTestUtils.getAllDescendant(fileInput, tree -> tree.is(Tree.Kind.CALL_EXPR)).get(0);
assertThat(call.callee().typeV2()).isEqualTo(functionType);
}

@Test
void flow_insensitive_when_try_except() {
FileInput fileInput = inferTypes("""
Expand Down

0 comments on commit a88d53e

Please sign in to comment.