-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added regression test for check_for_underconstrained_values re…
…solve bug (#5490) # Description ## Problem\* Resolves <!-- Link to GitHub Issue --> ## Summary\* There was a bug in the check_for_underconstrained_values pass that got fixed. This PR adds a regression test for that issue ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
test_programs/compile_success_no_bug/check_uncostrained_regression/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "check_unconstrained_regression" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.31.0" | ||
|
||
[dependencies] |
27 changes: 27 additions & 0 deletions
27
test_programs/compile_success_no_bug/check_uncostrained_regression/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
struct Trigger{ | ||
x: u32, | ||
y: Field, | ||
z: [Field;3], | ||
} | ||
struct ResultType{ | ||
a: u32, | ||
b: Field, | ||
c: [Field;3], | ||
} | ||
|
||
unconstrained fn convert(trigger: Trigger) -> ResultType { | ||
let result= ResultType { a: trigger.x + 1, b: trigger.y - 1 + trigger.z[2], c: [trigger.z[0], 0, trigger.z[1]] }; | ||
result | ||
} | ||
impl Trigger { | ||
fn execute(self) -> ResultType { | ||
let result = convert(self); | ||
assert(result.a == self.x + 1); | ||
assert(result.b == self.y - 1 + self.z[2]); | ||
assert(result.c[1] == 0); | ||
result | ||
} | ||
} | ||
fn main(x: Trigger) -> pub ResultType { | ||
x.execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters