Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add test case covering recursive functions #359

Merged
merged 5 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions src/types/__snapshots__/resolveStatements.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1407,3 +1407,76 @@ exports[`resolveStatements should resolve statements for case-21 1`] = `
],
]
`;

exports[`resolveStatements should resolve statements for case-22 1`] = `
[
[
"n",
"Int",
],
[
"0",
"Int",
],
[
"n <= 0",
"Bool",
],
[
"0",
"Int",
],
[
"n",
"Int",
],
[
"1",
"Int",
],
[
"n == 1",
"Bool",
],
[
"1",
"Int",
],
[
"n",
"Int",
],
[
"1",
"Int",
],
[
"n - 1",
"Int",
],
[
"fib(n - 1)",
"Int",
],
[
"n",
"Int",
],
[
"2",
"Int",
],
[
"n - 2",
"Int",
],
[
"fib(n - 2)",
"Int",
],
[
"fib(n - 1) + fib(n - 2)",
"Int",
],
]
`;
7 changes: 7 additions & 0 deletions src/types/stmts/case-22.tact
Gusarich marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
primitive Int;

fun fib(n: Int): Int {
if (n <= 0) { return 0; }
if (n == 1) { return 1; }
return fib(n - 1) + fib(n - 2);
}
Loading