aboutsummaryrefslogtreecommitdiffstats
path: root/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SolidityEndToEndTest.cpp')
-rw-r--r--SolidityEndToEndTest.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 7edc250c..ced9785e 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -885,7 +885,7 @@ BOOST_AUTO_TEST_CASE(constructor)
BOOST_AUTO_TEST_CASE(simple_accessor)
{
char const* sourceCode = "contract test {\n"
- " uint256 data;\n"
+ " uint256 public data;\n"
" function test() {\n"
" data = 8;\n"
" }\n"
@@ -897,10 +897,10 @@ BOOST_AUTO_TEST_CASE(simple_accessor)
BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
{
char const* sourceCode = "contract test {\n"
- " uint256 data;\n"
- " string6 name;\n"
- " hash a_hash;\n"
- " address an_address;\n"
+ " uint256 public data;\n"
+ " string6 public name;\n"
+ " hash public a_hash;\n"
+ " address public an_address;\n"
" function test() {\n"
" data = 8;\n"
" name = \"Celina\";\n"
@@ -908,7 +908,6 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
" an_address = address(0x1337);\n"
" super_secret_data = 42;\n"
" }\n"
- " private:"
" uint256 super_secret_data;"
"}\n";
compileAndRun(sourceCode);
@@ -919,6 +918,27 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
BOOST_CHECK(callContractFunction("super_secret_data()") == bytes());
}
+BOOST_AUTO_TEST_CASE(complex_accessors)
+{
+ char const* sourceCode = "contract test {\n"
+ " mapping(uint256 => string4) to_string_map;\n"
+ " mapping(uint256 => bool) to_bool_map;\n"
+ " mapping(uint256 => uint256) to_uint_map;\n"
+ " mapping(uint256 => mapping(uint256 => uint256)) to_multiple_map;\n"
+ " function test() {\n"
+ " to_string_map[42] = \"24\";\n"
+ " to_bool_map[42] = false;\n"
+ " to_uint_map[42] = 12;\n"
+ " to_multiple_map[42][23] = 31;\n"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("to_string_map(uint256)", 42) == encodeArgs("24"));
+ BOOST_CHECK(callContractFunction("to_bool_map(uint256)", 42) == encodeArgs(false));
+ BOOST_CHECK(callContractFunction("to_uint_map(uint256)", 42) == encodeArgs(12));
+ BOOST_CHECK(callContractFunction("to_multiple_map(uint256,uint256)", 42, 23) == encodeArgs(31));
+}
+
BOOST_AUTO_TEST_CASE(balance)
{
char const* sourceCode = "contract test {\n"
@@ -1490,8 +1510,7 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
setName("abc");
}
function getName() returns (string3 ret) { return name; }
- private:
- function setName(string3 _name) { name = _name; }
+ function setName(string3 _name) private { name = _name; }
})";
compileAndRun(sourceCode);
BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc"));