mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Split shift bytes test.
This commit is contained in:
parent
86051dc099
commit
52511a2163
@ -4427,27 +4427,6 @@ BOOST_AUTO_TEST_CASE(shift_bytes)
|
|||||||
ABI_CHECK(callContractFunction("right(bytes20,uint8)", "12345678901234567890", 8 * 8), encodeArgs(string(8, 0) + "123456789012"));
|
ABI_CHECK(callContractFunction("right(bytes20,uint8)", "12345678901234567890", 8 * 8), encodeArgs(string(8, 0) + "123456789012"));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(shift_bytes_cleanup)
|
|
||||||
{
|
|
||||||
char const* sourceCode = R"(
|
|
||||||
contract C {
|
|
||||||
function left(uint8 y) public returns (bytes20) {
|
|
||||||
bytes20 x;
|
|
||||||
assembly { x := "12345678901234567890abcde" }
|
|
||||||
return x << y;
|
|
||||||
}
|
|
||||||
function right(uint8 y) public returns (bytes20) {
|
|
||||||
bytes20 x;
|
|
||||||
assembly { x := "12345678901234567890abcde" }
|
|
||||||
return x >> y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
compileAndRun(sourceCode, 0, "C");
|
|
||||||
ABI_CHECK(callContractFunction("left(uint8)", 8 * 8), encodeArgs("901234567890" + string(8, 0)));
|
|
||||||
ABI_CHECK(callContractFunction("right(uint8)", 8 * 8), encodeArgs(string(8, 0) + "123456789012"));
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(contracts_separated_with_comment)
|
BOOST_AUTO_TEST_CASE(contracts_separated_with_comment)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
contract C {
|
||||||
|
function l(uint8 y) public returns (bytes20) {
|
||||||
|
bytes20 x;
|
||||||
|
assembly { x := "12345678901234567890abcde" }
|
||||||
|
// When compiling via IR, `x` is truncated before applying
|
||||||
|
// the operation.
|
||||||
|
return x << y;
|
||||||
|
}
|
||||||
|
function r(uint8 y) public returns (bytes20) {
|
||||||
|
bytes20 x;
|
||||||
|
assembly { x := "12345678901234567890abcde" }
|
||||||
|
return x >> y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: false
|
||||||
|
// ----
|
||||||
|
// l(uint8): 64 -> 0x3930313233343536373839300000000000000000000000000000000000000000
|
||||||
|
// r(uint8): 64 -> 0x313233343536373839303132000000000000000000000000
|
@ -0,0 +1,19 @@
|
|||||||
|
contract C {
|
||||||
|
function l(uint8 y) public returns (bytes20) {
|
||||||
|
bytes20 x;
|
||||||
|
assembly { x := "12345678901234567890abcde" }
|
||||||
|
// When compiling via IR, `x` is truncated before applying
|
||||||
|
// the operation.
|
||||||
|
return x << y;
|
||||||
|
}
|
||||||
|
function r(uint8 y) public returns (bytes20) {
|
||||||
|
bytes20 x;
|
||||||
|
assembly { x := "12345678901234567890abcde" }
|
||||||
|
return x >> y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: true
|
||||||
|
// ----
|
||||||
|
// l(uint8): 64 -> 0x3930313233343536373839306162636465000000000000000000000000000000
|
||||||
|
// r(uint8): 64 -> 0x313233343536373839303132000000000000000000000000
|
Loading…
Reference in New Issue
Block a user