-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Grant Wuerker
committed
Apr 21, 2023
1 parent
1ecc244
commit bab958e
Showing
20 changed files
with
266 additions
and
189 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
11 changes: 0 additions & 11 deletions
11
crates/test-files/fixtures/features/address_bytes10_map.fe
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
type Bytes10 = Array<u8, 10> | ||
|
||
contract Foo { | ||
bar: Map<address, Bytes10> | ||
|
||
pub fn read_bar(self, key: address) -> Bytes10 { | ||
return self.bar[key].to_mem() | ||
} | ||
|
||
pub fn write_bar(mut self, key: address, value: Bytes10) { | ||
self.bar[key] = value | ||
} | ||
} | ||
|
||
#test | ||
unsafe fn test_foo() { | ||
let mut ctx: Context = Context() | ||
let mut foo: Foo = Foo.create(ctx, 0) | ||
|
||
let address1: address = address(0x01) | ||
let address2: address = address(0x02) | ||
let bytes1: Bytes10 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | ||
let bytes2: Bytes10 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19] | ||
|
||
foo.write_bar(key: address1, value: bytes1) | ||
foo.write_bar(key: address2, value: bytes2) | ||
|
||
assert bytes10_eq(foo.read_bar(key: address1), bytes1) | ||
assert bytes10_eq(foo.read_bar(key: address2), bytes2) | ||
} | ||
|
||
fn bytes10_eq(_ a: Bytes10, _ b: Bytes10) -> bool { | ||
let mut i: u256 = 0 | ||
|
||
while i < 10 { | ||
if a[i] != b[i] { | ||
return false | ||
} | ||
i += 1 | ||
} | ||
|
||
return true | ||
} |
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,19 @@ | ||
#test | ||
fn foo() { | ||
let mut my_array: Array<u256, 4> = [8; 4] | ||
my_array[1] = 42 | ||
assert my_array[0] == 8 | ||
assert my_array[1] == 42 | ||
assert my_array[2] == 8 | ||
assert my_array[3] == 8 | ||
} | ||
|
||
#test | ||
fn bar() { | ||
let mut my_array: Array<(u256, u256), 2> = [(1, 0); 2] | ||
my_array[0].item0 = 4 | ||
assert my_array[0].item0 == 4 | ||
assert my_array[0].item1 == 0 | ||
assert my_array[1].item0 == 1 | ||
assert my_array[2].item1 == 0 | ||
} |
Oops, something went wrong.