aboutsummaryrefslogtreecommitdiffstats
path: root/SolidityParser.cpp
diff options
context:
space:
mode:
authorGav Wood <g@ethdev.com>2015-02-23 22:19:07 +0800
committerGav Wood <g@ethdev.com>2015-02-23 22:19:07 +0800
commit55cb6e31f5a3b73f612cccc82625a2c82377477f (patch)
treee3d941d0e8d3d56f73cff51f4ec7ebf60758277e /SolidityParser.cpp
parentcd9262badfd1cd7425469d0eba94a5109c20960a (diff)
parent9798d700dd27f87a33e3e251e812e9d62e4c9f18 (diff)
downloaddexon-solidity-55cb6e31f5a3b73f612cccc82625a2c82377477f.tar.gz
dexon-solidity-55cb6e31f5a3b73f612cccc82625a2c82377477f.tar.zst
dexon-solidity-55cb6e31f5a3b73f612cccc82625a2c82377477f.zip
Merge pull request #1100 from chriseth/sol_arrays
Parsing support for arrays.
Diffstat (limited to 'SolidityParser.cpp')
-rw-r--r--SolidityParser.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/SolidityParser.cpp b/SolidityParser.cpp
index 69bbc6e0..75eba8bc 100644
--- a/SolidityParser.cpp
+++ b/SolidityParser.cpp
@@ -480,6 +480,18 @@ BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion)
char const* text = "contract test {\n"
" function fun() {\n"
" uint64(2);\n"
+ " uint64[7](3);\n"
+ " uint64[](3);\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
+BOOST_AUTO_TEST_CASE(type_conversion_to_dynamic_array)
+{
+ char const* text = "contract test {\n"
+ " function fun() {\n"
+ " var x = uint64[](3);\n"
" }\n"
"}\n";
BOOST_CHECK_NO_THROW(parseText(text));
@@ -753,6 +765,45 @@ BOOST_AUTO_TEST_CASE(external_variable)
BOOST_CHECK_THROW(parseText(text), ParserError);
}
+BOOST_AUTO_TEST_CASE(arrays_in_storage)
+{
+ char const* text = R"(
+ contract c {
+ uint[10] a;
+ uint[] a2;
+ struct x { uint[2**20] b; y[0] c; }
+ struct y { uint d; mapping(uint=>x)[] e; }
+ })";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
+BOOST_AUTO_TEST_CASE(arrays_in_events)
+{
+ char const* text = R"(
+ contract c {
+ event e(uint[10] a, string7[8] indexed b, c[3] x);
+ })";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
+BOOST_AUTO_TEST_CASE(arrays_in_expressions)
+{
+ char const* text = R"(
+ contract c {
+ function f() { c[10] a = 7; uint8[10 * 2] x; }
+ })";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
+BOOST_AUTO_TEST_CASE(multi_arrays)
+{
+ char const* text = R"(
+ contract c {
+ mapping(uint => mapping(uint => int8)[8][][9])[] x;
+ })";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}