-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: struct destructuring * feat: add print statements for debugging * debugging: add print * Add Forc.lock. * Add descriptions. * fix: remove println! statements * chore: update to latest version * feat: add not working Pattern:Struct branch to match * fix: identation in oracle json * feat: create pattern if field has none * refactor: remove debug prints * fix: warnings * test: type annotations for destructure * fix: handle type annotations * chore: run formatter * fix: remove test cargo toml * fix: destructure test case * test: nested struct destructuring * docs: add struct destructuring * refactor: fix formatting * fix: formatting * refactor examples * fix: formatting * fix: remove mention of deleted file * test: nested tuple in struct and vis versa * docs: add nested tuple in struct and vis versa to examples * fix: formatting * fix: formatting * fix: formatting * fix: formatting Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
- Loading branch information
Showing
16 changed files
with
319 additions
and
10 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
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
9 changes: 9 additions & 0 deletions
9
...src/e2e_vm_tests/test_programs/should_pass/language/nested_struct_destructuring/Forc.lock
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,9 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-F93ECA3248F311E3' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'struct_destructuring' | ||
source = 'root' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
...src/e2e_vm_tests/test_programs/should_pass/language/nested_struct_destructuring/Forc.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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "struct_destructuring" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } |
15 changes: 15 additions & 0 deletions
15
...tests/test_programs/should_pass/language/nested_struct_destructuring/json_abi_oracle.json
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,15 @@ | ||
[ | ||
{ | ||
"inputs": [], | ||
"name": "main", | ||
"outputs": [ | ||
{ | ||
"components": null, | ||
"name": "", | ||
"type": "u64", | ||
"typeArguments": null | ||
} | ||
], | ||
"type": "function" | ||
} | ||
] |
33 changes: 33 additions & 0 deletions
33
...c/e2e_vm_tests/test_programs/should_pass/language/nested_struct_destructuring/src/main.sw
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,33 @@ | ||
script; | ||
|
||
// Tests nested struct destructuring | ||
|
||
fn main() -> u64 { | ||
let tuple_in_struct = TupleInStruct { | ||
nested_tuple: (42u64, (42u32, (true, "ok") ) ), | ||
}; | ||
let TupleInStruct { nested_tuple: (a, (b, (c, d) ) ) } = tuple_in_struct; | ||
|
||
let struct_in_tuple = (Point { x: 2, y: 4, }, Point { x: 3, y: 6 }); | ||
let (Point { x: x0, y: y0 }, Point { x: x1, y: y1 }) = struct_in_tuple; | ||
|
||
let point1 = Point { x: 0, y: 0 }; | ||
let point2 = Point { x: 1, y: 1 }; | ||
let line = Line { p1: point1, p2: point2 }; | ||
let Line { p1: Point { x: x2, y: y2 }, p2: Point { x: x3, y: y3} } = line; | ||
x2 | ||
} | ||
|
||
struct Point { | ||
x: u64, | ||
y: u64, | ||
} | ||
|
||
struct Line { | ||
p1: Point, | ||
p2: Point, | ||
} | ||
|
||
struct TupleInStruct { | ||
nested_tuple: (u64, (u32, (bool, str[2]) ) ), | ||
} |
3 changes: 3 additions & 0 deletions
3
...src/e2e_vm_tests/test_programs/should_pass/language/nested_struct_destructuring/test.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,3 @@ | ||
category = "run" | ||
expected_result = { action = "return", value = 0 } | ||
validate_abi = true |
9 changes: 9 additions & 0 deletions
9
test/src/e2e_vm_tests/test_programs/should_pass/language/struct_destructuring/Forc.lock
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,9 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-F93ECA3248F311E3' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'struct_destructuring' | ||
source = 'root' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/language/struct_destructuring/Forc.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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "struct_destructuring" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } |
15 changes: 15 additions & 0 deletions
15
...e2e_vm_tests/test_programs/should_pass/language/struct_destructuring/json_abi_oracle.json
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,15 @@ | ||
[ | ||
{ | ||
"inputs": [], | ||
"name": "main", | ||
"outputs": [ | ||
{ | ||
"components": null, | ||
"name": "", | ||
"type": "u64", | ||
"typeArguments": null | ||
} | ||
], | ||
"type": "function" | ||
} | ||
] |
Oops, something went wrong.