diff options
author | chriseth <chris@ethereum.org> | 2018-02-23 18:42:53 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-03-02 00:19:35 +0800 |
commit | dc317a44e031d45ebf745b47248bf06bc92d58bf (patch) | |
tree | d03753c0d0ff0672669e0e8ecb70db84f73f6a7f /test | |
parent | a53d6b499d5cc5c45fc096cea6393dc285581f90 (diff) | |
download | dexon-solidity-dc317a44e031d45ebf745b47248bf06bc92d58bf.tar.gz dexon-solidity-dc317a44e031d45ebf745b47248bf06bc92d58bf.tar.zst dexon-solidity-dc317a44e031d45ebf745b47248bf06bc92d58bf.zip |
Provide EVM version to assembly analysis.
Diffstat (limited to 'test')
-rw-r--r-- | test/ExecutionFramework.cpp | 8 | ||||
-rw-r--r-- | test/TestHelper.cpp | 16 | ||||
-rw-r--r-- | test/TestHelper.h | 5 | ||||
-rw-r--r-- | test/libjulia/Common.cpp | 9 | ||||
-rw-r--r-- | test/libjulia/Parser.cpp | 7 | ||||
-rw-r--r-- | test/libsolidity/InlineAssembly.cpp | 6 |
6 files changed, 37 insertions, 14 deletions
diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp index adf514e2..a24f78fb 100644 --- a/test/ExecutionFramework.cpp +++ b/test/ExecutionFramework.cpp @@ -51,17 +51,11 @@ string getIPCSocketPath() ExecutionFramework::ExecutionFramework() : m_rpc(RPCSession::instance(getIPCSocketPath())), + m_evmVersion(dev::test::Options::get().evmVersion()), m_optimize(dev::test::Options::get().optimize), m_showMessages(dev::test::Options::get().showMessages), m_sender(m_rpc.account(0)) { - if (!dev::test::Options::get().evmVersion.empty()) - { - auto version = solidity::EVMVersion::fromString(dev::test::Options::get().evmVersion); - BOOST_REQUIRE_MESSAGE(version, "Invalid EVM version: " + dev::test::Options::get().evmVersion); - m_evmVersion = *version; - } - m_rpc.test_rewindToBlock(0); } diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index fbf2dc90..e0d4423d 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -47,7 +47,7 @@ Options::Options() optimize = true; else if (string(suite.argv[i]) == "--evm-version") { - evmVersion = i + 1 < suite.argc ? suite.argv[i + 1] : "INVALID"; + evmVersionString = i + 1 < suite.argc ? suite.argv[i + 1] : "INVALID"; ++i; } else if (string(suite.argv[i]) == "--show-messages") @@ -61,3 +61,17 @@ Options::Options() if (auto path = getenv("ETH_TEST_IPC")) ipcPath = path; } + +dev::solidity::EVMVersion Options::evmVersion() const +{ + if (!evmVersionString.empty()) + { + // We do this check as opposed to in the constructor because the BOOST_REQUIRE + // macros cannot yet be used in the constructor. + auto version = solidity::EVMVersion::fromString(evmVersionString); + BOOST_REQUIRE_MESSAGE(version, "Invalid EVM version: " + evmVersionString); + return *version; + } + else + return dev::solidity::EVMVersion(); +} diff --git a/test/TestHelper.h b/test/TestHelper.h index 69ac458a..8c2eec36 100644 --- a/test/TestHelper.h +++ b/test/TestHelper.h @@ -36,14 +36,17 @@ struct Options: boost::noncopyable { std::string ipcPath; bool showMessages = false; - std::string evmVersion; bool optimize = false; bool disableIPC = false; bool disableSMT = false; + solidity::EVMVersion evmVersion() const; + static Options const& get(); private: + std::string evmVersionString; + Options(); }; diff --git a/test/libjulia/Common.cpp b/test/libjulia/Common.cpp index 7053a68d..d8cd20b6 100644 --- a/test/libjulia/Common.cpp +++ b/test/libjulia/Common.cpp @@ -21,6 +21,8 @@ #include <test/libjulia/Common.h> +#include <test/TestHelper.h> + #include <libjulia/optimiser/Disambiguator.h> #include <libsolidity/parsing/Scanner.h> @@ -61,7 +63,12 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test: { BOOST_REQUIRE(errorReporter.errors().empty()); auto analysisInfo = make_shared<assembly::AsmAnalysisInfo>(); - assembly::AsmAnalyzer analyzer(*analysisInfo, errorReporter, flavour); + assembly::AsmAnalyzer analyzer( + *analysisInfo, + errorReporter, + dev::test::Options::get().evmVersion(), + flavour + ); if (analyzer.analyze(*parserResult)) { BOOST_REQUIRE(errorReporter.errors().empty()); diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp index ff9474c1..6476c4d4 100644 --- a/test/libjulia/Parser.cpp +++ b/test/libjulia/Parser.cpp @@ -56,7 +56,12 @@ bool parse(string const& _source, ErrorReporter& errorReporter) if (parserResult) { assembly::AsmAnalysisInfo analysisInfo; - return (assembly::AsmAnalyzer(analysisInfo, errorReporter, assembly::AsmFlavour::IULIA)).analyze(*parserResult); + return (assembly::AsmAnalyzer( + analysisInfo, + errorReporter, + dev::test::Options::get().evmVersion(), + assembly::AsmFlavour::IULIA + )).analyze(*parserResult); } } catch (FatalError const&) diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index ea120657..16ab611a 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -55,7 +55,7 @@ boost::optional<Error> parseAndReturnFirstError( AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM ) { - AssemblyStack stack(_language); + AssemblyStack stack(dev::test::Options::get().evmVersion(), _language); bool success = false; try { @@ -117,7 +117,7 @@ Error expectError( void parsePrintCompare(string const& _source, bool _canWarn = false) { - AssemblyStack stack; + AssemblyStack stack(dev::test::Options::get().evmVersion()); BOOST_REQUIRE(stack.parseAndAnalyze("", _source)); if (_canWarn) BOOST_REQUIRE(Error::containsOnlyWarnings(stack.errors())); @@ -567,7 +567,7 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode) { string source = "{ let x := \"\\u1bac\" }"; string parsed = "{\n let x := \"\\xe1\\xae\\xac\"\n}"; - AssemblyStack stack; + AssemblyStack stack(dev::test::Options::get().evmVersion()); BOOST_REQUIRE(stack.parseAndAnalyze("", source)); BOOST_REQUIRE(stack.errors().empty()); BOOST_CHECK_EQUAL(stack.print(), parsed); |