aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index be042655..8586ebf8 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -84,16 +84,45 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration)
}
}
)";
+ CHECK_ERROR(text, DeclarationError, "Identifier already declared");
+}
+
+BOOST_AUTO_TEST_CASE(double_variable_declaration_050)
+{
+ string text = R"(
+ pragma experimental "v0.5.0";
+ contract test {
+ function f() pure public {
+ uint256 x;
+ if (true) { uint256 x; }
+ }
+ }
+ )";
CHECK_WARNING_ALLOW_MULTI(text, (vector<string>{
"This declaration shadows an existing declaration.",
+ "Experimental features",
"Unused local variable",
"Unused local variable"
}));
}
+BOOST_AUTO_TEST_CASE(scoping_old)
+{
+ char const* text = R"(
+ contract test {
+ function f() pure public {
+ x = 4;
+ uint256 x = 2;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+}
+
BOOST_AUTO_TEST_CASE(scoping)
{
char const* text = R"(
+ pragma experimental "v0.5.0";
contract test {
function f() public {
{
@@ -109,6 +138,7 @@ BOOST_AUTO_TEST_CASE(scoping)
BOOST_AUTO_TEST_CASE(scoping_for)
{
char const* text = R"(
+ pragma experimental "v0.5.0";
contract test {
function f() public {
for (uint x = 0; x < 10; x ++){
@@ -123,6 +153,7 @@ BOOST_AUTO_TEST_CASE(scoping_for)
BOOST_AUTO_TEST_CASE(scoping_for2)
{
char const* text = R"(
+ pragma experimental "v0.5.0";
contract test {
function f() public {
for (uint x = 0; x < 10; x ++){
@@ -1052,7 +1083,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation)
{
char const* text = R"(
contract B {
- function f() mod1(2, true) mod2("0123456") public { }
+ function f() mod1(2, true) mod2("0123456") pure public { }
modifier mod1(uint a, bool b) { if (b) _; }
modifier mod2(bytes7 a) { while (a == "1234567") _; }
}
@@ -1087,7 +1118,19 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables)
{
char const* text = R"(
contract B {
- function f() mod(x) public { uint x = 7; }
+ function f() mod(x) pure public { uint x = 7; }
+ modifier mod(uint a) { if (a > 0) _; }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+}
+
+BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables050)
+{
+ char const* text = R"(
+ pragma experimental "v0.5.0";
+ contract B {
+ function f() mod(x) pure public { uint x = 7; }
modifier mod(uint a) { if (a > 0) _; }
}
)";