From dce80911e198fe5d6317a9a4d155f929789fdea6 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 15 Nov 2016 09:16:33 +0100 Subject: Add tests --- test/libsolidity/InlineAssembly.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'test/libsolidity') 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() } -- cgit