-
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: left-to-right function/tuple/struct arguments evaluation
- Loading branch information
1 parent
e9e7578
commit 332a240
Showing
5 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
..._vm_tests/test_programs/should_pass/language/left_to_right_func_args_evaluation/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,8 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-88DBE1D69186ED7B' | ||
|
||
[[package]] | ||
name = 'left_to_right_arg_evaluation' | ||
source = 'member' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
..._vm_tests/test_programs/should_pass/language/left_to_right_func_args_evaluation/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 <[email protected]>"] | ||
license = "Apache-2.0" | ||
name = "left_to_right_arg_evaluation" | ||
entry = "main.sw" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } |
22 changes: 22 additions & 0 deletions
22
...est_programs/should_pass/language/left_to_right_func_args_evaluation/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,22 @@ | ||
{ | ||
"functions": [ | ||
{ | ||
"inputs": [], | ||
"name": "main", | ||
"output": { | ||
"name": "", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
} | ||
], | ||
"loggedTypes": [], | ||
"types": [ | ||
{ | ||
"components": null, | ||
"type": "bool", | ||
"typeId": 0, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
75 changes: 75 additions & 0 deletions
75
...m_tests/test_programs/should_pass/language/left_to_right_func_args_evaluation/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,75 @@ | ||
script; | ||
// This tests function, tuple, struct arguments are evaluated from left to right | ||
|
||
fn func(a: u64, b: u64, c: u64, d: u64) -> u64 { | ||
d | ||
} | ||
|
||
struct MyStruct { | ||
a: u64, | ||
b: u64, | ||
c: u64, | ||
d: u64, | ||
} | ||
|
||
fn main() -> bool { | ||
let mut x: u64 = 0; | ||
|
||
// function arguments evaluation | ||
let func_res = | ||
func( | ||
{ | ||
x = 1; | ||
0 | ||
}, | ||
{ | ||
x = 2; | ||
0 | ||
}, | ||
{ | ||
x = 3; | ||
0 | ||
}, | ||
x | ||
); | ||
|
||
// tuple evaluation | ||
x = 0; | ||
let tuple_res = | ||
( | ||
{ | ||
x = 1; | ||
0 | ||
}, | ||
{ | ||
x = 2; | ||
1 | ||
}, | ||
{ | ||
x = 3; | ||
2 | ||
}, | ||
x | ||
); | ||
|
||
// struct evaluation | ||
x = 0; | ||
let struct_res = | ||
MyStruct { | ||
a: { | ||
x = 1; | ||
0 | ||
}, | ||
b: { | ||
x = 2; | ||
1 | ||
}, | ||
c: { | ||
x = 3; | ||
2 | ||
}, | ||
d: x | ||
}; | ||
|
||
return (func_res == 3) && (tuple_res.3 == 3) && (struct_res.d == 3); | ||
} |
3 changes: 3 additions & 0 deletions
3
..._vm_tests/test_programs/should_pass/language/left_to_right_func_args_evaluation/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 = 1 } | ||
validate_abi = true |