Merge remote-tracking branch 'origin/develop' into breaking

This commit is contained in:
chriseth
2020-12-08 21:00:09 +01:00
60 changed files with 245 additions and 179 deletions
+1 -1
View File
@@ -133,7 +133,7 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi
for (size_t i = 0; i < m_sources.size(); i++)
{
sources[m_sources[i].first] = m_sources[i].second;
sourceIndices[m_sources[i].first] = i + 1;
sourceIndices[m_sources[i].first] = static_cast<unsigned>(i + 1);
}
c.setSources(sources);
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
+7 -7
View File
@@ -39,6 +39,7 @@
#include <boost/test/unit_test.hpp>
#include <functional>
#include <numeric>
#include <string>
#include <tuple>
@@ -82,7 +83,7 @@ struct SolidityEndToEndTestExecutionFramework: public SolidityExecutionFramework
BOOST_FIXTURE_TEST_SUITE(SolidityEndToEndTest, SolidityEndToEndTestExecutionFramework)
int constexpr roundTo32(int _num)
unsigned constexpr roundTo32(unsigned _num)
{
return (_num + 31) / 32 * 32;
}
@@ -2126,8 +2127,7 @@ BOOST_AUTO_TEST_CASE(event_indexed_string)
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
string dynx(90, 0);
for (size_t i = 0; i < dynx.size(); ++i)
dynx[i] = i;
std::iota(dynx.begin(), dynx.end(), 0);
BOOST_CHECK(logData(0) == bytes());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 3);
BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(dynx));
@@ -3362,7 +3362,7 @@ BOOST_AUTO_TEST_CASE(nested_string_as_public_mapping_key)
ABI_CHECK(callContractFunction(
"set(string,string,uint256)",
u256(0x60),
u256(roundTo32(0x80 + strings[i].size())),
u256(roundTo32(static_cast<unsigned>(0x80 + strings[i].size()))),
u256(7 + i),
u256(strings[i].size()),
strings[i],
@@ -3373,7 +3373,7 @@ BOOST_AUTO_TEST_CASE(nested_string_as_public_mapping_key)
ABI_CHECK(callContractFunction(
"data(string,string)",
u256(0x40),
u256(roundTo32(0x60 + strings[i].size())),
u256(roundTo32(static_cast<unsigned>(0x60 + strings[i].size()))),
u256(strings[i].size()),
strings[i],
u256(strings[i+1].size()),
@@ -3426,7 +3426,7 @@ BOOST_AUTO_TEST_CASE(nested_mixed_string_as_public_mapping_key)
u256(0xA0),
u256(data[i].s2),
u256(data[i].s3),
u256(roundTo32(0xC0 + data[i].s1.size())),
u256(roundTo32(static_cast<unsigned>(0xC0 + data[i].s1.size()))),
u256(i - 3),
u256(data[i].s1.size()),
data[i].s1,
@@ -3439,7 +3439,7 @@ BOOST_AUTO_TEST_CASE(nested_mixed_string_as_public_mapping_key)
u256(0x80),
u256(data[i].s2),
u256(data[i].s3),
u256(roundTo32(0xA0 + data[i].s1.size())),
u256(roundTo32(static_cast<unsigned>(0xA0 + data[i].s1.size()))),
u256(data[i].s1.size()),
data[i].s1,
u256(data[i].s4.size()),
@@ -149,7 +149,7 @@ bytes compileFirstExpression(
for (vector<string> const& variable: _localVariables)
context.addVariable(
dynamic_cast<VariableDeclaration const&>(resolveDeclaration(*sourceUnit, variable, resolver)),
parametersSize--
static_cast<unsigned>(parametersSize--)
);
ExpressionCompiler(
+1 -1
View File
@@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit)
maxDuration = numeric_limits<size_t>::max();
BOOST_TEST_MESSAGE("Disabled constant optimizer run time check for address sanitizer build.");
#endif
BOOST_CHECK_MESSAGE(duration <= maxDuration, "Compilation of constants took longer than 20 seconds.");
BOOST_CHECK_MESSAGE(duration <= double(maxDuration), "Compilation of constants took longer than 20 seconds.");
compareVersions("hexEncodeTest(address)", u256(0x123456789));
}
-7
View File
@@ -262,13 +262,6 @@ BOOST_AUTO_TEST_CASE(helper_bool_result)
r5.merge(r6, logical_and<bool>());
BOOST_REQUIRE_EQUAL(r5.get(), true);
BOOST_REQUIRE_EQUAL(r5.message(), "");
BoolResult r7{true};
// Attention: this will implicitly convert to bool.
BoolResult r8("true"); // We cannot use {} initializer here because this does not allow narrowing conversion (at least MSVC breaks)
r7.merge(r8, logical_and<bool>());
BOOST_REQUIRE_EQUAL(r7.get(), true);
BOOST_REQUIRE_EQUAL(r7.message(), "");
}
BOOST_AUTO_TEST_CASE(helper_string_result)
@@ -0,0 +1,24 @@
contract A {
constructor(uint) {}
}
contract B {
constructor(uint) {}
}
contract C {
constructor(uint) {}
}
contract D {
constructor(uint) {}
}
contract X is D, C, B, A {
uint[] x;
function f(uint _x) internal returns (uint) {
x.push(_x);
}
function g() public view returns (uint[] memory) { return x; }
constructor() A(f(1)) C(f(2)) B(f(3)) D(f(4)) {}
}
// ====
// compileViaYul: also
// ----
// g() -> 0x20, 4, 1, 3, 2, 4
+3 -3
View File
@@ -264,13 +264,13 @@ string BytesUtils::formatBytes(
{
auto entropy = [](std::string const& str) -> double {
double result = 0;
map<char, int> frequencies;
map<char, double> frequencies;
for (char c: str)
frequencies[c]++;
for (auto p: frequencies)
{
double freq = static_cast<double>(p.second) / str.length();
result -= freq * (log(freq) / log(2));
double freq = p.second / double(str.length());
result -= freq * (log(freq) / log(2.0));
}
return result;
};
+4 -3
View File
@@ -682,11 +682,12 @@ string TestFileParser::Scanner::scanString()
return str;
}
// TODO: use fromHex() from CommonData
char TestFileParser::Scanner::scanHexPart()
{
advance(); // skip 'x'
char value{};
int value{};
if (isdigit(current()))
value = current() - '0';
else if (tolower(current()) >= 'a' && tolower(current()) <= 'f')
@@ -696,7 +697,7 @@ char TestFileParser::Scanner::scanHexPart()
advance();
if (current() == '"')
return value;
return static_cast<char>(value);
value <<= 4;
if (isdigit(current()))
@@ -706,5 +707,5 @@ char TestFileParser::Scanner::scanHexPart()
advance();
return value;
return static_cast<char>(value);
}