Skip to content

Commit

Permalink
chore: Add test for recursing a foldable function (#4948)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves #4616 

## Summary\*

I wrote the initial issue for recursive calls a while ago. I thought I
had an error at the time and that is why I wrote the issue but it looks
to all be working for fibonacci example. This simply adds a test to
validate recursive ACIR calls.

## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [X] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
vezenovm authored Apr 30, 2024
1 parent 0ce04d3 commit 25080f3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test_programs/execution_success/fold_fibonacci/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "fold_fibonacci"
type = "bin"
authors = [""]
compiler_version = ">=0.28.0"

[dependencies]
1 change: 1 addition & 0 deletions test_programs/execution_success/fold_fibonacci/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "10"
12 changes: 12 additions & 0 deletions test_programs/execution_success/fold_fibonacci/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn main(x: u32) {
assert(fibonacci(x) == 55);
}

#[fold]
fn fibonacci(x: u32) -> u32 {
if x <= 1 {
x
} else {
fibonacci(x - 1) + fibonacci(x - 2)
}
}
1 change: 1 addition & 0 deletions tooling/debugger/ignored-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ fold_numeric_generic_poseidon
no_predicates_basic
no_predicates_numeric_generic_poseidon
regression_4709
fold_fibonacci

0 comments on commit 25080f3

Please sign in to comment.