mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Support EVM Version rules for extracted tests.
This commit is contained in:
@@ -35,8 +35,8 @@ using namespace dev;
|
||||
using namespace std;
|
||||
using namespace boost::unit_test;
|
||||
|
||||
SMTCheckerTest::SMTCheckerTest(string const& _filename)
|
||||
: SyntaxTest(_filename)
|
||||
SMTCheckerTest::SMTCheckerTest(string const& _filename, langutil::EVMVersion const _evmVersion)
|
||||
: SyntaxTest(_filename, _evmVersion)
|
||||
{
|
||||
if (!boost::algorithm::ends_with(_filename, ".sol"))
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Invalid test contract file name: \"" + _filename + "\"."));
|
||||
|
||||
@@ -35,9 +35,9 @@ class SMTCheckerTest: public SyntaxTest
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{
|
||||
return std::unique_ptr<TestCase>(new SMTCheckerTest(_config.filename));
|
||||
return std::unique_ptr<TestCase>(new SMTCheckerTest(_config.filename, _config.evmVersion));
|
||||
}
|
||||
SMTCheckerTest(std::string const& _filename);
|
||||
SMTCheckerTest(std::string const& _filename, langutil::EVMVersion _evmVersion);
|
||||
|
||||
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ using namespace boost::unit_test;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
|
||||
SemanticTest::SemanticTest(string const& _filename, string const& _ipcPath):
|
||||
SolidityExecutionFramework(_ipcPath)
|
||||
SemanticTest::SemanticTest(string const& _filename, string const& _ipcPath, langutil::EVMVersion const _evmVersion):
|
||||
SolidityExecutionFramework(_ipcPath, _evmVersion)
|
||||
{
|
||||
ifstream file(_filename);
|
||||
soltestAssert(file, "Cannot open test contract: \"" + _filename + "\".");
|
||||
|
||||
@@ -44,9 +44,9 @@ class SemanticTest: public SolidityExecutionFramework, public TestCase
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _options)
|
||||
{ return std::make_unique<SemanticTest>(_options.filename, _options.ipcPath); }
|
||||
{ return std::make_unique<SemanticTest>(_options.filename, _options.ipcPath, _options.evmVersion); }
|
||||
|
||||
explicit SemanticTest(std::string const& _filename, std::string const& _ipcPath);
|
||||
explicit SemanticTest(std::string const& _filename, std::string const& _ipcPath, langutil::EVMVersion const _evmVersion);
|
||||
|
||||
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
|
||||
void printSource(std::ostream &_stream, std::string const& _linePrefix = "", bool const _formatted = false) const override;
|
||||
|
||||
@@ -33,7 +33,7 @@ SolidityExecutionFramework::SolidityExecutionFramework():
|
||||
{
|
||||
}
|
||||
|
||||
SolidityExecutionFramework::SolidityExecutionFramework(std::string const& _ipcPath):
|
||||
ExecutionFramework(_ipcPath)
|
||||
SolidityExecutionFramework::SolidityExecutionFramework(std::string const& _ipcPath, langutil::EVMVersion const _evmVersion):
|
||||
ExecutionFramework(_ipcPath, _evmVersion)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class SolidityExecutionFramework: public dev::test::ExecutionFramework
|
||||
|
||||
public:
|
||||
SolidityExecutionFramework();
|
||||
SolidityExecutionFramework(std::string const& _ipcPath);
|
||||
SolidityExecutionFramework(std::string const& _ipcPath, langutil::EVMVersion const _evmVersion);
|
||||
|
||||
virtual bytes const& compileAndRunWithoutCheck(
|
||||
std::string const& _sourceCode,
|
||||
|
||||
@@ -52,7 +52,7 @@ int parseUnsignedInteger(string::iterator& _it, string::iterator _end)
|
||||
|
||||
}
|
||||
|
||||
SyntaxTest::SyntaxTest(string const& _filename)
|
||||
SyntaxTest::SyntaxTest(string const& _filename, langutil::EVMVersion const _evmVersion): m_evmVersion(_evmVersion)
|
||||
{
|
||||
ifstream file(_filename);
|
||||
if (!file)
|
||||
@@ -68,7 +68,7 @@ bool SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool const _fo
|
||||
string const versionPragma = "pragma solidity >=0.0;\n";
|
||||
m_compiler.reset();
|
||||
m_compiler.addSource("", versionPragma + m_source);
|
||||
m_compiler.setEVMVersion(dev::test::Options::get().evmVersion());
|
||||
m_compiler.setEVMVersion(m_evmVersion);
|
||||
|
||||
if (m_compiler.parse())
|
||||
m_compiler.analyze();
|
||||
|
||||
@@ -54,8 +54,8 @@ class SyntaxTest: AnalysisFramework, public TestCase
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{ return std::unique_ptr<TestCase>(new SyntaxTest(_config.filename)); }
|
||||
SyntaxTest(std::string const& _filename);
|
||||
{ return std::unique_ptr<TestCase>(new SyntaxTest(_config.filename, _config.evmVersion)); }
|
||||
SyntaxTest(std::string const& _filename, langutil::EVMVersion const _evmVersion);
|
||||
|
||||
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
|
||||
|
||||
@@ -82,6 +82,7 @@ protected:
|
||||
std::string m_source;
|
||||
std::vector<SyntaxTestError> m_expectations;
|
||||
std::vector<SyntaxTestError> m_errorList;
|
||||
langutil::EVMVersion const m_evmVersion;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user