diff options
author | chriseth <chris@ethereum.org> | 2018-03-13 20:15:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-13 20:15:45 +0800 |
commit | 6bab7a4cce26e922029769e7193636cfc2fe3752 (patch) | |
tree | 73adb2c2b21783e92cad8a1cdb2bf40a7a01d402 /test/libsolidity/SyntaxTest.h | |
parent | f2614be95f71a274db3c172661726dd007e90cf7 (diff) | |
parent | 7091b6c8b5a91a13ff02255cc0bca08266527e4f (diff) | |
download | dexon-solidity-6bab7a4cce26e922029769e7193636cfc2fe3752.tar dexon-solidity-6bab7a4cce26e922029769e7193636cfc2fe3752.tar.gz dexon-solidity-6bab7a4cce26e922029769e7193636cfc2fe3752.tar.bz2 dexon-solidity-6bab7a4cce26e922029769e7193636cfc2fe3752.tar.lz dexon-solidity-6bab7a4cce26e922029769e7193636cfc2fe3752.tar.xz dexon-solidity-6bab7a4cce26e922029769e7193636cfc2fe3752.tar.zst dexon-solidity-6bab7a4cce26e922029769e7193636cfc2fe3752.zip |
Merge pull request #3707 from ethereum/syntaxTestsTestRunner
Infrastructure for extracting syntax tests.
Diffstat (limited to 'test/libsolidity/SyntaxTest.h')
-rw-r--r-- | test/libsolidity/SyntaxTest.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h new file mode 100644 index 00000000..4379c77b --- /dev/null +++ b/test/libsolidity/SyntaxTest.h @@ -0,0 +1,77 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see <http://www.gnu.org/licenses/>. +*/ + +#pragma once + +#include <test/libsolidity/AnalysisFramework.h> +#include <libsolidity/interface/Exceptions.h> + +#include <boost/noncopyable.hpp> +#include <boost/test/unit_test.hpp> + +#include <iosfwd> +#include <string> +#include <vector> +#include <utility> + +namespace dev +{ +namespace solidity +{ +namespace test +{ + +struct SyntaxTestExpectation +{ + std::string type; + std::string message; +}; + + +class SyntaxTest: AnalysisFramework +{ +public: + SyntaxTest(std::string const& _filename); + + bool run(std::ostream& _stream, std::string const& _indent); + + void printExpected(std::ostream& _stream, std::string const& _indent) const; + void printErrorList( + std::ostream& _stream, + ErrorList const& _errors, + std::string const& _indent + ) const; + + static int registerTests( + boost::unit_test::test_suite& _suite, + boost::filesystem::path const& _basepath, + boost::filesystem::path const& _path + ); +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); + + std::string m_source; + std::vector<SyntaxTestExpectation> m_expectations; + ErrorList m_errorList; +}; + +} +} +} |