-
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.
## Description This PR recover configurable tests that were deleted by mistake. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
- Loading branch information
1 parent
9db4fe7
commit d8e57f3
Showing
3 changed files
with
327 additions
and
9 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
73 changes: 71 additions & 2 deletions
73
test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/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 |
---|---|---|
@@ -1,9 +1,78 @@ | ||
script; | ||
|
||
use std::hash::*; | ||
|
||
struct ConfigurableStruct { | ||
a: bool, | ||
b: u64, | ||
} | ||
|
||
enum ConfigurableEnum { | ||
A: bool, | ||
B: u64, | ||
} | ||
|
||
impl core::ops::Eq for ConfigurableEnum { | ||
fn eq(self, other: ConfigurableEnum) -> bool { | ||
match (self, other) { | ||
(ConfigurableEnum::A(inner1), ConfigurableEnum::A(inner2)) => inner1 == inner2, | ||
(ConfigurableEnum::B(inner1), ConfigurableEnum::B(inner2)) => inner1 == inner2, | ||
_ => false, | ||
} | ||
} | ||
} | ||
|
||
type AnotherU8 = u8; | ||
|
||
configurable { | ||
BOOL: bool = true, | ||
U8: u8 = 1, | ||
ANOTHER_U8: AnotherU8 = 3, | ||
U16: u16 = 2, | ||
U32: u32 = 3, | ||
U64: u32 = 4, | ||
U256: u256 = 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAu256, | ||
B256: b256 = 0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB, | ||
CONFIGURABLE_STRUCT: ConfigurableStruct = ConfigurableStruct { a: true, b: 5 }, | ||
CONFIGURABLE_ENUM_A: ConfigurableEnum = ConfigurableEnum::A(true), | ||
CONFIGURABLE_ENUM_B: ConfigurableEnum = ConfigurableEnum::B(12), | ||
ARRAY_BOOL: [bool; 3] = [true, false, true], | ||
ARRAY_U64: [u64; 3] = [9, 8, 7], | ||
TUPLE_BOOL_U64: (bool, u64) = (true, 11), | ||
STR_4: str[4] = __to_str_array("abcd"), | ||
|
||
NOT_USED: u8 = 1 | ||
} | ||
|
||
fn main() { | ||
assert(BOOL == true); | ||
} | ||
assert(U8 == 1); | ||
assert(ANOTHER_U8 == 3); | ||
assert(U16 == 2); | ||
assert(U32 == 3); | ||
assert(U64 == 4); | ||
assert(U256 == 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAu256); | ||
assert(B256 == 0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB); | ||
assert(CONFIGURABLE_STRUCT.a == true); | ||
assert(CONFIGURABLE_STRUCT.b == 5); | ||
assert(CONFIGURABLE_ENUM_A == ConfigurableEnum::A(true)); | ||
assert(CONFIGURABLE_ENUM_B == ConfigurableEnum::B(12)); | ||
assert(ARRAY_BOOL[0] == true); | ||
assert(ARRAY_BOOL[1] == false); | ||
assert(ARRAY_BOOL[2] == true); | ||
assert(ARRAY_U64[0] == 9); | ||
assert(ARRAY_U64[1] == 8); | ||
assert(ARRAY_U64[2] == 7); | ||
assert(TUPLE_BOOL_U64.0 == true); | ||
assert(TUPLE_BOOL_U64.1 == 11); | ||
assert(sha256_str_array(STR_4) == sha256("abcd")); | ||
|
||
// Assert address do not change | ||
let addr_1 = asm(addr: __addr_of(&BOOL)) { | ||
addr: u64 | ||
}; | ||
let addr_2 = asm(addr: __addr_of(&BOOL)) { | ||
addr: u64 | ||
}; | ||
assert(addr_1 == addr_2); | ||
} |
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