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 <liblangutil/Exceptions.h> 24 25 #include <libsolidity/interface/OptimiserSettings.h> 26 27 #include <iosfwd> 28 #include <string> 29 #include <vector> 30 #include <utility> 31 32 namespace solidity::frontend::test 33 { 34 35 class GasTest: AnalysisFramework, public TestCase 36 { 37 public: create(Config const & _config)38 static std::unique_ptr<TestCase> create(Config const& _config) 39 { return std::make_unique<GasTest>(_config.filename); } 40 GasTest(std::string const& _filename); 41 42 TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override; 43 44 void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool _formatted = false) const override; 45 void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override; 46 47 private: 48 void parseExpectations(std::istream& _stream); 49 50 bool m_optimise = false; 51 bool m_optimiseYul = false; 52 size_t m_optimiseRuns = OptimiserSettings{}.expectedExecutionsPerDeployment; 53 std::map<std::string, std::map<std::string, std::string>> m_expectations; 54 }; 55 56 } 57