Skip to content

Commit

Permalink
Add tests for global shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Feb 2, 2017
1 parent 0f50c53 commit bdd5614
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/libsolidity/SolidityNameAndTypeResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false,
}
if (success)
{
StaticAnalyzer staticAnalyzer(errors);
StaticAnalyzer staticAnalyzer(globalContext->declartions(), errors);
staticAnalyzer.analyze(*sourceUnit);
}
if (errors.size() > 1 && !_allowMultipleErrors)
Expand Down Expand Up @@ -5078,6 +5078,29 @@ BOOST_AUTO_TEST_CASE(invalid_address_length)
CHECK_WARNING(text, "checksum");
}

BOOST_AUTO_TEST_CASE(shadowing_global_functions)
{
char const* text = R"(
contract C {
function keccak256() {}
}
)";
CHECK_WARNING(text, "Shadowing global function");
}

BOOST_AUTO_TEST_CASE(shadowing_global_variables)
{
char const* text = R"(
contract C {
function f() {
uint msg;
}
}
)";
CHECK_WARNING(text, "Shadowing global variable");
}


BOOST_AUTO_TEST_SUITE_END()

}
Expand Down

0 comments on commit bdd5614

Please sign in to comment.