Skip to content

Commit 3ceac8f

Browse files
chore(test): add tests for unconstrained main recursion (#8551)
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
1 parent 7e7cb4c commit 3ceac8f

11 files changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "brillig_recursive_main"
3+
type = "bin"
4+
authors = [""]
5+
6+
[dependencies]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x = "3"
2+
3+
return = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
unconstrained fn main(x: u32) -> pub bool {
2+
if x == 0 {
3+
true
4+
} else {
5+
main(x - 1)
6+
}
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[brillig_recursive_main] Circuit output: Field(1)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "brillig_recursive_main_indirect"
3+
type = "bin"
4+
authors = [""]
5+
6+
[dependencies]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x = "10"
2+
3+
return = true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
unconstrained fn foo(x: u32, f: unconstrained fn(u32) -> bool) -> bool {
2+
if f(x - 1) & (x > 1) {
3+
f(x - 2)
4+
} else {
5+
x < 2
6+
}
7+
}
8+
9+
unconstrained fn main(x: u32) -> pub bool {
10+
if x == 0 {
11+
true
12+
} else {
13+
foo(x, main)
14+
}
15+
}

tooling/nargo_cli/tests/snapshots/execution_success/brillig_recursive_main/execute__tests__expanded.snap

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/nargo_cli/tests/snapshots/execution_success/brillig_recursive_main/execute__tests__stdout.snap

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/nargo_cli/tests/snapshots/execution_success/brillig_recursive_main_indirect/execute__tests__expanded.snap

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)