diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-04-03 18:05:26 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-04-04 01:54:45 +0800 |
commit | 6f9644add18b27363a423e2c7ccb0e578ba800bc (patch) | |
tree | c6158178cf44a68563acd92ef5f3ccad98ce56c6 /test/libsolidity/SyntaxTest.h | |
parent | 104a9736b35495cf50bf1a895d61aed9a1ba830a (diff) | |
download | dexon-solidity-6f9644add18b27363a423e2c7ccb0e578ba800bc.tar.gz dexon-solidity-6f9644add18b27363a423e2c7ccb0e578ba800bc.tar.zst dexon-solidity-6f9644add18b27363a423e2c7ccb0e578ba800bc.zip |
SyntaxTests: extend syntax tests and isoltest to support parser errors and compiler exceptions.
Diffstat (limited to 'test/libsolidity/SyntaxTest.h')
-rw-r--r-- | test/libsolidity/SyntaxTest.h | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h index cb6ee05c..dddd86ef 100644 --- a/test/libsolidity/SyntaxTest.h +++ b/test/libsolidity/SyntaxTest.h @@ -36,10 +36,14 @@ namespace solidity namespace test { -struct SyntaxTestExpectation +struct SyntaxTestError { std::string type; std::string message; + bool operator==(SyntaxTestError const& _rhs) const + { + return type == _rhs.type && message == _rhs.message; + } }; @@ -50,21 +54,16 @@ public: bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false); - std::vector<SyntaxTestExpectation> const& expectations() const { return m_expectations; } + std::vector<SyntaxTestError> const& expectations() const { return m_expectations; } std::string const& source() const { return m_source; } - ErrorList const& errorList() const { return m_errorList; } - ErrorList const& compilerErrors() const { return m_compiler.errors(); } + std::vector<SyntaxTestError> const& errorList() const { return m_errorList; } - void printExpected(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted = false) const; - - void printErrorList( + static void printErrorList( std::ostream& _stream, - ErrorList const& _errors, + std::vector<SyntaxTestError> const& _errors, std::string const& _linePrefix, - bool const _ignoreWarnings, - bool const _lineNumbers, bool const _formatted = false - ) const; + ); static int registerTests( boost::unit_test::test_suite& _suite, @@ -72,16 +71,14 @@ public: boost::filesystem::path const& _path ); static bool isTestFilename(boost::filesystem::path const& _filename); + static std::string errorMessage(Exception const& _e); private: - bool matchesExpectations(ErrorList const& _errors) const; - static std::string errorMessage(Error const& _e); static std::string parseSource(std::istream& _stream); - static std::vector<SyntaxTestExpectation> parseExpectations(std::istream& _stream); - int offsetToLineNumber(int _location) const; + static std::vector<SyntaxTestError> parseExpectations(std::istream& _stream); std::string m_source; - std::vector<SyntaxTestExpectation> m_expectations; - ErrorList m_errorList; + std::vector<SyntaxTestError> m_expectations; + std::vector<SyntaxTestError> m_errorList; }; } |