Skip to content

Commit db5f1f7

Browse files
committed
Remove unnecessary namespace prefixes, some aliases and unused imports from a few test casees
1 parent ce8ca0a commit db5f1f7

20 files changed

+84
-86
lines changed

libevmasm/Assembly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
#include <range/v3/view/enumerate.hpp>
4444
#include <range/v3/view/map.hpp>
4545

46-
#include <fstream>
4746
#include <limits>
4847
#include <iterator>
48+
#include <ostream>
4949
#include <stack>
5050

5151
using namespace solidity;

test/Common.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void CommonOptions::addOptions()
113113
("evm-version", po::value(&evmVersionString), "which EVM version to use")
114114
// "eof-version" is declared as uint64_t, since uint8_t will be parsed as character by boost.
115115
("eof-version", po::value<uint64_t>()->implicit_value(1u), "which EOF version to use")
116-
("testpath", po::value<fs::path>(&this->testPath)->default_value(solidity::test::testPath()), "path to test files")
116+
("testpath", po::value<fs::path>(&this->testPath)->default_value(test::testPath()), "path to test files")
117117
("vm", po::value<std::vector<fs::path>>(&vmPaths), "path to evmc library, can be supplied multiple times.")
118118
("batches", po::value<size_t>(&this->batches)->default_value(1), "set number of batches to split the tests into")
119119
("selected-batch", po::value<size_t>(&this->selectedBatch)->default_value(0), "zero-based number of batch to execute")
@@ -309,7 +309,7 @@ bool isValidSemanticTestPath(boost::filesystem::path const& _testPath)
309309
boost::unit_test::precondition::predicate_t nonEOF()
310310
{
311311
return [](boost::unit_test::test_unit_id) {
312-
return !solidity::test::CommonOptions::get().eofVersion().has_value();
312+
return !CommonOptions::get().eofVersion().has_value();
313313
};
314314
}
315315

@@ -325,13 +325,13 @@ bool loadVMs(CommonOptions const& _options)
325325
if (_options.disableSemanticTests)
326326
return true;
327327

328-
bool evmSupported = solidity::test::EVMHost::checkVmPaths(_options.vmPaths);
328+
bool evmSupported = EVMHost::checkVmPaths(_options.vmPaths);
329329
if (!_options.disableSemanticTests && !evmSupported)
330330
{
331-
std::cerr << "Unable to find " << solidity::test::evmoneFilename;
331+
std::cerr << "Unable to find " << evmoneFilename;
332332
std::cerr << ". Please disable semantics tests with --no-semantic-tests or provide a path using --vm <path>." << std::endl;
333333
std::cerr << "You can download it at" << std::endl;
334-
std::cerr << solidity::test::evmoneDownloadLink << std::endl;
334+
std::cerr << evmoneDownloadLink << std::endl;
335335
return false;
336336
}
337337
return true;

test/CommonSyntaxTest.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include <boost/test/unit_test.hpp>
3131
#include <boost/throw_exception.hpp>
3232

33-
#include <fstream>
34-
#include <memory>
33+
#include <istream>
34+
#include <ostream>
3535
#include <stdexcept>
3636

3737
using namespace solidity;
@@ -42,7 +42,6 @@ using namespace solidity::frontend;
4242
using namespace solidity::frontend::test;
4343
using namespace solidity::test;
4444
using namespace boost::unit_test;
45-
namespace fs = boost::filesystem;
4645

