From 54965fb0aeace0d1cc1d1343d8060d5e6a3a5e70 Mon Sep 17 00:00:00 2001 From: andy53 Date: Mon, 24 Oct 2022 13:22:39 -0600 Subject: [PATCH] fix emit statments being printed on the same line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update test/libsolidity/semanticTests/emit_three_identical_events.sol Co-authored-by: Kamil Śliwak Update test/libsolidity/semanticTests/emit_two_identical_events.sol Co-authored-by: Nikola Matić --- .../semanticTests/emit_three_identical_events.sol | 14 ++++++++++++++ .../semanticTests/emit_two_identical_events.sol | 12 ++++++++++++ test/libsolidity/util/TestFunctionCall.cpp | 10 ++++------ 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 test/libsolidity/semanticTests/emit_three_identical_events.sol create mode 100644 test/libsolidity/semanticTests/emit_two_identical_events.sol diff --git a/test/libsolidity/semanticTests/emit_three_identical_events.sol b/test/libsolidity/semanticTests/emit_three_identical_events.sol new file mode 100644 index 000000000..dec367e1b --- /dev/null +++ b/test/libsolidity/semanticTests/emit_three_identical_events.sol @@ -0,0 +1,14 @@ +contract C { + event Terminated(); + + function terminate() external { + emit Terminated(); + emit Terminated(); + emit Terminated(); + } +} +// ---- +// terminate() -> +// ~ emit Terminated() +// ~ emit Terminated() +// ~ emit Terminated() \ No newline at end of file diff --git a/test/libsolidity/semanticTests/emit_two_identical_events.sol b/test/libsolidity/semanticTests/emit_two_identical_events.sol new file mode 100644 index 000000000..85cdceafc --- /dev/null +++ b/test/libsolidity/semanticTests/emit_two_identical_events.sol @@ -0,0 +1,12 @@ +contract C { + event Terminated(); + + function terminate() external { + emit Terminated(); + emit Terminated(); + } +} +// ---- +// terminate() -> +// ~ emit Terminated() +// ~ emit Terminated() \ No newline at end of file diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index 7531d8ce5..a50b3caf0 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -208,12 +208,10 @@ string TestFunctionCall::format( if (!sideEffects.empty()) { stream << std::endl; - for (string const& effect: sideEffects) - { - stream << _linePrefix << "// ~ " << effect; - if (effect != *sideEffects.rbegin()) - stream << std::endl; - } + size_t i = 0; + for (; i < sideEffects.size() - 1; ++i) + stream << _linePrefix << "// ~ " << sideEffects[i] << std::endl; + stream << _linePrefix << "// ~ " << sideEffects[i]; } stream << formatGasExpectations(_linePrefix, _renderMode == RenderMode::ExpectedValuesActualGas, _interactivePrint);