From 14d0f8c2f194bfed0ae8d23042f6210cff1f93c9 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 8 Jun 2018 14:17:50 +0200 Subject: Refactor syntax test infrastructure to prepare introducing semantics tests. --- test/libsolidity/TestCase.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/libsolidity/TestCase.cpp (limited to 'test/libsolidity/TestCase.cpp') diff --git a/test/libsolidity/TestCase.cpp b/test/libsolidity/TestCase.cpp new file mode 100644 index 00000000..6c4e0aea --- /dev/null +++ b/test/libsolidity/TestCase.cpp @@ -0,0 +1,55 @@ +/* + 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 . +*/ + +#include + +#include +#include + +#include + +using namespace dev; +using namespace solidity; +using namespace dev::solidity::test; +using namespace std; + +bool TestCase::isTestFilename(boost::filesystem::path const& _filename) +{ + return _filename.extension().string() == ".sol" && + !boost::starts_with(_filename.string(), "~") && + !boost::starts_with(_filename.string(), "."); +} + +string TestCase::parseSource(istream& _stream) +{ + string source; + string line; + string const delimiter("// ----"); + while (getline(_stream, line)) + if (boost::algorithm::starts_with(line, delimiter)) + break; + else + source += line + "\n"; + return source; +} + +void TestCase::expect(string::iterator& _it, string::iterator _end, string::value_type _c) +{ + if (_it == _end || *_it != _c) + throw runtime_error(string("Invalid test expectation. Expected: \"") + _c + "\"."); + ++_it; +} -- cgit v1.2.3 From 4607118d2e9bbf59707b48f177aff54ac99163b8 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 9 Oct 2018 15:43:55 +0200 Subject: Add Yul optimizer test framework. --- test/libsolidity/TestCase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/libsolidity/TestCase.cpp') diff --git a/test/libsolidity/TestCase.cpp b/test/libsolidity/TestCase.cpp index 6c4e0aea..17972269 100644 --- a/test/libsolidity/TestCase.cpp +++ b/test/libsolidity/TestCase.cpp @@ -29,7 +29,8 @@ using namespace std; bool TestCase::isTestFilename(boost::filesystem::path const& _filename) { - return _filename.extension().string() == ".sol" && + string extension = _filename.extension().string(); + return (extension == ".sol" || extension == ".yul") && !boost::starts_with(_filename.string(), "~") && !boost::starts_with(_filename.string(), "."); } -- cgit v1.2.3