diff options
author | chriseth <chris@ethereum.org> | 2017-05-31 18:39:50 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-06-08 21:52:45 +0800 |
commit | b75c7b577583721a853a01a070f5497d702d17f0 (patch) | |
tree | 5cdf20aa7e87f13b1d88dde2afe585853754badd /test/libsolidity | |
parent | fefd3b866d982d95d05e5956d1af48b357162cc8 (diff) | |
download | dexon-solidity-b75c7b577583721a853a01a070f5497d702d17f0.tar.gz dexon-solidity-b75c7b577583721a853a01a070f5497d702d17f0.tar.zst dexon-solidity-b75c7b577583721a853a01a070f5497d702d17f0.zip |
Move inline assembly to new abstraction and test both backends.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/InlineAssembly.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 88b2d584..4de2ea81 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -22,7 +22,7 @@ #include "../TestHelper.h" -#include <libsolidity/inlineasm/AsmStack.h> +#include <libsolidity/interface/AssemblyStack.h> #include <libsolidity/parsing/Scanner.h> #include <libsolidity/interface/Exceptions.h> #include <libsolidity/ast/AST.h> @@ -47,15 +47,20 @@ namespace test namespace { -boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _assemble = false, bool _allowWarnings = true) +boost::optional<Error> parseAndReturnFirstError( + string const& _source, + bool _assemble = false, + bool _allowWarnings = true, + AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM +) { - assembly::InlineAssemblyStack stack; + AssemblyStack stack; bool success = false; try { - success = stack.parse(std::make_shared<Scanner>(CharStream(_source))); + success = stack.parseAndAnalyze("", _source); if (success && _assemble) - stack.assemble(); + stack.assemble(_machine); } catch (FatalError const&) { @@ -82,14 +87,20 @@ boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _ass return {}; } -bool successParse(std::string const& _source, bool _assemble = false, bool _allowWarnings = true) +bool successParse( + string const& _source, + bool _assemble = false, + bool _allowWarnings = true, + AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM +) { - return !parseAndReturnFirstError(_source, _assemble, _allowWarnings); + return !parseAndReturnFirstError(_source, _assemble, _allowWarnings, _machine); } bool successAssemble(string const& _source, bool _allowWarnings = true) { - return successParse(_source, true, _allowWarnings); + return successParse(_source, true, _allowWarnings, AssemblyStack::Machine::EVM) && + successParse(_source, true, _allowWarnings, AssemblyStack::Machine::EVM15); } Error expectError(std::string const& _source, bool _assemble, bool _allowWarnings = false) @@ -102,10 +113,10 @@ Error expectError(std::string const& _source, bool _assemble, bool _allowWarning void parsePrintCompare(string const& _source) { - assembly::InlineAssemblyStack stack; - BOOST_REQUIRE(stack.parse(std::make_shared<Scanner>(CharStream(_source)))); + AssemblyStack stack; + BOOST_REQUIRE(stack.parseAndAnalyze("", _source)); BOOST_REQUIRE(stack.errors().empty()); - BOOST_CHECK_EQUAL(stack.toString(), _source); + BOOST_CHECK_EQUAL(stack.print(), _source); } } @@ -376,10 +387,10 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode) { string source = "{ let x := \"\\u1bac\" }"; string parsed = "{\n let x := \"\\xe1\\xae\\xac\"\n}"; - assembly::InlineAssemblyStack stack; - BOOST_REQUIRE(stack.parse(std::make_shared<Scanner>(CharStream(source)))); + AssemblyStack stack; + BOOST_REQUIRE(stack.parseAndAnalyze("", source)); BOOST_REQUIRE(stack.errors().empty()); - BOOST_CHECK_EQUAL(stack.toString(), parsed); + BOOST_CHECK_EQUAL(stack.print(), parsed); parsePrintCompare(parsed); } |