aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/InlineAssembly.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-15 16:16:33 +0800
committerchriseth <c@ethdev.com>2016-11-15 16:16:33 +0800
commitdce80911e198fe5d6317a9a4d155f929789fdea6 (patch)
treeb0259484d80002637a98b3fb9fb039c8fa118e25 /test/libsolidity/InlineAssembly.cpp
parentdad33f80dda1824c87e64ad857f9f075e97a01c8 (diff)
downloaddexon-solidity-dce80911e198fe5d6317a9a4d155f929789fdea6.tar.gz
dexon-solidity-dce80911e198fe5d6317a9a4d155f929789fdea6.tar.zst
dexon-solidity-dce80911e198fe5d6317a9a4d155f929789fdea6.zip
Add tests
Diffstat (limited to 'test/libsolidity/InlineAssembly.cpp')
-rw-r--r--test/libsolidity/InlineAssembly.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp
index 6c04367f..a80a44a2 100644
--- a/test/libsolidity/InlineAssembly.cpp
+++ b/test/libsolidity/InlineAssembly.cpp
@@ -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()
}