aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-18 17:57:15 +0800
committerGitHub <noreply@github.com>2018-05-18 17:57:15 +0800
commit4d7b092cb4eabf7722b1161fda225e36097debc1 (patch)
tree656cd9480ea57aec1e34a057dc7002ffb4c4ac36
parent4aa2f036ce74d9a210e12ac4df928a5ecb006e28 (diff)
parent0bed065ee73c467014d5464a7d9dc2596d6e7dfc (diff)
downloaddexon-solidity-4d7b092cb4eabf7722b1161fda225e36097debc1.tar.gz
dexon-solidity-4d7b092cb4eabf7722b1161fda225e36097debc1.tar.zst
dexon-solidity-4d7b092cb4eabf7722b1161fda225e36097debc1.zip
Merge pull request #4150 from ethereum/isoltest
Tidy up tests to always have closing braces on the proper line
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp57
-rw-r--r--test/libsolidity/SolidityExpressionCompiler.cpp3
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp12
-rw-r--r--test/libsolidity/SolidityParser.cpp42
-rw-r--r--test/tools/isoltest.cpp4
5 files changed, 78 insertions, 40 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 1efcfde0..d00b174c 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -177,7 +177,8 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_return_values)
function f(bool cond, uint v) returns (uint a, uint b) {
cond ? a = v : b = v;
}
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f(bool,uint256)", true, u256(20)), encodeArgs(u256(20), u256(0)));
ABI_CHECK(callContractFunction("f(bool,uint256)", false, u256(20)), encodeArgs(u256(0), u256(20)));
@@ -2216,7 +2217,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls)
function setHelper(address haddress) {
h = Helper(haddress);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2246,7 +2248,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
function setHelper(address haddress) {
h = Helper(haddress);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2277,7 +2280,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
function setHelper(address addr) {
h = Helper(addr);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2308,7 +2312,8 @@ BOOST_AUTO_TEST_CASE(calls_to_this)
function setHelper(address addr) {
h = Helper(addr);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2343,7 +2348,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
function setHelper(address haddress) {
h = Helper(haddress);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2373,7 +2379,8 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls)
function setHelper(address addr) {
h = Helper(addr);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2403,7 +2410,8 @@ BOOST_AUTO_TEST_CASE(constructor_arguments_internal)
}
function getFlag() returns (bool ret) { return h.getFlag(); }
function getName() returns (bytes3 ret) { return h.getName(); }
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Main");
ABI_CHECK(callContractFunction("getFlag()"), encodeArgs(true));
ABI_CHECK(callContractFunction("getName()"), encodeArgs("abc"));
@@ -2506,7 +2514,8 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
}
function getName() returns (bytes3 ret) { return name; }
function setName(bytes3 _name) private { name = _name; }
- })";
+ }
+ )";
compileAndRun(sourceCode);
BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc"));
}
@@ -2632,7 +2641,8 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
function getFlag() returns (bool ret) { return h.getFlag(); }
function getName() returns (bytes3 ret) { return h.getName(); }
function getBalances() returns (uint me, uint them) { me = this.balance; them = h.balance;}
- })";
+ }
+ )";
compileAndRun(sourceCode, 22, "Main");
BOOST_REQUIRE(callContractFunction("getFlag()") == encodeArgs(true));
BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc"));
@@ -3737,7 +3747,8 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments)
{
d = sha3(a, b, c);
}
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13), encodeArgs(
@@ -4404,7 +4415,8 @@ BOOST_AUTO_TEST_CASE(inline_member_init)
b = m_b;
c = m_c;
}
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("get()"), encodeArgs(5, 6, 8));
}
@@ -4421,7 +4433,8 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence)
function Derived(){}
uint m_derived = 6;
function getDMember() returns (uint i) { return m_derived; }
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("getBMember()"), encodeArgs(5));
ABI_CHECK(callContractFunction("getDMember()"), encodeArgs(6));
@@ -4437,7 +4450,8 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence_without_constructor)
contract Derived is Base {
uint m_derived = 6;
function getDMember() returns (uint i) { return m_derived; }
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("getBMember()"), encodeArgs(5));
ABI_CHECK(callContractFunction("getDMember()"), encodeArgs(6));
@@ -5303,7 +5317,8 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base)
{}
}
contract Final is Derived(4) {
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("m_i()"), encodeArgs(4));
}
@@ -5326,7 +5341,8 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base)
{}
}
contract Final is Derived(4) {
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("m_i()"), encodeArgs(4));
}
@@ -5346,7 +5362,8 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap)
function Derived(uint i) Base(i) {}
}
contract Final is Derived(4) {
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("m_i()"), encodeArgs(4));
}
@@ -5357,7 +5374,8 @@ BOOST_AUTO_TEST_CASE(simple_constant_variables_test)
contract Foo {
function getX() returns (uint r) { return x; }
uint constant x = 56;
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("getX()"), encodeArgs(56));
}
@@ -5370,7 +5388,8 @@ BOOST_AUTO_TEST_CASE(constant_variables)
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
ActionChoices constant choices = ActionChoices.GoLeft;
bytes32 constant st = "abc\x00\xff__";
- })";
+ }
+ )";
compileAndRun(sourceCode);
}
diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp
index 90d8265c..ad26ce6b 100644
--- a/test/libsolidity/SolidityExpressionCompiler.cpp
+++ b/test/libsolidity/SolidityExpressionCompiler.cpp
@@ -249,7 +249,8 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination)
{
var x = 1 finney;
}
- })";
+ }
+ )";
bytes code = compileFirstExpression(sourceCode);
bytes expectation({byte(Instruction::PUSH7), 0x3, 0x8d, 0x7e, 0xa4, 0xc6, 0x80, 0x00});
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 5326feaf..afce1823 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -139,7 +139,8 @@ BOOST_AUTO_TEST_CASE(smoke_test)
function f(uint a) returns (uint b) {
return a;
}
- })";
+ }
+ )";
compileBothVersions(sourceCode);
compareVersions("f(uint256)", u256(7));
}
@@ -151,7 +152,8 @@ BOOST_AUTO_TEST_CASE(identities)
function f(int a) returns (int b) {
return int(0) | (int(1) * (int(0) ^ (0 + a)));
}
- })";
+ }
+ )";
compileBothVersions(sourceCode);
compareVersions("f(int256)", u256(0x12334664));
}
@@ -165,7 +167,8 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
10 + 20;
data;
}
- })";
+ }
+ )";
compileBothVersions(sourceCode);
compareVersions("f()");
}
@@ -180,7 +183,8 @@ BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
function f(uint x) returns (uint y) {
return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
}
- })";
+ }
+ )";
compileBothVersions(sourceCode);
compareVersions("f(uint256)", 7);
}
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 0c801cf6..e80b3394 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -733,7 +733,8 @@ BOOST_AUTO_TEST_CASE(event)
char const* text = R"(
contract c {
event e();
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -742,7 +743,8 @@ BOOST_AUTO_TEST_CASE(event_arguments)
char const* text = R"(
contract c {
event e(uint a, bytes32 s);
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -751,7 +753,8 @@ BOOST_AUTO_TEST_CASE(event_arguments_indexed)
char const* text = R"(
contract c {
event e(uint a, bytes32 indexed s, bool indexed b);
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -767,7 +770,8 @@ BOOST_AUTO_TEST_CASE(visibility_specifiers)
function f_priv() private {}
function f_public() public {}
function f_internal() internal {}
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -776,12 +780,14 @@ BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
char const* text = R"(
contract c {
uint private internal a;
- })";
+ }
+ )";
CHECK_PARSE_ERROR(text, "Visibility already specified as \"private\".");
text = R"(
contract c {
function f() private external {}
- })";
+ }
+ )";
CHECK_PARSE_ERROR(text, "Visibility already specified as \"private\".");
}
@@ -800,7 +806,8 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations)
uint256 b;
uint256 c;
uint256 d;
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -813,7 +820,8 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expression
a = 1 wei * 100 wei + 7 szabo - 3;
}
uint256 a;
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -827,7 +835,8 @@ BOOST_AUTO_TEST_CASE(enum_valid_declaration)
a = foo.Value3;
}
uint256 a;
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -836,7 +845,8 @@ BOOST_AUTO_TEST_CASE(external_function)
char const* text = R"(
contract c {
function x() external {}
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -848,7 +858,8 @@ BOOST_AUTO_TEST_CASE(arrays_in_storage)
uint[] a2;
struct x { uint[2**20] b; y[0] c; }
struct y { uint d; mapping(uint=>x)[] e; }
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -857,7 +868,8 @@ BOOST_AUTO_TEST_CASE(arrays_in_events)
char const* text = R"(
contract c {
event e(uint[10] a, bytes7[8] indexed b, c[3] x);
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -866,7 +878,8 @@ BOOST_AUTO_TEST_CASE(arrays_in_expressions)
char const* text = R"(
contract c {
function f() { c[10] a = 7; uint8[10 * 2] x; }
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
@@ -875,7 +888,8 @@ BOOST_AUTO_TEST_CASE(multi_arrays)
char const* text = R"(
contract c {
mapping(uint => mapping(uint => int8)[8][][9])[] x;
- })";
+ }
+ )";
BOOST_CHECK(successParse(text));
}
diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp
index 7a147bd0..100fcbf0 100644
--- a/test/tools/isoltest.cpp
+++ b/test/tools/isoltest.cpp
@@ -99,8 +99,8 @@ void SyntaxTestTool::printContract() const
for (auto const& error: m_test->errorList())
if (error.locationStart >= 0 && error.locationEnd >= 0)
{
- assert(static_cast<size_t>(error.locationStart) < source.length());
- assert(static_cast<size_t>(error.locationEnd) < source.length());
+ assert(static_cast<size_t>(error.locationStart) <= source.length());
+ assert(static_cast<size_t>(error.locationEnd) <= source.length());
bool isWarning = error.type == "Warning";
for (int i = error.locationStart; i < error.locationEnd; i++)
if (isWarning)