-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: split conditional_regression tests (#2774)
- Loading branch information
Showing
19 changed files
with
243 additions
and
156 deletions.
There are no files selected for viewing
155 changes: 0 additions & 155 deletions
155
tooling/nargo_cli/tests/execution_success/conditional_3_regression/src/main.nr
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ccess/conditional_3_regression/Nargo.toml → ...ess/conditional_regression_421/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
2 changes: 2 additions & 0 deletions
2
tooling/nargo_cli/tests/execution_success/conditional_regression_421/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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
c=[2, 4, 3, 0, ] | ||
a=0 |
14 changes: 14 additions & 0 deletions
14
tooling/nargo_cli/tests/execution_success/conditional_regression_421/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,14 @@ | ||
fn main(a: u32, mut c: [u32; 4]){ | ||
//Issue reported in #421 | ||
if a == c[0] { | ||
assert(c[0] == 0); | ||
} else { | ||
if a == c[1] { | ||
assert(c[1] == 0); | ||
} else { | ||
if a == c[2] { | ||
assert(c[2] == 0); | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tooling/nargo_cli/tests/execution_success/conditional_regression_547/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 = "conditional_regression_547" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
Empty file.
23 changes: 23 additions & 0 deletions
23
tooling/nargo_cli/tests/execution_success/conditional_regression_547/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 @@ | ||
fn main() -> pub Field { | ||
// Regression test for issue #547 | ||
// Warning: it must be kept at the start of main | ||
let arr: [u8; 2] = [1, 2]; | ||
if arr[0] != arr[1] { | ||
for i in 0..1 { | ||
assert(i != 2); | ||
} | ||
} | ||
|
||
// Regression for predicate simplification | ||
safe_inverse(0) | ||
} | ||
|
||
fn safe_inverse(n: Field) -> Field | ||
{ | ||
if n == 0 { | ||
0 | ||
} | ||
else { | ||
1 / n | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tooling/nargo_cli/tests/execution_success/conditional_regression_579/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 = "conditional_regression_579" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
Empty file.
28 changes: 28 additions & 0 deletions
28
tooling/nargo_cli/tests/execution_success/conditional_regression_579/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,28 @@ | ||
fn main(){ | ||
//Regression for Issue #579 | ||
let result1_true = test(true); | ||
assert(result1_true.array_param[0] == 1); | ||
let result1_false = test(false); | ||
assert(result1_false.array_param[0] == 0); | ||
} | ||
|
||
struct MyStruct579 { | ||
array_param: [u32; 2] | ||
} | ||
|
||
impl MyStruct579 { | ||
fn new(array_param: [u32; 2]) -> MyStruct579 { | ||
MyStruct579 { | ||
array_param: array_param | ||
} | ||
} | ||
} | ||
|
||
fn test(flag: bool) -> MyStruct579 { | ||
let mut my_struct = MyStruct579::new([0; 2]); | ||
|
||
if flag == true { | ||
my_struct= MyStruct579::new([1; 2]); | ||
} | ||
my_struct | ||
} |
7 changes: 7 additions & 0 deletions
7
tooling/nargo_cli/tests/execution_success/conditional_regression_661/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 = "conditional_regression_661" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
File renamed without changes.
29 changes: 29 additions & 0 deletions
29
tooling/nargo_cli/tests/execution_success/conditional_regression_661/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,29 @@ | ||
fn main(a: u32, mut c: [u32; 4]){ | ||
// Regression for issue #661: | ||
let mut c_661 :[u32;1]=[0]; | ||
if a > 5 { | ||
c_661 = issue_661_foo(issue_661_bar(c), a); | ||
} else { | ||
c_661 = issue_661_foo(issue_661_bar(c), a + 2); | ||
} | ||
assert(c_661[0] < 20000); | ||
} | ||
|
||
fn test5(a : u32) { | ||
if a > 1 { | ||
let q = a / 2; | ||
assert(q == 2); | ||
} | ||
} | ||
|
||
|
||
fn issue_661_foo(array: [u32;4], b:u32) ->[u32;1] { | ||
[array[0]+b] | ||
} | ||
|
||
fn issue_661_bar(a : [u32;4]) ->[u32;4] { | ||
let mut b:[u32;4] = [0;4]; | ||
b[0]=a[0]+1; | ||
b | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
tooling/nargo_cli/tests/execution_success/conditional_regression_short_circuit/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 = "conditional_regression_short_circuit" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
38 changes: 38 additions & 0 deletions
38
tooling/nargo_cli/tests/execution_success/conditional_regression_short_circuit/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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
c=[2, 4, 3, 0, ] | ||
a=0 | ||
x = [104, 101, 108, 108, 111] | ||
|
||
result = [ | ||
0x2c, | ||
0xf2, | ||
0x4d, | ||
0xba, | ||
0x5f, | ||
0xb0, | ||
0xa3, | ||
0x0e, | ||
0x26, | ||
0xe8, | ||
0x3b, | ||
0x2a, | ||
0xc5, | ||
0xb9, | ||
0xe2, | ||
0x9e, | ||
0x1b, | ||
0x16, | ||
0x1e, | ||
0x5c, | ||
0x1f, | ||
0xa7, | ||
0x42, | ||
0x5e, | ||
0x73, | ||
0x04, | ||
0x33, | ||
0x62, | ||
0x93, | ||
0x8b, | ||
0x98, | ||
0x24, | ||
] |
41 changes: 41 additions & 0 deletions
41
tooling/nargo_cli/tests/execution_success/conditional_regression_short_circuit/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,41 @@ | ||
use dep::std; | ||
|
||
fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]){ | ||
//regression for short-circuit2 | ||
if 35 == a { | ||
assert(false); | ||
} | ||
bar(a as Field); | ||
|
||
if a == 3 { | ||
c = test4(); | ||
} | ||
assert(c[1] != 2); | ||
call_intrinsic(x, result); | ||
} | ||
|
||
|
||
|
||
fn foo() { | ||
let mut x = 1; | ||
x /= 0; | ||
} | ||
|
||
fn bar(x:Field) { | ||
if x == 15 { | ||
foo(); | ||
} | ||
} | ||
|
||
|
||
fn call_intrinsic(x: [u8; 5], result: [u8; 32]) { | ||
let mut digest = std::hash::sha256(x); | ||
digest[0] = 5 as u8; | ||
digest = std::hash::sha256(x); | ||
assert(digest == result); | ||
} | ||
|
||
fn test4() -> [u32; 4] { | ||
let b: [u32; 4] = [1,2,3,4]; | ||
b | ||
} |
7 changes: 7 additions & 0 deletions
7
tooling/nargo_cli/tests/execution_success/conditional_regression_to_bits/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 = "cconditional_regression_to_bits" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
Empty file.
Oops, something went wrong.