-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding semantic tests for bytes to bytesNN conversion.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_simple.sol
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,28 @@ | ||
contract C { | ||
bytes s = "abcdefghabcdefgh"; | ||
bytes sLong = "abcdefghabcdefghabcdefghabcdefgh"; | ||
|
||
function fromMemory(bytes memory m) public returns (bytes16) { | ||
return bytes16(m); | ||
} | ||
function fromCalldata(bytes calldata c) external returns (bytes16) { | ||
return bytes16(c); | ||
} | ||
function fromStorage() external returns (bytes16) { | ||
return bytes16(s); | ||
} | ||
function fromStorageLong() external returns (bytes32) { | ||
return bytes32(sLong); | ||
} | ||
function fromSlice(bytes calldata c) external returns (bytes8) { | ||
return bytes8(c[8:]); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// fromMemory(bytes): 0x20, 16, "abcdefghabcdefgh" -> "abcdefghabcdefgh" | ||
// fromCalldata(bytes): 0x20, 16, "abcdefghabcdefgh" -> "abcdefghabcdefgh" | ||
// fromStorage() -> "abcdefghabcdefgh" | ||
// fromStorageLong() -> "abcdefghabcdefghabcdefghabcdefgh" | ||
// fromSlice(bytes): 0x20, 16, "abcdefghabcdefgh" -> "abcdefgh" |