From 8fb7a188008df9363eccb7497e208935743dbed9 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 25 Nov 2020 01:11:11 +0000 Subject: [PATCH] Small refactorings for isoltest --- test/libsolidity/util/TestFunctionCall.cpp | 12 +++++++++--- test/libsolidity/util/TestFunctionCall.h | 2 +- test/tools/isoltest.cpp | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index 6adf4fcaf..0e411a458 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -83,12 +83,17 @@ string TestFunctionCall::format( stream << _linePrefix << newline << ws << m_call.signature; if (m_call.value.value > u256(0)) { - if (m_call.value.unit == FunctionValueUnit::Ether) + switch (m_call.value.unit) + { + case FunctionValueUnit::Ether: stream << comma << ws << (m_call.value.value / exp256(10, 18)) << ws << ether; - else if (m_call.value.unit == FunctionValueUnit::Wei) + break; + case FunctionValueUnit::Wei: stream << comma << ws << m_call.value.value << ws << wei; - else + break; + default: soltestAssert(false, ""); + } } if (!m_call.arguments.rawBytes().empty()) { @@ -360,6 +365,7 @@ void TestFunctionCall::reset() { m_rawBytes = bytes{}; m_failure = true; + m_contractABI = Json::Value{}; m_calledNonExistingFunction = false; } diff --git a/test/libsolidity/util/TestFunctionCall.h b/test/libsolidity/util/TestFunctionCall.h index 839c86553..35ae139ad 100644 --- a/test/libsolidity/util/TestFunctionCall.h +++ b/test/libsolidity/util/TestFunctionCall.h @@ -150,7 +150,7 @@ private: bool m_failure = true; /// JSON object which holds the contract ABI and that is used to set the output formatting /// in the interactive update routine. - Json::Value m_contractABI; + Json::Value m_contractABI = Json::Value{}; /// Flags that the test failed because the called function is not known to exist on the contract. bool m_calledNonExistingFunction = false; }; diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index 91efedadb..b05cbe84a 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -151,7 +151,6 @@ bool TestTool::m_exitRequested = false; TestTool::Result TestTool::process() { bool formatted{!m_options.noColor}; - std::stringstream outputMessages; try { @@ -168,6 +167,8 @@ TestTool::Result TestTool::process() m_options.enforceGasTestMinValue }); if (m_test->shouldRun()) + { + std::stringstream outputMessages; switch (TestCase::TestResult result = m_test->run(outputMessages, " ", formatted)) { case TestCase::TestResult::Success: @@ -183,6 +184,7 @@ TestTool::Result TestTool::process() cout << endl << outputMessages.str() << endl; return result == TestCase::TestResult::FatalError ? Result::Exception : Result::Failure; } + } else { AnsiColorized(cout, formatted, {BOLD, YELLOW}) << "NOT RUN" << endl;