diff --git a/test/TestCase.cpp b/test/TestCase.cpp index 8b2afc780..f952e40bd 100644 --- a/test/TestCase.cpp +++ b/test/TestCase.cpp @@ -28,7 +28,7 @@ using namespace solidity; using namespace solidity::frontend; using namespace solidity::frontend::test; -void TestCase::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool) +void TestCase::printSettings(ostream& _stream, const string& _linePrefix, const bool) { auto& settings = m_reader.settings(); if (settings.empty()) @@ -63,11 +63,10 @@ void TestCase::expect(string::iterator& _it, string::iterator _end, string::valu EVMVersionRestrictedTestCase::EVMVersionRestrictedTestCase(string const& _filename): TestCase(_filename) { - if (!m_reader.hasSetting("EVMVersion")) + string versionString = m_reader.stringSetting("EVMVersion", "any"); + if (versionString == "any") return; - string versionString = m_reader.stringSetting("EVMVersion", ""); - string comparator; size_t versionBegin = 0; for (auto character: versionString) diff --git a/test/TestCase.h b/test/TestCase.h index b4e7e3972..0add6947b 100644 --- a/test/TestCase.h +++ b/test/TestCase.h @@ -57,8 +57,8 @@ public: /// If @arg _formatted is true, color-coding may be used to indicate /// error locations in the contract, if applicable. virtual void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) const = 0; - /// Outputs the updated settings. - virtual void printUpdatedSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false); + /// Outputs settings. + virtual void printSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false); /// Outputs test expectations to @arg _stream that match the actual results of the test. /// Each line of output is prefixed with @arg _linePrefix. virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const = 0; diff --git a/test/TestCaseReader.cpp b/test/TestCaseReader.cpp index 2b7e201af..0f49a6401 100644 --- a/test/TestCaseReader.cpp +++ b/test/TestCaseReader.cpp @@ -49,14 +49,9 @@ string TestCaseReader::simpleExpectations() return parseSimpleExpectations(m_file); } -bool TestCaseReader::hasSetting(std::string const& _name) const -{ - return m_settings.count(_name) != 0; -} - bool TestCaseReader::boolSetting(std::string const& _name, bool _defaultValue) { - if (!hasSetting(_name)) + if (m_settings.count(_name) == 0) return _defaultValue; m_unreadSettings.erase(_name); @@ -71,7 +66,7 @@ bool TestCaseReader::boolSetting(std::string const& _name, bool _defaultValue) size_t TestCaseReader::sizetSetting(std::string const& _name, size_t _defaultValue) { - if (!hasSetting(_name)) + if (m_settings.count(_name) == 0) return _defaultValue; m_unreadSettings.erase(_name); @@ -82,18 +77,13 @@ size_t TestCaseReader::sizetSetting(std::string const& _name, size_t _defaultVal string TestCaseReader::stringSetting(string const& _name, string const& _defaultValue) { - if (!hasSetting(_name)) + if (m_settings.count(_name) == 0) return _defaultValue; m_unreadSettings.erase(_name); return m_settings.at(_name); } -void TestCaseReader::setSetting(std::string const& _name, std::string const& _value) -{ - m_settings[_name] = _value; -} - void TestCaseReader::ensureAllSettingsRead() const { if (!m_unreadSettings.empty()) diff --git a/test/TestCaseReader.h b/test/TestCaseReader.h index 055b355b7..5ab226826 100644 --- a/test/TestCaseReader.h +++ b/test/TestCaseReader.h @@ -40,11 +40,9 @@ public: std::string simpleExpectations(); - bool hasSetting(std::string const& _name) const; bool boolSetting(std::string const& _name, bool _defaultValue); size_t sizetSetting(std::string const& _name, size_t _defaultValue); std::string stringSetting(std::string const& _name, std::string const& _defaultValue); - void setSetting(std::string const& _name, std::string const& _value); void ensureAllSettingsRead() const; diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 8b5112e12..ded01f8dd 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -43,21 +43,24 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer m_source = m_reader.source(); m_lineOffset = m_reader.lineNumber(); - if (m_reader.hasSetting("compileViaYul")) + string choice = m_reader.stringSetting("compileViaYul", "false"); + if (choice == "also") { - string choice = m_reader.stringSetting("compileViaYul", ""); - if (choice == "also") - { - m_runWithYul = true; - m_runWithoutYul = true; - } - else - { - m_reader.setSetting("compileViaYul", "only"); - m_runWithYul = true; - m_runWithoutYul = false; - } + m_runWithYul = true; + m_runWithoutYul = true; } + else if (choice == "true") + { + m_runWithYul = true; + m_runWithoutYul = false; + } + else if (choice == "false") + { + m_runWithYul = false; + m_runWithoutYul = true; + } + else + BOOST_THROW_EXCEPTION(runtime_error("Invalid compileViaYul value: " + choice + ".")); m_runWithABIEncoderV1Only = m_reader.boolSetting("ABIEncoderV1Only", false); if (m_runWithABIEncoderV1Only && solidity::test::CommonOptions::get().useABIEncoderV2) diff --git a/test/libsolidity/semanticTests/viaYul/detect_mod_zero.sol b/test/libsolidity/semanticTests/viaYul/detect_mod_zero.sol index d8defa17a..6340c71c3 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_mod_zero.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_mod_zero.sol @@ -7,7 +7,7 @@ contract C { } } // ==== -// compileViaYul: only +// compileViaYul: true // ---- // f(uint256,uint256): 10, 3 -> 1 // f(uint256,uint256): 10, 2 -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/detect_mod_zero_signed.sol b/test/libsolidity/semanticTests/viaYul/detect_mod_zero_signed.sol index 9164bf06c..d93e18d06 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_mod_zero_signed.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_mod_zero_signed.sol @@ -7,7 +7,7 @@ contract C { } } // ==== -// compileViaYul: only +// compileViaYul: true // ---- // f(int256,int256): 10, 3 -> 1 // f(int256,int256): 10, 2 -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/keccak.sol b/test/libsolidity/semanticTests/viaYul/keccak.sol index 887faf9e4..58c37ebd6 100644 --- a/test/libsolidity/semanticTests/viaYul/keccak.sol +++ b/test/libsolidity/semanticTests/viaYul/keccak.sol @@ -8,7 +8,7 @@ contract C { } } // ==== -// compileViaYul: only +// compileViaYul: true // ---- // keccak1() -> 0x64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107 // keccak2() -> 0x64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107 diff --git a/test/libsolidity/semanticTests/viaYul/string_format.sol b/test/libsolidity/semanticTests/viaYul/string_format.sol index 2d9d71d7c..98e4d1081 100644 --- a/test/libsolidity/semanticTests/viaYul/string_format.sol +++ b/test/libsolidity/semanticTests/viaYul/string_format.sol @@ -5,7 +5,7 @@ contract C { function h() external pure returns (bytes4) { return 0xcafecafe; } } // ==== -// compileViaYul: only +// compileViaYul: true // ---- // f1() -> 0x20, 6, left(0x616263616263) // f2() -> 32, 47, 44048183223289766195424279195050628400112610419087780792899004030957505095210, 18165586057823232067963737336409268114628061002662705707816940456850361417728 diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index da85c9ed0..ad689ffcf 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -172,7 +172,7 @@ TestTool::Result TestTool::process() AnsiColorized(cout, formatted, {BOLD, CYAN}) << " Contract:" << endl; m_test->printSource(cout, " ", formatted); - m_test->printUpdatedSettings(cout, " ", formatted); + m_test->printSettings(cout, " ", formatted); cout << endl << outputMessages.str() << endl; return result == TestCase::TestResult::FatalError ? Result::Exception : Result::Failure; @@ -231,7 +231,7 @@ TestTool::Request TestTool::handleResponse(bool _exception) cout << endl; ofstream file(m_path.string(), ios::trunc); m_test->printSource(file); - m_test->printUpdatedSettings(file); + m_test->printSettings(file); file << "// ----" << endl; m_test->printUpdatedExpectations(file, "// "); return Request::Rerun;