|
| 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 | +#include <test/libyul/EVMDialectCompatibility.h> |
| 20 | + |
| 21 | +#include <boost/test/data/test_case.hpp> |
| 22 | +#include <boost/test/data/monomorphic.hpp> |
| 23 | + |
| 24 | +namespace bdata = boost::unit_test::data; |
| 25 | + |
| 26 | +using namespace solidity; |
| 27 | +using namespace solidity::yul; |
| 28 | +using namespace solidity::yul::test; |
| 29 | + |
| 30 | +BOOST_AUTO_TEST_SUITE(EVMDialectCompatibility) |
| 31 | + |
| 32 | +BOOST_DATA_TEST_CASE( |
| 33 | + builtin_function_handle_compatibility_non_eof, |
| 34 | + bdata::make(generateEVMDialectConfigurationsToTest(std::nullopt)), |
| 35 | + evmDialectConfigurationToTest |
| 36 | +) |
| 37 | +{ |
| 38 | + auto const& dialectToTestAgainst = evmDialectConfigurationToTest.dialect(); |
| 39 | + // no object access for current |
| 40 | + { |
| 41 | + auto const& currentDialect = EVMDialect::strictAssemblyForEVM({}, std::nullopt); |
| 42 | + for (auto const& builtinFunctionName: currentDialect.builtinFunctionNames()) |
| 43 | + requireBuiltinCompatibility(currentDialect, dialectToTestAgainst, builtinFunctionName); |
| 44 | + } |
| 45 | + // object access for current |
| 46 | + { |
| 47 | + auto const& currentDialect = EVMDialect::strictAssemblyForEVMObjects({}, std::nullopt); |
| 48 | + for (auto const& builtinFunctionName: currentDialect.builtinFunctionNames()) |
| 49 | + requireBuiltinCompatibility(currentDialect, dialectToTestAgainst, builtinFunctionName); |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +BOOST_DATA_TEST_CASE( |
| 54 | + builtin_function_handle_compatibility_eof, |
| 55 | + bdata::monomorphic::grid( |
| 56 | + bdata::make(generateEVMDialectConfigurationsToTest(std::nullopt)) + bdata::make(generateEVMDialectConfigurationsToTest(1)), |
| 57 | + bdata::make({false, true}) |
| 58 | + ), |
| 59 | + evmDialectConfigurationToTest, |
| 60 | + withEOF |
| 61 | +) |
| 62 | +{ |
| 63 | + auto const& dialectToTestAgainst = evmDialectConfigurationToTest.dialect(); |
| 64 | + langutil::EVMVersion latestEVMVersion = langutil::EVMVersion::allVersions().back(); |
| 65 | + std::optional<uint8_t> eofVersion = std::nullopt; |
| 66 | + if (withEOF) |
| 67 | + eofVersion = 1; |
| 68 | + // no object access for latest |
| 69 | + { |
| 70 | + auto const& latestDialect = EVMDialect::strictAssemblyForEVM(latestEVMVersion, eofVersion); |
| 71 | + for (auto const& builtinFunctionName: latestDialect.builtinFunctionNames()) |
| 72 | + requireBuiltinCompatibility(latestDialect, dialectToTestAgainst, builtinFunctionName); |
| 73 | + } |
| 74 | + // object access for latest |
| 75 | + { |
| 76 | + auto const& latestDialect = EVMDialect::strictAssemblyForEVMObjects(latestEVMVersion, eofVersion); |
| 77 | + for (auto const& builtinFunctionName: latestDialect.builtinFunctionNames()) |
| 78 | + requireBuiltinCompatibility(latestDialect, dialectToTestAgainst, builtinFunctionName); |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +BOOST_AUTO_TEST_SUITE_END() |
0 commit comments