Corrected "delete" for local variables i.e. set them to 0

Added test case
This commit is contained in:
liana 2015-01-16 12:55:49 +01:00
parent 3b7fff5389
commit ac77d20ee3

View File

@ -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"