1 /* 2 This file is part of solidity. 3 4 solidity is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 solidity is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with solidity. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 // SPDX-License-Identifier: GPL-3.0 18 19 #pragma once 20 21 #include <test/libsolidity/AnalysisFramework.h> 22 #include <test/TestCase.h> 23 #include <test/CommonSyntaxTest.h> 24 #include <liblangutil/Exceptions.h> 25 #include <libsolutil/AnsiColorized.h> 26 27 #include <iosfwd> 28 #include <string> 29 #include <vector> 30 #include <utility> 31 32 namespace solidity::frontend::test 33 { 34 35 using solidity::test::SyntaxTestError; 36 37 class SyntaxTest: public AnalysisFramework, public solidity::test::CommonSyntaxTest 38 { 39 public: create(Config const & _config)40 static std::unique_ptr<TestCase> create(Config const& _config) 41 { 42 return std::make_unique<SyntaxTest>(_config.filename, _config.evmVersion, false); 43 } createErrorRecovery(Config const & _config)44 static std::unique_ptr<TestCase> createErrorRecovery(Config const& _config) 45 { 46 return std::make_unique<SyntaxTest>(_config.filename, _config.evmVersion, true); 47 } 48 SyntaxTest(std::string const& _filename, langutil::EVMVersion _evmVersion, bool _parserErrorRecovery = false); 49 50 TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override; 51 52 protected: 53 /// Returns @param _sourceCode prefixed with the version pragma and the SPDX license identifier. 54 static std::string addPreamble(std::string const& _sourceCode); 55 56 void setupCompiler(); 57 void parseAndAnalyze() override; 58 virtual void filterObtainedErrors(); 59 60 bool m_optimiseYul = true; 61 bool m_parserErrorRecovery = false; 62 }; 63 64 } 65