aboutsummaryrefslogtreecommitdiffstats
path: root/SolidityParser.cpp
diff options
context:
space:
mode:
authorCJentzsch <jentzsch.software@gmail.com>2015-02-06 05:43:29 +0800
committerCJentzsch <jentzsch.software@gmail.com>2015-02-06 05:43:29 +0800
commit1298b8605cb45914ae700aaae942dc4bab9b9ac2 (patch)
treed2956f1731d68c41f054ff6927a972f2a7dd0143 /SolidityParser.cpp
parentcbfd094a17212da0d81d10b99416e240c5e7c625 (diff)
parent969366f46b83c57461fc5399fff76bd07738b6f2 (diff)
downloaddexon-solidity-1298b8605cb45914ae700aaae942dc4bab9b9ac2.tar
dexon-solidity-1298b8605cb45914ae700aaae942dc4bab9b9ac2.tar.gz
dexon-solidity-1298b8605cb45914ae700aaae942dc4bab9b9ac2.tar.bz2
dexon-solidity-1298b8605cb45914ae700aaae942dc4bab9b9ac2.tar.lz
dexon-solidity-1298b8605cb45914ae700aaae942dc4bab9b9ac2.tar.xz
dexon-solidity-1298b8605cb45914ae700aaae942dc4bab9b9ac2.tar.zst
dexon-solidity-1298b8605cb45914ae700aaae942dc4bab9b9ac2.zip
Merge remote-tracking branch 'upstream/develop' into RefundOverflow
Diffstat (limited to 'SolidityParser.cpp')
-rw-r--r--SolidityParser.cpp49
1 files changed, 44 insertions, 5 deletions
diff --git a/SolidityParser.cpp b/SolidityParser.cpp
index 4adee9c6..9ba38a4a 100644
--- a/SolidityParser.cpp
+++ b/SolidityParser.cpp
@@ -124,14 +124,30 @@ BOOST_AUTO_TEST_CASE(single_function_param)
BOOST_CHECK_NO_THROW(parseText(text));
}
+BOOST_AUTO_TEST_CASE(missing_parameter_name_in_named_args)
+{
+ char const* text = "contract test {\n"
+ " function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n"
+ " function b() returns (uint r) { r = a({: 1, : 2, : 3}); }\n"
+ "}\n";
+ BOOST_CHECK_THROW(parseText(text), ParserError);
+}
+
+BOOST_AUTO_TEST_CASE(missing_argument_in_named_args)
+{
+ char const* text = "contract test {\n"
+ " function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n"
+ " function b() returns (uint r) { r = a({a: , b: , c: }); }\n"
+ "}\n";
+ BOOST_CHECK_THROW(parseText(text), ParserError);
+}
+
BOOST_AUTO_TEST_CASE(function_natspec_documentation)
{
ASTPointer<ContractDefinition> contract;
ASTPointer<FunctionDefinition> function;
char const* text = "contract test {\n"
- " private:\n"
- " uint256 stateVar;\n"
- " public:\n"
+ " uint256 stateVar;\n"
" /// This is a test function\n"
" function functionName(hash hashin) returns (hash hashout) {}\n"
"}\n";
@@ -162,9 +178,7 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation)
ASTPointer<ContractDefinition> contract;
ASTPointer<FunctionDefinition> function;
char const* text = "contract test {\n"
- " private:\n"
" uint256 stateVar;\n"
- " public:\n"
" /// This is test function 1\n"
" function functionName1(hash hashin) returns (hash hashout) {}\n"
" /// This is test function 2\n"
@@ -621,6 +635,31 @@ BOOST_AUTO_TEST_CASE(event_arguments_indexed)
BOOST_CHECK_NO_THROW(parseText(text));
}
+BOOST_AUTO_TEST_CASE(visibility_specifiers)
+{
+ char const* text = R"(
+ contract c {
+ uint private a;
+ uint protected b;
+ uint public c;
+ uint d;
+ function f() {}
+ function f_priv() private {}
+ function f_public() public {}
+ function f_protected() protected {}
+ })";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
+BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
+{
+ char const* text = R"(
+ contract c {
+ uint private protected a;
+ })";
+ BOOST_CHECK_THROW(parseText(text), ParserError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}