4746
namespace
4847
{

test/CommonSyntaxTest.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <iosfwd>
2828
#include <string>
2929
#include <vector>
30-
#include <utility>
3130

3231
namespace solidity::test
3332
{

test/ExecutionFramework.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#include <libsolutil/FunctionSelector.h>
3535
#include <libsolutil/ErrorCodes.h>
3636

37-
#include <functional>
38-
3937
#include <boost/rational.hpp>
4038
#include <boost/test/unit_test.hpp>
4139

test/InteractiveTests.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
#pragma once
2020

2121
#include <test/TestCase.h>
22+
2223
#include <test/libsolidity/ABIJsonTest.h>
2324
#include <test/libsolidity/ASTJSONTest.h>
2425
#include <test/libsolidity/ASTPropertyTest.h>
25-
#include <libsolidity/FunctionDependencyGraphTest.h>
2626
#include <test/libsolidity/GasTest.h>
2727
#include <test/libsolidity/MemoryGuardTest.h>
2828
#include <test/libsolidity/NatspecJSONTest.h>
2929
#include <test/libsolidity/OptimizedIRCachingTest.h>
3030
#include <test/libsolidity/SyntaxTest.h>
3131
#include <test/libsolidity/SemanticTest.h>
3232
#include <test/libsolidity/SMTCheckerTest.h>
33+
3334
#include <test/libyul/ControlFlowGraphTest.h>
3435
#include <test/libyul/SSAControlFlowGraphTest.h>
3536
#include <test/libyul/EVMCodeTransformTest.h>
@@ -44,6 +45,8 @@
4445

4546
#include <test/libevmasm/EVMAssemblyTest.h>
4647

48+
#include <libsolidity/FunctionDependencyGraphTest.h>
49+
4750
#include <boost/filesystem.hpp>
4851

4952
namespace solidity::frontend::test

test/TestCase.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ using namespace solidity;
3131
using namespace solidity::frontend;
3232
using namespace solidity::frontend::test;
3333
using namespace solidity::util;
34+
using namespace solidity::test;
3435

3536
void TestCase::printSettings(std::ostream& _stream, const std::string& _linePrefix, const bool)
3637
{
@@ -123,7 +124,7 @@ void EVMVersionRestrictedTestCase::processEVMVersionSetting()
123124
if (!version)
124125
BOOST_THROW_EXCEPTION(std::runtime_error{"Invalid EVM version: \"" + versionString + "\""});
125126

126-
langutil::EVMVersion evmVersion = solidity::test::CommonOptions::get().evmVersion();
127+
langutil::EVMVersion evmVersion = CommonOptions::get().evmVersion();
127128
bool comparisonResult;
128129
if (comparator == ">")
129130
comparisonResult = evmVersion > version;
@@ -146,9 +147,9 @@ void EVMVersionRestrictedTestCase::processEVMVersionSetting()
146147

147148
void EVMVersionRestrictedTestCase::processBytecodeFormatSetting()
148149
{
149-
std::optional<uint8_t> eofVersion = solidity::test::CommonOptions::get().eofVersion();
150+
std::optional<uint8_t> eofVersion = CommonOptions::get().eofVersion();
150151
// EOF only available since Osaka
151-
solAssert(!eofVersion.has_value() || solidity::test::CommonOptions::get().evmVersion().supportsEOF());
152+
solAssert(!eofVersion.has_value() || CommonOptions::get().evmVersion().supportsEOF());
152153

153154
std::string bytecodeFormatString = m_reader.stringSetting("bytecodeFormat", "legacy,>=EOFv1");
154155
if (bytecodeFormatString == "legacy,>=EOFv1" || bytecodeFormatString == ">=EOFv1,legacy")

test/libevmasm/Optimiser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <range/v3/algorithm/any_of.hpp>
3737

3838
#include <string>
39-
#include <tuple>
4039
#include <memory>
4140

4241
using namespace solidity::langutil;

test/libsolidity/ABIJsonTest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
#include <libsolutil/JSON.h>
2727
#include <libsolutil/AnsiColorized.h>
2828

29-
#include <fstream>
29+
#include <ostream>
30+
#include <string>
3031

3132
using namespace solidity;
3233
using namespace solidity::util;
3334
using namespace solidity::frontend;
3435
using namespace solidity::frontend::test;
36+
using namespace solidity::test;
3537

3638
ABIJsonTest::ABIJsonTest(std::string const& _filename):
3739
TestCase(_filename)
@@ -48,8 +50,8 @@ TestCase::TestResult ABIJsonTest::run(std::ostream& _stream, std::string const&
4850
"",
4951
"pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n" + m_source
5052
}});
51-
compiler.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
52-
compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
53+
compiler.setEVMVersion(CommonOptions::get().evmVersion());
54+
compiler.setOptimiserSettings(CommonOptions::get().optimize);
5355
if (!compiler.parseAndAnalyze())
5456
BOOST_THROW_EXCEPTION(std::runtime_error("Parsing contract failed"));
5557

test/libsolidity/ASTJSONTest.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@
3333
#include <boost/throw_exception.hpp>
3434

3535
#include <fstream>
36-
#include <memory>
3736
#include <stdexcept>
3837

3938
using namespace solidity;
4039
using namespace solidity::langutil;
4140
using namespace solidity::frontend;
4241
using namespace solidity::frontend::test;
42+
using namespace solidity::test;
4343
using namespace solidity::util::formatting;
4444
using namespace solidity::util;
45-
namespace fs = boost::filesystem;
4645
using namespace boost::unit_test;
4746
using namespace std::string_literals;
4847

@@ -79,7 +78,7 @@ void replaceVersionWithTag(std::string& _input)
7978
{
8079
boost::algorithm::replace_all(
8180
_input,
82-
"\"" + solidity::test::CommonOptions::get().evmVersion().name() + "\"",
81+
"\"" + CommonOptions::get().evmVersion().name() + "\"",
8382
"%EVMVERSION%"
8483
);
8584
}
@@ -89,7 +88,7 @@ void replaceTagWithVersion(std::string& _input)
8988
boost::algorithm::replace_all(
9089
_input,
9190
"%EVMVERSION%",
92-
"\"" + solidity::test::CommonOptions::get().evmVersion().name() + "\""
91+
"\"" + CommonOptions::get().evmVersion().name() + "\""
9392
);
9493
}
9594

@@ -210,7 +209,7 @@ TestCase::TestResult ASTJSONTest::run(std::ostream& _stream, std::string const&
210209
{
211210
c.reset();
212211
c.setSources(sources);
213-
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
212+
c.setEVMVersion(CommonOptions::get().evmVersion());
214213

215214
if (!c.parseAndAnalyze(variant.stopAfter))
216215
{

test/libsolidity/ASTPropertyTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <queue>
3737

3838
using namespace solidity::util;
39+
using namespace solidity::test;
3940
using namespace solidity::langutil;
4041
using namespace solidity::frontend;
4142
using namespace solidity::frontend::test;
@@ -191,8 +192,8 @@ TestCase::TestResult ASTPropertyTest::run(std::ostream& _stream, std::string con
191192
"A",
192193
"pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n" + m_source
193194
}});
194-
compiler.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
195-
compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
195+
compiler.setEVMVersion(CommonOptions::get().evmVersion());
196+
compiler.setOptimiserSettings(CommonOptions::get().optimize);
196197
if (!compiler.parseAndAnalyze())
197198
BOOST_THROW_EXCEPTION(std::runtime_error(
198199
"Parsing contract failed" +

test/libsolidity/GasTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
#include <boost/filesystem.hpp>
2828
#include <boost/test/unit_test.hpp>
2929
#include <boost/throw_exception.hpp>
30-
#include <fstream>
30+
31+
#include <istream>
32+
#include <ostream>
3133
#include <stdexcept>
3234

3335
using namespace solidity::langutil;

test/libsolidity/NatspecJSONTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
#include <fmt/format.h>
2929

30-
#include <vector>
31-
3230
using namespace solidity::frontend::test;
3331
using namespace solidity::util;
3432
using namespace std::string_literals;

test/libsolidity/SemanticTest.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@
2424
#include <boost/algorithm/string/trim.hpp>
2525
#include <boost/throw_exception.hpp>
2626

27-
#include <algorithm>
2827
#include <cctype>
29-
#include <fstream>
28+
#include <istream>
3029
#include <functional>
31-
#include <memory>
3230
#include <optional>
31+
#include <ostream>
32+
#include <sstream>
3333
#include <stdexcept>
3434
#include <string>
3535
#include <utility>
3636

3737
using namespace solidity;
3838
using namespace solidity::yul;
3939
using namespace solidity::langutil;
40+
using namespace solidity::test;
4041
using namespace solidity::util;
4142
using namespace solidity::util::formatting;
4243
using namespace solidity::frontend::test;
4344
using namespace boost::algorithm;
4445
using namespace boost::unit_test;
4546
using namespace std::string_literals;
46-
namespace fs = boost::filesystem;
4747

4848
std::ostream& solidity::frontend::test::operator<<(std::ostream& _output, RequiresYulOptimizer _requiresYulOptimizer)
4949
{
@@ -88,10 +88,10 @@ SemanticTest::SemanticTest(
8888
);
8989

9090
m_runWithABIEncoderV1Only = m_reader.boolSetting("ABIEncoderV1Only", false);
91-
if (m_runWithABIEncoderV1Only && !solidity::test::CommonOptions::get().useABIEncoderV1)
91+
if (m_runWithABIEncoderV1Only && !CommonOptions::get().useABIEncoderV1)
9292
m_shouldRun = false;
9393

94-
auto const eofEnabled = solidity::test::CommonOptions::get().eofVersion().has_value();
94+
auto const eofEnabled = CommonOptions::get().eofVersion().has_value();
9595
std::string compileViaYul = m_reader.stringSetting("compileViaYul", eofEnabled ? "true" : "also");
9696

9797
if (compileViaYul == "false" && eofEnabled)
@@ -326,14 +326,14 @@ TestCase::TestResult SemanticTest::run(std::ostream& _stream, std::string const&
326326

327327
if (m_testCaseWantsYulRun && result == TestResult::Success)
328328
{
329-
if (solidity::test::CommonOptions::get().optimize)
329+
if (CommonOptions::get().optimize)
330330
result = runTest(_stream, _linePrefix, _formatted, true /* _isYulRun */);
331331
else
332332
result = tryRunTestWithYulOptimizer(_stream, _linePrefix, _formatted);
333333
}
334334

335335
if (result != TestResult::Success)
336-
solidity::test::CommonOptions::get().printSelectedOptions(
336+
CommonOptions::get().printSelectedOptions(
337337
_stream,
338338
_linePrefix,
339339
{"evmVersion", "optimize", "useABIEncoderV1", "batch"}
@@ -364,7 +364,7 @@ TestCase::TestResult SemanticTest::runTest(
364364
for (TestFunctionCall& test: m_tests)
365365
test.reset();
366366

367-
std::map<std::string, solidity::test::Address> libraries;
367+
std::map<std::string, Address> libraries;
368368

369369
bool constructed = false;
370370

@@ -703,7 +703,7 @@ bool SemanticTest::deploy(
703703
std::string const& _contractName,
704704
u256 const& _value,
705705
bytes const& _arguments,
706-
std::map<std::string, solidity::test::Address> const& _libraries
706+
std::map<std::string, Address> const& _libraries
707707
)
708708
{
709709
auto output = compileAndRunWithoutCheck(m_sources.sources, _value, _contractName, _arguments, _libraries, m_sources.mainSourceFile);

test/libsolidity/SyntaxTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <boost/test/unit_test.hpp>
2626
#include <boost/throw_exception.hpp>
2727
#include <range/v3/algorithm/find_if.hpp>
28-
#include <fstream>
28+
2929
#include <memory>
3030
#include <stdexcept>
3131

@@ -35,8 +35,8 @@ using namespace solidity::util::formatting;
3535
using namespace solidity::langutil;
3636
using namespace solidity::frontend;
3737
using namespace solidity::frontend::test;
38+
using namespace solidity::test;
3839
using namespace boost::unit_test;
39-
namespace fs = boost::filesystem;
4040

4141
SyntaxTest::SyntaxTest(
4242
std::string const& _filename,
@@ -48,7 +48,7 @@ SyntaxTest::SyntaxTest(
4848
{
4949
static std::set<std::string> const compileViaYulAllowedValues{"true", "false"};
5050

51-
auto const eofEnabled = solidity::test::CommonOptions::get().eofVersion().has_value();
51+
auto const eofEnabled = CommonOptions::get().eofVersion().has_value();
5252

5353
m_compileViaYul = m_reader.stringSetting("compileViaYul", eofEnabled ? "true" : "false");
5454
if (!util::contains(compileViaYulAllowedValues, m_compileViaYul))
@@ -133,8 +133,8 @@ void SyntaxTest::filterObtainedErrors()
133133
if(m_sources.sources.count(sourceName) == 1)
134134
{
135135
int preambleSize =
136-
static_cast<int>(compiler().charStream(sourceName).size()) -
137-
static_cast<int>(m_sources.sources[sourceName].size());
136+
static_cast<int>(compiler().charStream(sourceName).size()) -
137+
static_cast<int>(m_sources.sources[sourceName].size());
138138
solAssert(preambleSize >= 0, "");
139139

140140
// ignore the version & license pragma inserted by the testing tool when calculating locations.

test/libyul/Common.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141

4242
#include <boost/test/unit_test.hpp>
4343

44-
#include <variant>
45-
4644
using namespace solidity;
4745
using namespace solidity::frontend;
4846
using namespace solidity::yul;

0 commit comments

Comments
 (0)