mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Enable C99-scoping with the 0.5.0-experimental pragma.
This commit is contained in:
@@ -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) _; }
|
||||
}
|
||||
)";
|
||||
|
||||
Reference in New Issue
Block a user