mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for new scoping behaviour.
This commit is contained in:
parent
69f5f2eb65
commit
0005990382
@ -91,6 +91,50 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration)
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(scoping)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
function f() public {
|
||||||
|
{
|
||||||
|
uint256 x;
|
||||||
|
}
|
||||||
|
x = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(text, DeclarationError, "Undeclared identifier");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(scoping_for)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
function f() public {
|
||||||
|
for (uint x = 0; x < 10; x ++){
|
||||||
|
x = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_SUCCESS(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(scoping_for2)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
function f() public {
|
||||||
|
for (uint x = 0; x < 10; x ++){
|
||||||
|
x = 2;
|
||||||
|
}
|
||||||
|
x = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(text, DeclarationError, "Undeclared identifier");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(name_shadowing)
|
BOOST_AUTO_TEST_CASE(name_shadowing)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user