mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Corrected "delete" for local variables i.e. set them to 0
Added test case
This commit is contained in:
parent
3b7fff5389
commit
ac77d20ee3
@ -799,8 +799,6 @@ BOOST_AUTO_TEST_CASE(deleteStruct)
|
||||
str.nstr.nestedValue = 2;
|
||||
str.nstr.nestedMapping[0] = true;
|
||||
str.nstr.nestedMapping[1] = false;
|
||||
uint v = 5;
|
||||
delete v;
|
||||
delete str;
|
||||
delete toDelete;
|
||||
}
|
||||
@ -833,6 +831,37 @@ BOOST_AUTO_TEST_CASE(deleteStruct)
|
||||
BOOST_CHECK(callContractFunction("getNestedMapping(uint256)", 1) == encodeArgs(false));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(deleteLocal)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
function delLocal() returns (uint res){
|
||||
uint v = 5;
|
||||
delete v;
|
||||
res = v;
|
||||
}
|
||||
})";
|
||||
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("delLocal()") == encodeArgs(0));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(deleteLocals)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
function delLocal() returns (uint res){
|
||||
uint v = 5;
|
||||
uint w = 6;
|
||||
delete v;
|
||||
res = w;
|
||||
}
|
||||
})";
|
||||
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("delLocal()") == encodeArgs(6));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(constructor)
|
||||
{
|
||||
char const* sourceCode = "contract test {\n"
|
||||
|
Loading…
Reference in New Issue
Block a user