From 269241e9105a3b3014002bf711ade985d87febe4 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Mon, 12 Mar 2018 13:57:48 +0100 Subject: Add formatted printing to SyntaxTest and expand its public interface. --- test/libsolidity/FormattedScope.h | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 test/libsolidity/FormattedScope.h (limited to 'test/libsolidity/FormattedScope.h') diff --git a/test/libsolidity/FormattedScope.h b/test/libsolidity/FormattedScope.h new file mode 100644 index 00000000..78560848 --- /dev/null +++ b/test/libsolidity/FormattedScope.h @@ -0,0 +1,66 @@ +/* + 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 . +*/ + +#pragma once + +#include + +#include +#include + +namespace dev +{ +namespace solidity +{ +namespace test +{ + +namespace formatting +{ + +static constexpr char const* RESET = "\033[0m"; +static constexpr char const* RED = "\033[1;31m"; +static constexpr char const* GREEN = "\033[1;32m"; +static constexpr char const* YELLOW = "\033[1;33m"; +static constexpr char const* CYAN = "\033[1;36m"; +static constexpr char const* BOLD = "\033[1m"; +static constexpr char const* INVERSE = "\033[7m"; + +} + +class FormattedScope: boost::noncopyable +{ +public: + /// @arg _formatting List of formatting strings (e.g. colors) defined in the formatting namespace. + FormattedScope(std::ostream& _stream, bool const _enabled, std::vector const& _formatting): + m_stream(_stream), m_enabled(_enabled) + { + if (m_enabled) + for (auto const& format: _formatting) + m_stream << format; + } + ~FormattedScope() { if (m_enabled) m_stream << formatting::RESET; } + template + std::ostream& operator<<(T&& _t) { return m_stream << std::forward(_t); } +private: + std::ostream& m_stream; + bool m_enabled; +}; + +} +} +} -- cgit v1.2.3 From f03695731b9b36cd4014620b7b63556a69b4e952 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 6 Apr 2018 18:37:01 +0200 Subject: Add source locations to syntax test expectations. --- test/libsolidity/FormattedScope.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/libsolidity/FormattedScope.h') diff --git a/test/libsolidity/FormattedScope.h b/test/libsolidity/FormattedScope.h index 78560848..923404f0 100644 --- a/test/libsolidity/FormattedScope.h +++ b/test/libsolidity/FormattedScope.h @@ -38,6 +38,8 @@ static constexpr char const* GREEN = "\033[1;32m"; static constexpr char const* YELLOW = "\033[1;33m"; static constexpr char const* CYAN = "\033[1;36m"; static constexpr char const* BOLD = "\033[1m"; +static constexpr char const* RED_BACKGROUND = "\033[48;5;160m"; +static constexpr char const* ORANGE_BACKGROUND = "\033[48;5;166m"; static constexpr char const* INVERSE = "\033[7m"; } -- cgit v1.2.3