-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
158 additions
and
33 deletions.
There are no files selected for viewing
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
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
2 changes: 1 addition & 1 deletion
2
test_programs/execution_success/brillig_fns_as_values/Prover.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 |
---|---|---|
@@ -1 +1 @@ | ||
x = "0" | ||
x = "1" |
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
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,6 @@ | ||
[package] | ||
name = "brillig_wrapping" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
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,2 @@ | ||
x = 0 | ||
y = 255 |
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,8 @@ | ||
use dep::std; | ||
|
||
unconstrained fn main(x: u8, y: u8) { | ||
assert(std::wrapping_sub(x, 1) == y); | ||
assert(std::wrapping_add(y, 1) == x); | ||
assert(std::wrapping_mul(y, y) == 1); | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
test_programs/noir_test_success/brillig_overflow_checks/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,5 @@ | ||
[package] | ||
name = "brillig_overflow_checks" | ||
type = "bin" | ||
authors = [""] | ||
[dependencies] |
Empty file.
23 changes: 23 additions & 0 deletions
23
test_programs/noir_test_success/brillig_overflow_checks/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,23 @@ | ||
use dep::std::field::bn254::{TWO_POW_128, assert_gt}; | ||
|
||
#[test(should_fail_with = "attempt to add with overflow")] | ||
unconstrained fn test_overflow_add() { | ||
let a: u8 = 255; | ||
let b: u8 = 1; | ||
assert_eq(a + b, 0); | ||
} | ||
|
||
#[test(should_fail_with = "attempt to subtract with overflow")] | ||
unconstrained fn test_overflow_sub() { | ||
let a: u8 = 0; | ||
let b: u8 = 1; | ||
assert_eq(a - b, 255); | ||
} | ||
|
||
#[test(should_fail_with = "attempt to multiply with overflow")] | ||
unconstrained fn test_overflow_mul() { | ||
let a: u8 = 128; | ||
let b: u8 = 2; | ||
assert_eq(a * b, 0); | ||
} | ||
|