diff options
author | liana <liana@ethdev.com> | 2015-01-16 19:55:49 +0800 |
---|---|---|
committer | liana <liana@ethdev.com> | 2015-01-16 19:55:49 +0800 |
commit | ac77d20ee36c4d4b13d90926c0447a8cc4459edf (patch) | |
tree | 9232a729226a8310e0810345bffabf165ed5842b | |
parent | 3b7fff538943ae174282c5d02ca47a6d8167015d (diff) | |
download | dexon-solidity-ac77d20ee36c4d4b13d90926c0447a8cc4459edf.tar dexon-solidity-ac77d20ee36c4d4b13d90926c0447a8cc4459edf.tar.gz dexon-solidity-ac77d20ee36c4d4b13d90926c0447a8cc4459edf.tar.bz2 dexon-solidity-ac77d20ee36c4d4b13d90926c0447a8cc4459edf.tar.lz dexon-solidity-ac77d20ee36c4d4b13d90926c0447a8cc4459edf.tar.xz dexon-solidity-ac77d20ee36c4d4b13d90926c0447a8cc4459edf.tar.zst dexon-solidity-ac77d20ee36c4d4b13d90926c0447a8cc4459edf.zip |
Corrected "delete" for local variables i.e. set them to 0
Added test case
-rw-r--r-- | SolidityEndToEndTest.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index a733c2c4..ad537750 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -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" |