mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add tests
This commit is contained in:
parent
dad33f80dd
commit
dce80911e1
@ -41,7 +41,7 @@ namespace test
|
||||
namespace
|
||||
{
|
||||
|
||||
bool successParse(std::string const& _source, bool _assemble = false)
|
||||
bool successParse(std::string const& _source, bool _assemble = false, bool _allowWarnings = true)
|
||||
{
|
||||
assembly::InlineAssemblyStack stack;
|
||||
try
|
||||
@ -51,8 +51,9 @@ bool successParse(std::string const& _source, bool _assemble = false)
|
||||
if (_assemble)
|
||||
{
|
||||
stack.assemble();
|
||||
if (!stack.errors().empty() && !Error::containsOnlyWarnings(stack.errors()))
|
||||
return false;
|
||||
if (!stack.errors().empty())
|
||||
if (!_allowWarnings || !Error::containsOnlyWarnings(stack.errors()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (FatalError const&)
|
||||
@ -67,9 +68,9 @@ bool successParse(std::string const& _source, bool _assemble = false)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool successAssemble(string const& _source)
|
||||
bool successAssemble(string const& _source, bool _allowWarnings = true)
|
||||
{
|
||||
return successParse(_source, true);
|
||||
return successParse(_source, true, _allowWarnings);
|
||||
}
|
||||
|
||||
}
|
||||
@ -169,6 +170,13 @@ BOOST_AUTO_TEST_CASE(magic_variables)
|
||||
BOOST_CHECK(successAssemble("{ let ecrecover := 1 ecrecover }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(imbalanced_stack)
|
||||
{
|
||||
BOOST_CHECK(successAssemble("{ 1 2 mul pop }", false));
|
||||
BOOST_CHECK(!successAssemble("{ 1 }", false));
|
||||
BOOST_CHECK(successAssemble("{ let x := 4 7 add }", false));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user