mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Moving some byte array pop tests to semanticTests.
This commit is contained in:
parent
31981bad12
commit
29d480d0ed
@ -2854,81 +2854,6 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi)
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(byte_array_pop_storage_empty)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract c {
|
||||
bytes data;
|
||||
function test() public {
|
||||
data.push(0x07);
|
||||
data.push(0x05);
|
||||
data.push(0x03);
|
||||
data.pop();
|
||||
data.pop();
|
||||
data.pop();
|
||||
}
|
||||
}
|
||||
)";
|
||||
ALSO_VIA_YUL(
|
||||
DISABLE_EWASM_TESTRUN()
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(callContractFunction("test()"), encodeArgs());
|
||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract c {
|
||||
uint256 a;
|
||||
uint256 b;
|
||||
uint256 c;
|
||||
bytes data;
|
||||
function test() public returns (bool) {
|
||||
for (uint8 i = 0; i <= 40; i++)
|
||||
data.push(byte(i+1));
|
||||
for (int8 j = 40; j >= 0; j--) {
|
||||
require(data[uint8(j)] == byte(j+1));
|
||||
require(data.length == uint8(j+1));
|
||||
data.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
)";
|
||||
ALSO_VIA_YUL(
|
||||
DISABLE_EWASM_TESTRUN()
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(callContractFunction("test()"), encodeArgs(true));
|
||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty_garbage_ref)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract c {
|
||||
uint256 a;
|
||||
uint256 b;
|
||||
bytes data;
|
||||
function test() public {
|
||||
for (uint8 i = 0; i <= 40; i++)
|
||||
data.push(0x03);
|
||||
for (uint8 j = 0; j <= 40; j++) {
|
||||
assembly {
|
||||
mstore(0, "garbage")
|
||||
}
|
||||
data.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(callContractFunction("test()"), encodeArgs());
|
||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(external_array_args)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
@ -0,0 +1,21 @@
|
||||
contract c {
|
||||
uint256 a;
|
||||
uint256 b;
|
||||
uint256 c;
|
||||
bytes data;
|
||||
function test() public returns (bool) {
|
||||
for (uint8 i = 0; i <= 40; i++)
|
||||
data.push(byte(i+1));
|
||||
for (int8 j = 40; j >= 0; j--) {
|
||||
require(data[uint8(j)] == byte(j+1));
|
||||
require(data.length == uint8(j+1));
|
||||
data.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> true
|
||||
// storage: empty
|
@ -0,0 +1,20 @@
|
||||
contract c {
|
||||
uint256 a;
|
||||
uint256 b;
|
||||
bytes data;
|
||||
function test() public {
|
||||
for (uint8 i = 0; i <= 40; i++)
|
||||
data.push(0x03);
|
||||
for (uint8 j = 0; j <= 40; j++) {
|
||||
assembly {
|
||||
mstore(0, "garbage")
|
||||
}
|
||||
data.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() ->
|
||||
// storage: empty
|
@ -0,0 +1,16 @@
|
||||
contract c {
|
||||
bytes data;
|
||||
function test() public {
|
||||
data.push(0x07);
|
||||
data.push(0x05);
|
||||
data.push(0x03);
|
||||
data.pop();
|
||||
data.pop();
|
||||
data.pop();
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() ->
|
||||
// storage: empty
|
Loading…
Reference in New Issue
Block a user