forked from noir-lang/noir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(abi): Tuples as inputs/outputs to main (noir-lang#2899)
Co-authored-by: Tom French <[email protected]> Co-authored-by: Tom French <[email protected]>
- Loading branch information
Showing
8 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
tooling/nargo_cli/tests/execution_success/tuple_inputs/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 = "tuple_inputs" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.14.1" | ||
|
||
[dependencies] |
12 changes: 12 additions & 0 deletions
12
tooling/nargo_cli/tests/execution_success/tuple_inputs/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,12 @@ | ||
pair = [1, 0] | ||
x = [[0, 1, 2], [3, 4, 5]] | ||
|
||
[[struct_pair]] | ||
a = "1" | ||
b = ["2", "3", "20"] | ||
|
||
[struct_pair.bar] | ||
inner = ["100", "101", "102"] | ||
|
||
[[struct_pair]] | ||
inner = ["103", "104", "105"] |
37 changes: 37 additions & 0 deletions
37
tooling/nargo_cli/tests/execution_success/tuple_inputs/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,37 @@ | ||
struct Bar { | ||
inner: [Field; 3], | ||
} | ||
|
||
struct Foo { | ||
a: Field, | ||
b: [Field; 3], | ||
bar: Bar, | ||
} | ||
|
||
fn main(pair : (Field, Field), x: [(u8, u8, u8); 2], struct_pair: (Foo, Bar)) -> pub (Field, u8) { | ||
assert(pair.0 == 1); | ||
assert(pair.1 == 0); | ||
|
||
let mut start_val = 0; | ||
for i in 0..2 { | ||
assert(x[i].0 == start_val); | ||
assert(x[i].1 == start_val + 1); | ||
assert(x[i].2 == start_val + 2); | ||
start_val += 3; | ||
} | ||
|
||
assert(struct_pair.0.a == 1); | ||
assert(struct_pair.0.b == [2, 3, 20]); | ||
assert(struct_pair.0.bar.inner == [100, 101, 102]); | ||
assert(struct_pair.1.inner == [103, 104, 105]); | ||
|
||
let (u, v) = if pair.0 as u32 < 1 { | ||
(pair.0, pair.0 + 1) | ||
} else { | ||
(pair.0 + 1, pair.0) | ||
}; | ||
assert(u == pair.0 + 1); | ||
assert(v == pair.0); | ||
|
||
(u, v as u8) | ||
} |
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
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
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