Skip to content

Commit

Permalink
Add separate execution_success/loop test
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Oct 3, 2024
1 parent 6eee91b commit 754738b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test_programs/execution_success/loop/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "loop"
type = "bin"
authors = [""]

[dependencies]
1 change: 1 addition & 0 deletions test_programs/execution_success/loop/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sum = "6"
23 changes: 23 additions & 0 deletions test_programs/execution_success/loop/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Tests a very simple program.
//
// The features being tested is basic looping.
fn main(six_as_u32: u32) {
assert_eq(loop(4), six_as_u32);
assert_eq(loop_incl(3), six_as_u32);
}

fn loop(x: u32) -> u32 {
let mut sum = 0;
for i in 0..x {
sum = sum + i;
}
sum
}

fn loop_incl(x: u32) -> u32 {
let mut sum = 0;
for i in 0..=x {
sum = sum + i;
}
sum
}

0 comments on commit 754738b

Please sign in to comment.