From 9719cf38e662e428ace8f3ebce9774a5338f0ce5 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 15 Nov 2016 01:04:00 +0000 Subject: Move InterfaceHandler from string to JSON --- libsolidity/ast/AST.cpp | 8 ++++---- libsolidity/ast/AST.h | 13 +++++++------ libsolidity/interface/CompilerStack.cpp | 8 ++++---- libsolidity/interface/CompilerStack.h | 14 +++++++------- libsolidity/interface/InterfaceHandler.cpp | 17 +++++++---------- libsolidity/interface/InterfaceHandler.h | 16 ++++++++-------- solc/CommandLineInterface.cpp | 30 ++++++++++++++++++++++++------ solc/jsonCompiler.cpp | 13 ++++++++++--- 8 files changed, 71 insertions(+), 48 deletions(-) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 695d9881..305668e7 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -160,22 +160,22 @@ vector, FunctionTypePointer>> const& ContractDefinition::inter return *m_interfaceFunctionList; } -string const& ContractDefinition::devDocumentation() const +Json::Value const& ContractDefinition::devDocumentation() const { return m_devDocumentation; } -string const& ContractDefinition::userDocumentation() const +Json::Value const& ContractDefinition::userDocumentation() const { return m_userDocumentation; } -void ContractDefinition::setDevDocumentation(string const& _devDocumentation) +void ContractDefinition::setDevDocumentation(Json::Value const& _devDocumentation) { m_devDocumentation = _devDocumentation; } -void ContractDefinition::setUserDocumentation(string const& _userDocumentation) +void ContractDefinition::setUserDocumentation(Json::Value const& _userDocumentation) { m_userDocumentation = _userDocumentation; } diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 6c3f52bc..1b42c499 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -35,6 +35,7 @@ #include #include #include +#include namespace dev { @@ -343,11 +344,11 @@ public: /// Returns the fallback function or nullptr if no fallback function was specified. FunctionDefinition const* fallbackFunction() const; - std::string const& userDocumentation() const; - void setUserDocumentation(std::string const& _userDocumentation); + Json::Value const& userDocumentation() const; + void setUserDocumentation(Json::Value const& _userDocumentation); - std::string const& devDocumentation() const; - void setDevDocumentation(std::string const& _devDocumentation); + Json::Value const& devDocumentation() const; + void setDevDocumentation(Json::Value const& _devDocumentation); virtual TypePointer type() const override; @@ -359,8 +360,8 @@ private: bool m_isLibrary; // parsed Natspec documentation of the contract. - std::string m_userDocumentation; - std::string m_devDocumentation; + Json::Value m_userDocumentation; + Json::Value m_devDocumentation; std::vector m_linearizedBaseContracts; mutable std::unique_ptr, FunctionTypePointer>>> m_interfaceFunctionList; diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index efbbd237..519027bc 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -345,17 +345,17 @@ map CompilerStack::sourceIndices() const return indices; } -string const& CompilerStack::interface(string const& _contractName) const +Json::Value const& CompilerStack::interface(string const& _contractName) const { return metadata(_contractName, DocumentationType::ABIInterface); } -string const& CompilerStack::metadata(string const& _contractName, DocumentationType _type) const +Json::Value const& CompilerStack::metadata(string const& _contractName, DocumentationType _type) const { if (!m_parseSuccessful) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful.")); - std::unique_ptr* doc; + std::unique_ptr* doc; Contract const& currentContract = contract(_contractName); // checks wheather we already have the documentation @@ -376,7 +376,7 @@ string const& CompilerStack::metadata(string const& _contractName, Documentation // caches the result if (!*doc) - doc->reset(new string(InterfaceHandler::documentation(*currentContract.contract, _type))); + doc->reset(new Json::Value(InterfaceHandler::documentation(*currentContract.contract, _type))); return *(*doc); } diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index da479638..1fd30c4d 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -162,14 +162,14 @@ public: /// @returns a mapping assigning each source name its index inside the vector returned /// by sourceNames(). std::map sourceIndices() const; - /// @returns a string representing the contract interface in JSON. + /// @returns a JSON representing the contract interface. /// Prerequisite: Successful call to parse or compile. - std::string const& interface(std::string const& _contractName = "") const; - /// @returns a string representing the contract's documentation in JSON. + Json::Value const& interface(std::string const& _contractName = "") const; + /// @returns a JSON representing the contract's documentation. /// Prerequisite: Successful call to parse or compile. /// @param type The type of the documentation to get. /// Can be one of 4 types defined at @c DocumentationType - std::string const& metadata(std::string const& _contractName, DocumentationType _type) const; + Json::Value const& metadata(std::string const& _contractName, DocumentationType _type) const; /// @returns the previously used scanner, useful for counting lines during error reporting. Scanner const& scanner(std::string const& _sourceName = "") const; @@ -213,9 +213,9 @@ private: eth::LinkerObject object; eth::LinkerObject runtimeObject; eth::LinkerObject cloneObject; - mutable std::unique_ptr interface; - mutable std::unique_ptr userDocumentation; - mutable std::unique_ptr devDocumentation; + mutable std::unique_ptr interface; + mutable std::unique_ptr userDocumentation; + mutable std::unique_ptr devDocumentation; mutable std::unique_ptr sourceMapping; mutable std::unique_ptr runtimeSourceMapping; }; diff --git a/libsolidity/interface/InterfaceHandler.cpp b/libsolidity/interface/InterfaceHandler.cpp index 1686f9ea..5705856c 100644 --- a/libsolidity/interface/InterfaceHandler.cpp +++ b/libsolidity/interface/InterfaceHandler.cpp @@ -8,7 +8,7 @@ using namespace std; using namespace dev; using namespace dev::solidity; -string InterfaceHandler::documentation( +Json::Value InterfaceHandler::documentation( ContractDefinition const& _contractDef, DocumentationType _type ) @@ -24,10 +24,9 @@ string InterfaceHandler::documentation( } BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type")); - return ""; } -string InterfaceHandler::abiInterface(ContractDefinition const& _contractDef) +Json::Value InterfaceHandler::abiInterface(ContractDefinition const& _contractDef) { Json::Value abi(Json::arrayValue); @@ -104,12 +103,10 @@ string InterfaceHandler::abiInterface(ContractDefinition const& _contractDef) abi.append(event); } - Json::FastWriter writer; - writer.omitEndingLineFeed(); - return writer.write(abi); + return abi; } -string InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) +Json::Value InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) { Json::Value doc; Json::Value methods(Json::objectValue); @@ -129,10 +126,10 @@ string InterfaceHandler::userDocumentation(ContractDefinition const& _contractDe } doc["methods"] = methods; - return Json::StyledWriter().write(doc); + return doc; } -string InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef) +Json::Value InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef) { Json::Value doc; Json::Value methods(Json::objectValue); @@ -178,7 +175,7 @@ string InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef } doc["methods"] = methods; - return Json::StyledWriter().write(doc); + return doc; } string InterfaceHandler::extractDoc(multimap const& _tags, string const& _name) diff --git a/libsolidity/interface/InterfaceHandler.h b/libsolidity/interface/InterfaceHandler.h index 54199e4e..d4f2eaf4 100644 --- a/libsolidity/interface/InterfaceHandler.h +++ b/libsolidity/interface/InterfaceHandler.h @@ -64,24 +64,24 @@ public: /// @param _contractDef The contract definition /// @param _type The type of the documentation. Can be one of the /// types provided by @c DocumentationType - /// @return A string with the json representation of provided type - static std::string documentation( + /// @return A JSON representation of provided type + static Json::Value documentation( ContractDefinition const& _contractDef, DocumentationType _type ); /// Get the ABI Interface of the contract /// @param _contractDef The contract definition - /// @return A string with the json representation of the contract's ABI Interface - static std::string abiInterface(ContractDefinition const& _contractDef); + /// @return A JSONrepresentation of the contract's ABI Interface + static Json::Value abiInterface(ContractDefinition const& _contractDef); /// Get the User documentation of the contract /// @param _contractDef The contract definition - /// @return A string with the json representation of the contract's user documentation - static std::string userDocumentation(ContractDefinition const& _contractDef); + /// @return A JSON representation of the contract's user documentation + static Json::Value userDocumentation(ContractDefinition const& _contractDef); /// Genereates the Developer's documentation of the contract /// @param _contractDef The contract definition - /// @return A string with the json representation + /// @return A JSON representation /// of the contract's developer documentation - static std::string devDocumentation(ContractDefinition const& _contractDef); + static Json::Value devDocumentation(ContractDefinition const& _contractDef); private: /// @returns concatenation of all content under the given tag name. diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 83168f86..5509a414 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -107,6 +107,18 @@ static void version() exit(0); } +string jsonPrettyPrint(Json::Value const& input) +{ + return Json::StyledWriter().write(input); +} + +string jsonCompactPrint(Json::Value const& input) +{ + Json::FastWriter writer; + writer.omitEndingLineFeed(); + return writer.write(input); +} + static bool needsHumanTargetedStdout(po::variables_map const& _args) { if (_args.count(g_argGas)) @@ -230,12 +242,18 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co if (m_args.count(argName)) { + std::string output; + if (_type == DocumentationType::ABIInterface) + output = jsonCompactPrint(m_compiler->metadata(_contract, _type)); + else + output = jsonPrettyPrint(m_compiler->metadata(_contract, _type)); + if (m_args.count("output-dir")) - createFile(_contract + suffix, m_compiler->metadata(_contract, _type)); + createFile(_contract + suffix, output); else { cout << title << endl; - cout << m_compiler->metadata(_contract, _type) << endl; + cout << output << endl; } } @@ -651,7 +669,7 @@ void CommandLineInterface::handleCombinedJSON() { Json::Value contractData(Json::objectValue); if (requests.count("abi")) - contractData["abi"] = m_compiler->interface(contractName); + contractData["abi"] = jsonCompactPrint(m_compiler->interface(contractName)); if (requests.count("bin")) contractData["bin"] = m_compiler->object(contractName).toHex(); if (requests.count("bin-runtime")) @@ -676,9 +694,9 @@ void CommandLineInterface::handleCombinedJSON() contractData["srcmap-runtime"] = map ? *map : ""; } if (requests.count("devdoc")) - contractData["devdoc"] = m_compiler->metadata(contractName, DocumentationType::NatspecDev); + contractData["devdoc"] = jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecDev)); if (requests.count("userdoc")) - contractData["userdoc"] = m_compiler->metadata(contractName, DocumentationType::NatspecUser); + contractData["userdoc"] = jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecUser)); output["contracts"][contractName] = contractData; } @@ -702,7 +720,7 @@ void CommandLineInterface::handleCombinedJSON() output["sources"][sourceCode.first]["AST"] = converter.json(); } } - cout << Json::FastWriter().write(output) << endl; + cout << jsonCompactPrint(output) << endl; } void CommandLineInterface::handleAst(string const& _argStr) diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index e5be8404..52f796a5 100644 --- a/solc/jsonCompiler.cpp +++ b/solc/jsonCompiler.cpp @@ -125,6 +125,13 @@ Json::Value estimateGas(CompilerStack const& _compiler, string const& _contract) return gasEstimates; } +string jsonCompactPrint(Json::Value const& input) +{ + Json::FastWriter writer; + writer.omitEndingLineFeed(); + return writer.write(input); +} + string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback _readCallback) { Json::Value output(Json::objectValue); @@ -213,7 +220,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback for (string const& contractName: compiler.contractNames()) { Json::Value contractData(Json::objectValue); - contractData["interface"] = compiler.interface(contractName); + contractData["interface"] = jsonCompactPrint(compiler.interface(contractName)); contractData["bytecode"] = compiler.object(contractName).toHex(); contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex(); contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode); @@ -274,7 +281,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback try { - return Json::FastWriter().write(output); + return jsonCompactPrint(output); } catch (...) { @@ -292,7 +299,7 @@ string compileMulti(string const& _input, bool _optimize, CStyleReadFileCallback errors.append("Error parsing input JSON: " + reader.getFormattedErrorMessages()); Json::Value output(Json::objectValue); output["errors"] = errors; - return Json::FastWriter().write(output); + return jsonCompactPrint(output); } else { -- cgit From 9205662de9416ab160db7327a6022ea8b1fba3e1 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 15 Nov 2016 17:20:24 +0000 Subject: Update tests to use JSON --- test/libsolidity/SolidityABIJSON.cpp | 4 +--- test/libsolidity/SolidityNatspecJSON.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index 073d7d97..0566f253 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -40,9 +40,7 @@ public: void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString) { ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse("pragma solidity >=0.0;\n" + _code), "Parsing contract failed"); - std::string generatedInterfaceString = m_compilerStack.metadata("", DocumentationType::ABIInterface); - Json::Value generatedInterface; - m_reader.parse(generatedInterfaceString, generatedInterface); + Json::Value generatedInterface = m_compilerStack.metadata("", DocumentationType::ABIInterface); Json::Value expectedInterface; m_reader.parse(_expectedInterfaceString, expectedInterface); BOOST_CHECK_MESSAGE( diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 1f74e928..facfcda7 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -45,21 +45,19 @@ public: bool _userDocumentation ) { - std::string generatedDocumentationString; + Json::Value generatedDocumentation; ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse("pragma solidity >=0.0;\n" + _code), "Parsing failed"); if (_userDocumentation) - generatedDocumentationString = m_compilerStack.metadata("", DocumentationType::NatspecUser); + generatedDocumentation = m_compilerStack.metadata("", DocumentationType::NatspecUser); else - generatedDocumentationString = m_compilerStack.metadata("", DocumentationType::NatspecDev); - Json::Value generatedDocumentation; - m_reader.parse(generatedDocumentationString, generatedDocumentation); + generatedDocumentation = m_compilerStack.metadata("", DocumentationType::NatspecDev); Json::Value expectedDocumentation; m_reader.parse(_expectedDocumentationString, expectedDocumentation); BOOST_CHECK_MESSAGE( expectedDocumentation == generatedDocumentation, "Expected " << _expectedDocumentationString << - "\n but got:\n" << generatedDocumentationString + "\n but got:\n" << Json::StyledWriter().write(generatedDocumentation) ); } -- cgit From 81c50143f2bff6f589ab1237d68c8820107f18b9 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 15 Nov 2016 17:33:28 +0000 Subject: Move JSON helpers to libdevcore/json --- libdevcore/JSON.h | 44 ++++++++++++++++++++++++++++++++ solc/CommandLineInterface.cpp | 25 +++++------------- solc/jsonCompiler.cpp | 14 +++------- test/libsolidity/SolidityNatspecJSON.cpp | 3 ++- 4 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 libdevcore/JSON.h diff --git a/libdevcore/JSON.h b/libdevcore/JSON.h new file mode 100644 index 00000000..7876dfb2 --- /dev/null +++ b/libdevcore/JSON.h @@ -0,0 +1,44 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum 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. + + cpp-ethereum 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 cpp-ethereum. If not, see . +*/ +/** @file JSON.h + * @date 2016 + * + * JSON related helpers + */ + +#pragma once + +#include + +namespace dev +{ + +/// Serialise the JSON object (@a _input) with identation +std::string jsonPrettyPrint(Json::Value const& _input) +{ + return Json::StyledWriter().write(_input); +} + +/// Serialise theJ SON object (@a _input) without identation +std::string jsonCompactPrint(Json::Value const& _input) +{ + Json::FastWriter writer; + writer.omitEndingLineFeed(); + return writer.write(_input); +} + +} diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 5509a414..7b23f886 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -107,18 +108,6 @@ static void version() exit(0); } -string jsonPrettyPrint(Json::Value const& input) -{ - return Json::StyledWriter().write(input); -} - -string jsonCompactPrint(Json::Value const& input) -{ - Json::FastWriter writer; - writer.omitEndingLineFeed(); - return writer.write(input); -} - static bool needsHumanTargetedStdout(po::variables_map const& _args) { if (_args.count(g_argGas)) @@ -244,9 +233,9 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co { std::string output; if (_type == DocumentationType::ABIInterface) - output = jsonCompactPrint(m_compiler->metadata(_contract, _type)); + output = dev::jsonCompactPrint(m_compiler->metadata(_contract, _type)); else - output = jsonPrettyPrint(m_compiler->metadata(_contract, _type)); + output = dev::jsonPrettyPrint(m_compiler->metadata(_contract, _type)); if (m_args.count("output-dir")) createFile(_contract + suffix, output); @@ -669,7 +658,7 @@ void CommandLineInterface::handleCombinedJSON() { Json::Value contractData(Json::objectValue); if (requests.count("abi")) - contractData["abi"] = jsonCompactPrint(m_compiler->interface(contractName)); + contractData["abi"] = dev::jsonCompactPrint(m_compiler->interface(contractName)); if (requests.count("bin")) contractData["bin"] = m_compiler->object(contractName).toHex(); if (requests.count("bin-runtime")) @@ -694,9 +683,9 @@ void CommandLineInterface::handleCombinedJSON() contractData["srcmap-runtime"] = map ? *map : ""; } if (requests.count("devdoc")) - contractData["devdoc"] = jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecDev)); + contractData["devdoc"] = dev::jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecDev)); if (requests.count("userdoc")) - contractData["userdoc"] = jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecUser)); + contractData["userdoc"] = dev::jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecUser)); output["contracts"][contractName] = contractData; } @@ -720,7 +709,7 @@ void CommandLineInterface::handleCombinedJSON() output["sources"][sourceCode.first]["AST"] = converter.json(); } } - cout << jsonCompactPrint(output) << endl; + cout << dev::jsonCompactPrint(output) << endl; } void CommandLineInterface::handleAst(string const& _argStr) diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index 52f796a5..771f0df8 100644 --- a/solc/jsonCompiler.cpp +++ b/solc/jsonCompiler.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -125,13 +126,6 @@ Json::Value estimateGas(CompilerStack const& _compiler, string const& _contract) return gasEstimates; } -string jsonCompactPrint(Json::Value const& input) -{ - Json::FastWriter writer; - writer.omitEndingLineFeed(); - return writer.write(input); -} - string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback _readCallback) { Json::Value output(Json::objectValue); @@ -220,7 +214,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback for (string const& contractName: compiler.contractNames()) { Json::Value contractData(Json::objectValue); - contractData["interface"] = jsonCompactPrint(compiler.interface(contractName)); + contractData["interface"] = dev::jsonCompactPrint(compiler.interface(contractName)); contractData["bytecode"] = compiler.object(contractName).toHex(); contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex(); contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode); @@ -281,7 +275,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback try { - return jsonCompactPrint(output); + return dev::jsonCompactPrint(output); } catch (...) { @@ -299,7 +293,7 @@ string compileMulti(string const& _input, bool _optimize, CStyleReadFileCallback errors.append("Error parsing input JSON: " + reader.getFormattedErrorMessages()); Json::Value output(Json::objectValue); output["errors"] = errors; - return jsonCompactPrint(output); + return dev::jsonCompactPrint(output); } else { diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index facfcda7..f05542b1 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace dev { @@ -57,7 +58,7 @@ public: BOOST_CHECK_MESSAGE( expectedDocumentation == generatedDocumentation, "Expected " << _expectedDocumentationString << - "\n but got:\n" << Json::StyledWriter().write(generatedDocumentation) + "\n but got:\n" << dev::jsonPrettyPrint(generatedDocumentation) ); } -- cgit From 227f6aab4f96003e0f7c99194a9ea1095041970f Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 15 Nov 2016 17:37:18 +0000 Subject: Change natspec/abi JSON expected message to be the same --- test/libsolidity/SolidityABIJSON.cpp | 4 +++- test/libsolidity/SolidityNatspecJSON.cpp | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index 0566f253..0ad9e928 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -40,12 +40,14 @@ public: void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString) { ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse("pragma solidity >=0.0;\n" + _code), "Parsing contract failed"); + Json::Value generatedInterface = m_compilerStack.metadata("", DocumentationType::ABIInterface); Json::Value expectedInterface; m_reader.parse(_expectedInterfaceString, expectedInterface); BOOST_CHECK_MESSAGE( expectedInterface == generatedInterface, - "Expected:\n" << expectedInterface.toStyledString() << "\n but got:\n" << generatedInterface.toStyledString() + "Expected:\n" << expectedInterface.toStyledString() << + "\n but got:\n" << generatedInterface.toStyledString() ); } diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index f05542b1..49844f15 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -26,7 +26,6 @@ #include #include #include -#include namespace dev { @@ -46,9 +45,9 @@ public: bool _userDocumentation ) { - Json::Value generatedDocumentation; ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse("pragma solidity >=0.0;\n" + _code), "Parsing failed"); + Json::Value generatedDocumentation; if (_userDocumentation) generatedDocumentation = m_compilerStack.metadata("", DocumentationType::NatspecUser); else @@ -57,8 +56,8 @@ public: m_reader.parse(_expectedDocumentationString, expectedDocumentation); BOOST_CHECK_MESSAGE( expectedDocumentation == generatedDocumentation, - "Expected " << _expectedDocumentationString << - "\n but got:\n" << dev::jsonPrettyPrint(generatedDocumentation) + "Expected " << expectedDocumentation.toStyledString() << + "\n but got:\n" << generatedDocumentation.toStyledString() ); } -- cgit