aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-08 03:07:55 +0800
committerchriseth <c@ethdev.com>2016-11-16 21:37:18 +0800
commitb6992d740a849d28f7c2a52bef0ba6b3740c9179 (patch)
tree794c3ae8d0b608c02d4dc946d9ae3393deda19c8 /test/libsolidity/SolidityEndToEndTest.cpp
parent3158a8ea7b06888472b09ac4bc5f6a5a2f7ae2ce (diff)
downloaddexon-solidity-b6992d740a849d28f7c2a52bef0ba6b3740c9179.tar.gz
dexon-solidity-b6992d740a849d28f7c2a52bef0ba6b3740c9179.tar.zst
dexon-solidity-b6992d740a849d28f7c2a52bef0ba6b3740c9179.zip
Tests for uninitialized storage functions.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 7dbadc48..44dba9b2 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -7629,6 +7629,29 @@ BOOST_AUTO_TEST_CASE(calling_uninitialized_function)
BOOST_CHECK(callContractFunction("extern()") == encodeArgs());
}
+BOOST_AUTO_TEST_CASE(calling_uninitialized_function_in_detail)
+{
+ // Storage default value of zero would be correct jump dest, this tests that
+ // that is properly handled.
+ char const* sourceCode = R"(
+ contract C {
+ function() internal returns (uint) x;
+ int mutex;
+ function t() returns (uint) {
+ if (mutex > 0)
+ return 7;
+ mutex = 1;
+ // If this test fails, it will jump to "0" and re-execute this function.
+ x();
+ return 2;
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("t()") == encodeArgs());
+}
+
BOOST_AUTO_TEST_CASE(pass_function_types_internally)
{
char const* sourceCode = R"(
@@ -7949,7 +7972,7 @@ BOOST_AUTO_TEST_CASE(function_delete)
y = a;
return y();
}
- funciton d() returns (uint) {
+ function d() returns (uint) {
delete y;
return 1;
}
@@ -7988,6 +8011,35 @@ BOOST_AUTO_TEST_CASE(copy_function_storage_array)
BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(7)));
}
+BOOST_AUTO_TEST_CASE(copy_internal_function_array_to_storage)
+{
+ // This has to apply NOT to the functions because encoding in storage
+ // is different than encoding in memory.
+ char const* sourceCode = R"(
+ contract C {
+ function() internal returns (uint)[20] x;
+ int mutex;
+ function one() returns (uint) {
+ function() internal returns (uint)[20] xmem;
+ x = xmem;
+ return 3;
+ }
+ function two() returns (uint) {
+ if (mutex > 0)
+ return 7;
+ mutex = 1;
+ // If this test fails, it will jump to "0" and re-execute this function.
+ x[0]();
+ return 2;
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("one()") == encodeArgs(u256(3)));
+ BOOST_CHECK(callContractFunction("two()") == encodeArgs());
+}
+
BOOST_AUTO_TEST_CASE(shift_constant_left)
{
char const* sourceCode = R"(