Skip to content

Commit

Permalink
Adding semantic tests for bytes to bytesNN conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
mijovic committed Mar 4, 2021
1 parent dbf21e9 commit de8e09f
Showing 1 changed file with 28 additions and 0 deletions.
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"

0 comments on commit de8e09f

Please sign in to comment.