Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 73615c4

Browse files
committedMar 25, 2020
Remove some extracted test-cases.
- remove correctly_initialize_memory_array_in_constructor.sol and create_memory_array_allocation_size.sol, because there seem to be no way to disable Yul optimizer
1 parent ea1317e commit 73615c4

File tree

3 files changed

+57
-52
lines changed

3 files changed

+57
-52
lines changed
 

‎test/libsolidity/SolidityEndToEndTest.cpp

+57
Original file line numberDiff line numberDiff line change
@@ -5005,6 +5005,33 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
50055005
BOOST_CHECK_EQUAL(balanceAt(libraryAddress), 0);
50065006
}
50075007

5008+
BOOST_AUTO_TEST_CASE(create_memory_array_allocation_size)
5009+
{
5010+
// Check allocation size of byte array. Should be 32 plus length rounded up to next
5011+
// multiple of 32
5012+
char const* sourceCode = R"(
5013+
contract C {
5014+
function f() public pure returns (uint d1, uint d2, uint d3, uint memsize) {
5015+
bytes memory b1 = new bytes(31);
5016+
bytes memory b2 = new bytes(32);
5017+
bytes memory b3 = new bytes(256);
5018+
bytes memory b4 = new bytes(31);
5019+
assembly {
5020+
d1 := sub(b2, b1)
5021+
d2 := sub(b3, b2)
5022+
d3 := sub(b4, b3)
5023+
memsize := msize()
5024+
}
5025+
}
5026+
}
5027+
)";
5028+
if (!m_optimiserSettings.runYulOptimiser)
5029+
{
5030+
compileAndRun(sourceCode);
5031+
ABI_CHECK(callContractFunction("f()"), encodeArgs(0x40, 0x40, 0x20 + 256, 0x260));
5032+
}
5033+
}
5034+
50085035
BOOST_AUTO_TEST_CASE(using_for_function_on_int)
50095036
{
50105037
char const* sourceCode = R"(
@@ -5202,6 +5229,36 @@ BOOST_AUTO_TEST_CASE(failed_create)
52025229
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(1)));
52035230
}
52045231

5232+
BOOST_AUTO_TEST_CASE(correctly_initialize_memory_array_in_constructor)
5233+
{
5234+
// Memory arrays are initialized using calldatacopy past the size of the calldata.
5235+
// This test checks that it also works in the constructor context.
5236+
char const* sourceCode = R"(
5237+
contract C {
5238+
bool public success;
5239+
constructor() public {
5240+
// Make memory dirty.
5241+
assembly {
5242+
for { let i := 0 } lt(i, 64) { i := add(i, 1) } {
5243+
mstore(msize(), not(0))
5244+
}
5245+
}
5246+
uint16[3] memory c;
5247+
require(c[0] == 0 && c[1] == 0 && c[2] == 0);
5248+
uint16[] memory x = new uint16[](3);
5249+
require(x[0] == 0 && x[1] == 0 && x[2] == 0);
5250+
success = true;
5251+
}
5252+
}
5253+
)";
5254+
// Cannot run against yul optimizer because of msize
5255+
if (!m_optimiserSettings.runYulOptimiser)
5256+
{
5257+
compileAndRun(sourceCode, 0, "C");
5258+
ABI_CHECK(callContractFunction("success()"), encodeArgs(u256(1)));
5259+
}
5260+
}
5261+
52055262
BOOST_AUTO_TEST_CASE(mutex)
52065263
{
52075264
char const* sourceCode = R"(

‎test/libsolidity/semanticTests/extracted/correctly_initialize_memory_array_in_constructor.sol

-28
This file was deleted.

‎test/libsolidity/semanticTests/extracted/create_memory_array_allocation_size.sol

-24
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.