aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-07-11 21:57:07 +0800
committerErik Kundt <bitshift@posteo.org>2018-07-16 20:49:55 +0800
commit893f4cf092c98d13116741d1ebc19846f6873536 (patch)
tree9449cbeb1abd76e2ca83804caa44c9f93f916de5 /test/libsolidity
parent931794001e92cbfe99c91da037cf36a1808d9df1 (diff)
downloaddexon-solidity-893f4cf092c98d13116741d1ebc19846f6873536.tar
dexon-solidity-893f4cf092c98d13116741d1ebc19846f6873536.tar.gz
dexon-solidity-893f4cf092c98d13116741d1ebc19846f6873536.tar.bz2
dexon-solidity-893f4cf092c98d13116741d1ebc19846f6873536.tar.lz
dexon-solidity-893f4cf092c98d13116741d1ebc19846f6873536.tar.xz
dexon-solidity-893f4cf092c98d13116741d1ebc19846f6873536.tar.zst
dexon-solidity-893f4cf092c98d13116741d1ebc19846f6873536.zip
Specifies visibility in unit tests.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/ABIDecoderTests.cpp2
-rw-r--r--test/libsolidity/GasMeter.cpp26
-rw-r--r--test/libsolidity/Metadata.cpp14
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp22
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp176
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp8
-rw-r--r--test/libsolidity/StandardCompiler.cpp6
7 files changed, 127 insertions, 127 deletions
diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp
index 2cfa27d6..28f982c4 100644
--- a/test/libsolidity/ABIDecoderTests.cpp
+++ b/test/libsolidity/ABIDecoderTests.cpp
@@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(dynamic_nested_arrays)
public pure returns (uint, uint, uint, uint, uint, uint, uint) {
return (a, b.length, b[1].length, b[1][1], c[1].length, c[1][1][1], d);
}
- function test() view returns (uint, uint, uint, uint, uint, uint, uint) {
+ function test() public view returns (uint, uint, uint, uint, uint, uint, uint) {
uint16[][] memory b = new uint16[][](3);
b[0] = new uint16[](2);
b[0][0] = 0x55;
diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp
index a404c072..84e30033 100644
--- a/test/libsolidity/GasMeter.cpp
+++ b/test/libsolidity/GasMeter.cpp
@@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs)
char const* sourceCode = R"(
contract test {
bytes x;
- function f(uint a) returns (uint b) {
+ function f(uint a) public returns (uint b) {
x.length = a;
for (; a < 200; ++a) {
x[a] = 9;
@@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(simple_contract)
char const* sourceCode = R"(
contract test {
bytes32 public shaValue;
- function f(uint a) {
+ function f(uint a) public {
shaValue = keccak256(abi.encodePacked(a));
}
}
@@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(store_keccak256)
char const* sourceCode = R"(
contract test {
bytes32 public shaValue;
- constructor(uint a) {
+ constructor(uint a) public {
shaValue = keccak256(abi.encodePacked(a));
}
}
@@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(updating_store)
contract test {
uint data;
uint data2;
- constructor() {
+ constructor() public {
data = 1;
data = 2;
data2 = 0;
@@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(branches)
contract test {
uint data;
uint data2;
- function f(uint x) {
+ function f(uint x) public {
if (x > 7)
data2 = 1;
else
@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(function_calls)
contract test {
uint data;
uint data2;
- function f(uint x) {
+ function f(uint x) public {
if (x > 7)
data2 = g(x**8) + 1;
else
@@ -234,13 +234,13 @@ BOOST_AUTO_TEST_CASE(multiple_external_functions)
contract test {
uint data;
uint data2;
- function f(uint x) {
+ function f(uint x) public {
if (x > 7)
data2 = g(x**8) + 1;
else
data = 1;
}
- function g(uint x) returns (uint) {
+ function g(uint x) public returns (uint) {
return data2;
}
}
@@ -254,10 +254,10 @@ BOOST_AUTO_TEST_CASE(exponent_size)
{
char const* sourceCode = R"(
contract A {
- function g(uint x) returns (uint) {
+ function g(uint x) public returns (uint) {
return x ** 0x100;
}
- function h(uint x) returns (uint) {
+ function h(uint x) public returns (uint) {
return x ** 0x10000;
}
}
@@ -271,7 +271,7 @@ BOOST_AUTO_TEST_CASE(balance_gas)
{
char const* sourceCode = R"(
contract A {
- function lookup_balance(address a) returns (uint) {
+ function lookup_balance(address a) public returns (uint) {
return a.balance;
}
}
@@ -284,7 +284,7 @@ BOOST_AUTO_TEST_CASE(extcodesize_gas)
{
char const* sourceCode = R"(
contract A {
- function f() returns (uint _s) {
+ function f() public returns (uint _s) {
assembly {
_s := extcodesize(0x30)
}
@@ -316,7 +316,7 @@ BOOST_AUTO_TEST_CASE(complex_control_flow)
// we previously considered. This of course reduces accuracy.
char const* sourceCode = R"(
contract log {
- function ln(int128 x) pure returns (int128 result) {
+ function ln(int128 x) public pure returns (int128 result) {
int128 t = x / 256;
int128 y = 5545177;
x = t;
diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp
index 808bd1e1..007ee2b6 100644
--- a/test/libsolidity/Metadata.cpp
+++ b/test/libsolidity/Metadata.cpp
@@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
pragma solidity >=0.0;
pragma experimental __testOnlyAnalysis;
contract test {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
CompilerStack compilerStack;
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental)
pragma solidity >=0.0;
pragma experimental __test;
contract test {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
CompilerStack compilerStack;
@@ -97,14 +97,14 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources)
char const* sourceCode = R"(
pragma solidity >=0.0;
contract A {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("A", std::string(sourceCode));
sourceCode = R"(
pragma solidity >=0.0;
contract B {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("B", std::string(sourceCode));
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
char const* sourceCode = R"(
pragma solidity >=0.0;
contract A {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("A", std::string(sourceCode));
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
pragma solidity >=0.0;
import "./A";
contract B is A {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("B", std::string(sourceCode));
@@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
pragma solidity >=0.0;
import "./B";
contract C is B {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("C", std::string(sourceCode));
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index e3e06ddd..d4b355c7 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
BOOST_AUTO_TEST_CASE(multiple_methods_order)
{
- // methods are expected to be in alphabetical order
+ // methods are expected to be in alpabetical order
char const* sourceCode = R"(
contract test {
function f(uint a) public returns (uint d) { return a * 7; }
@@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(view_function)
char const* sourceCode = R"(
contract test {
function foo(uint a, uint b) public returns (uint d) { return a + b; }
- function boo(uint32 a) view returns(uint b) { return a * 4; }
+ function boo(uint32 a) public view returns(uint b) { return a * 4; }
}
)";
@@ -311,7 +311,7 @@ BOOST_AUTO_TEST_CASE(pure_function)
char const* sourceCode = R"(
contract test {
function foo(uint a, uint b) public returns (uint d) { return a + b; }
- function boo(uint32 a) pure returns(uint b) { return a * 4; }
+ function boo(uint32 a) public pure returns (uint b) { return a * 4; }
}
)";
@@ -616,7 +616,7 @@ BOOST_AUTO_TEST_CASE(constructor_abi)
{
char const* sourceCode = R"(
contract test {
- constructor(uint param1, test param2, bool param3) {}
+ constructor(uint param1, test param2, bool param3) public {}
}
)";
@@ -648,7 +648,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor_abi)
{
char const* sourceCode = R"(
contract test {
- constructor(uint param1, test param2, bool param3) payable {}
+ constructor(uint param1, test param2, bool param3) public payable {}
}
)";
@@ -682,7 +682,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- constructor(ActionChoices param) {}
+ constructor(ActionChoices param) public {}
function ret() public returns (ActionChoices) {
ActionChoices action = ActionChoices.GoLeft;
return action;
@@ -807,8 +807,8 @@ BOOST_AUTO_TEST_CASE(payable_function)
{
char const* sourceCode = R"(
contract test {
- function f() {}
- function g() payable {}
+ function f() public {}
+ function g() public payable {}
}
)";
@@ -861,7 +861,7 @@ BOOST_AUTO_TEST_CASE(function_type)
{
char const* sourceCode = R"(
contract test {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
@@ -1041,8 +1041,8 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries)
library L {
struct S { uint a; T[] sub; bytes b; }
struct T { uint[2] x; }
- function f(L.S storage s) {}
- function g(L.S memory s) {}
+ function f(L.S storage s) public {}
+ function g(L.S memory s) public {}
}
)";
char const* interface = R"(
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index be74c5ff..25c553e7 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -53,9 +53,9 @@ BOOST_AUTO_TEST_CASE(transaction_status)
{
char const* sourceCode = R"(
contract test {
- function f() { }
- function g() { revert(); }
- function h() { assert(false); }
+ function f() public { }
+ function g() public { revert(); }
+ function h() public { assert(false); }
}
)";
compileAndRun(sourceCode);
@@ -1253,7 +1253,7 @@ BOOST_AUTO_TEST_CASE(state_smoke_test)
if (which == 0) return value1;
else return value2;
}
- function set(uint8 which, uint256 value) {
+ function set(uint8 which, uint256 value) public {
if (which == 0) value1 = value;
else value2 = value;
}
@@ -1315,7 +1315,7 @@ BOOST_AUTO_TEST_CASE(simple_mapping)
function get(uint8 k) public returns (uint8 v) {
return table[k];
}
- function set(uint8 k, uint8 v) {
+ function set(uint8 k, uint8 v) public {
table[k] = v;
}
}
@@ -1349,7 +1349,7 @@ BOOST_AUTO_TEST_CASE(mapping_state)
function getVoteCount(address addr) public returns (uint retVoteCount) {
return voteCount[addr];
}
- function grantVoteRight(address addr) {
+ function grantVoteRight(address addr) public {
canVote[addr] = true;
}
function vote(address voter, address vote) public returns (bool success) {
@@ -1562,7 +1562,7 @@ BOOST_AUTO_TEST_CASE(deleteStruct)
uint nestedValue;
mapping (uint => bool) nestedMapping;
}
- constructor(){
+ constructor() public {
toDelete = 5;
str.topValue = 1;
str.topMapping[0] = 1;
@@ -2085,7 +2085,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
addr.transfer(amount);
return this.balance;
}
- function b(address addr, uint amount) {
+ function b(address addr, uint amount) public {
addr.transfer(amount);
}
}
@@ -2344,7 +2344,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
function a(bytes32 input) public returns (bytes32 hash) {
uint24 b = 65536;
uint c = 256;
- return keccak256(abi.encodePacked(uint8(8), input, b, input, c));
+ return keccak256(abi.encodePacked(8, input, b, input, c));
}
}
)";
@@ -2396,7 +2396,7 @@ BOOST_AUTO_TEST_CASE(packed_sha256)
function a(bytes32 input) public returns (bytes32 hash) {
uint24 b = 65536;
uint c = 256;
- return sha256(abi.encodePacked(uint8(8), input, b, input, c));
+ return sha256(abi.encodePacked(8, input, b, input, c));
}
}
)";
@@ -2423,7 +2423,7 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160)
function a(bytes32 input) public returns (bytes32 hash) {
uint24 b = 65536;
uint c = 256;
- return ripemd160(abi.encodePacked(uint8(8), input, b, input, c));
+ return ripemd160(abi.encodePacked(8, input, b, input, c));
}
}
)";
@@ -2477,7 +2477,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls)
function getHelper() public returns (address haddress) {
return address(h);
}
- function setHelper(address haddress) {
+ function setHelper(address haddress) public {
h = Helper(haddress);
}
}
@@ -2508,7 +2508,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
function getHelper() public returns (address haddress) {
return address(h);
}
- function setHelper(address haddress) {
+ function setHelper(address haddress) public {
h = Helper(haddress);
}
}
@@ -2540,7 +2540,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
function getHelper() public returns (address addr) {
return address(h);
}
- function setHelper(address addr) {
+ function setHelper(address addr) public {
h = Helper(addr);
}
}
@@ -2572,7 +2572,7 @@ BOOST_AUTO_TEST_CASE(calls_to_this)
function getHelper() public returns (address addr) {
return address(h);
}
- function setHelper(address addr) {
+ function setHelper(address addr) public {
h = Helper(addr);
}
}
@@ -2607,7 +2607,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
function getHelper() public returns (address haddress) {
return address(h);
}
- function setHelper(address haddress) {
+ function setHelper(address haddress) public {
h = Helper(haddress);
}
}
@@ -2638,7 +2638,7 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls)
function getHelper() public returns (address addr) {
return address(h);
}
- function setHelper(address addr) {
+ function setHelper(address addr) public {
h = Helper(addr);
}
}
@@ -2847,7 +2847,7 @@ BOOST_AUTO_TEST_CASE(value_complex)
contract test {
helper h;
constructor() public payable { h = new helper(); }
- function sendAmount(uint amount) payable returns (uint256 bal) {
+ function sendAmount(uint amount) public payable returns (uint256 bal) {
uint someStackElement = 20;
return h.getBalance.value(amount).gas(1000).value(amount + 3)();
}
@@ -2883,7 +2883,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
contract Helper {
bytes3 name;
bool flag;
- constructor(bytes3 x, bool f) payable {
+ constructor(bytes3 x, bool f) public payable {
name = x;
flag = f;
}
@@ -2892,7 +2892,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
}
contract Main {
Helper h;
- constructor() payable {
+ constructor() public payable {
h = (new Helper).value(10)("abc", true);
}
function getFlag() public returns (bool ret) { return h.getFlag(); }
@@ -2953,10 +2953,10 @@ BOOST_AUTO_TEST_CASE(single_copy_with_multiple_inheritance)
char const* sourceCode = R"(
contract Base {
uint data;
- function setData(uint i) { data = i; }
+ function setData(uint i) public { data = i; }
function getViaBase() public returns (uint i) { return data; }
}
- contract A is Base { function setViaA(uint i) { setData(i); } }
+ contract A is Base { function setViaA(uint i) public { setData(i); } }
contract B is Base { function getViaB() public returns (uint i) { return getViaBase(); } }
contract Derived is Base, B, A { }
)";
@@ -3165,7 +3165,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_for_constructor)
char const* sourceCode = R"(
contract A {
uint data;
- constructor() mod1 { data |= 2; }
+ constructor() mod1 public { data |= 2; }
modifier mod1 { data |= 1; _; }
function getData() public returns (uint r) { return data; }
}
@@ -3375,7 +3375,7 @@ BOOST_AUTO_TEST_CASE(event)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
- function deposit(bytes32 _id, bool _manually) payable {
+ function deposit(bytes32 _id, bool _manually) public payable {
if (_manually) {
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
log3(bytes32(msg.value), s, bytes32(uint256(msg.sender)), _id);
@@ -3406,7 +3406,7 @@ BOOST_AUTO_TEST_CASE(event_emit)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
- function deposit(bytes32 _id) payable {
+ function deposit(bytes32 _id) public payable {
emit Deposit(msg.sender, _id, msg.value);
}
}
@@ -3584,7 +3584,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous;
- function deposit(bytes32 _id) payable {
+ function deposit(bytes32 _id) public payable {
emit Deposit(msg.sender, _id, msg.value, 2, "abc");
}
}
@@ -3608,7 +3608,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(address _from, bytes32 _id, uint _value, bool _flag);
- function deposit(bytes32 _id) payable {
+ function deposit(bytes32 _id) public payable {
emit Deposit(msg.sender, _id, msg.value, true);
}
}
@@ -3822,7 +3822,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_numeric_literals)
contract c {
function foo(uint a, uint16 b) public returns (bytes32 d)
{
- d = keccak256(abi.encodePacked(a, b, uint8(145)));
+ d = keccak256(abi.encodePacked(a, b, 145));
}
}
)";
@@ -3847,7 +3847,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_string_literals)
}
function bar(uint a, uint16 b) public returns (bytes32 d)
{
- d = keccak256(abi.encodePacked(a, b, uint8(145), "foo"));
+ d = keccak256(abi.encodePacked(a, b, 145, "foo"));
}
}
)";
@@ -3910,7 +3910,7 @@ BOOST_AUTO_TEST_CASE(generic_call)
char const* sourceCode = R"**(
contract receiver {
uint public received;
- function receive(uint256 x) payable { received = x; }
+ function receive(uint256 x) public payable { received = x; }
}
contract sender {
constructor() public payable {}
@@ -3936,15 +3936,15 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
uint public received;
address public sender;
uint public value;
- constructor() payable {}
- function receive(uint256 x) payable { received = x; sender = msg.sender; value = msg.value; }
+ constructor() public payable {}
+ function receive(uint256 x) public payable { received = x; sender = msg.sender; value = msg.value; }
}
contract Sender {
uint public received;
address public sender;
uint public value;
- constructor() payable {}
- function doSend(address rec) payable
+ constructor() public payable {}
+ function doSend(address rec) public payable
{
bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)")));
if (rec.delegatecall(abi.encodeWithSelector(signature, 23))) {}
@@ -4130,7 +4130,7 @@ BOOST_AUTO_TEST_CASE(copying_bytes_multiassign)
char const* sourceCode = R"(
contract receiver {
uint public received;
- function receive(uint x) { received += x + 1; }
+ function receive(uint x) public { received += x + 1; }
function() external { received = 0x80; }
}
contract sender {
@@ -4349,7 +4349,7 @@ BOOST_AUTO_TEST_CASE(using_enums)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- constructor()
+ constructor() public
{
choices = ActionChoices.GoStraight;
}
@@ -4369,7 +4369,7 @@ BOOST_AUTO_TEST_CASE(enum_explicit_overflow)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight }
- constructor()
+ constructor() public
{
}
function getChoiceExp(uint x) public returns (uint d)
@@ -4514,7 +4514,7 @@ BOOST_AUTO_TEST_CASE(inline_member_init)
{
char const* sourceCode = R"(
contract test {
- constructor(){
+ constructor() public {
m_b = 6;
m_c = 8;
}
@@ -4536,12 +4536,12 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence)
{
char const* sourceCode = R"(
contract Base {
- constructor(){}
+ constructor() public {}
uint m_base = 5;
function getBMember() public returns (uint i) { return m_base; }
}
contract Derived is Base {
- constructor(){}
+ constructor() public {}
uint m_derived = 6;
function getDMember() public returns (uint i) { return m_derived; }
}
@@ -4588,8 +4588,8 @@ BOOST_AUTO_TEST_CASE(bytes_in_arguments)
char const* sourceCode = R"(
contract c {
uint result;
- function f(uint a, uint b) { result += a + b; }
- function g(uint a) { result *= a; }
+ function f(uint a, uint b) public { result += a + b; }
+ function g(uint a) public { result *= a; }
function test(uint a, bytes data1, bytes data2, uint b) external returns (uint r_a, uint r, uint r_b, uint l) {
r_a = a;
this.call(data1);
@@ -4621,9 +4621,9 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_in_storage)
struct Data { uint x; uint y; }
Data[2**10] data;
uint[2**10 + 3] ids;
- function setIDStatic(uint id) { ids[2] = id; }
- function setID(uint index, uint id) { ids[index] = id; }
- function setData(uint index, uint x, uint y) { data[index].x = x; data[index].y = y; }
+ function setIDStatic(uint id) public { ids[2] = id; }
+ function setID(uint index, uint id) public { ids[index] = id; }
+ function setData(uint index, uint x, uint y) public { data[index].x = x; data[index].y = y; }
function getID(uint index) public returns (uint) { return ids[index]; }
function getData(uint index) public returns (uint x, uint y) { x = data[index].x; y = data[index].y; }
function getLengths() public returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; }
@@ -4648,13 +4648,13 @@ BOOST_AUTO_TEST_CASE(dynamic_arrays_in_storage)
struct Data { uint x; uint y; }
Data[] data;
uint[] ids;
- function setIDStatic(uint id) { ids[2] = id; }
- function setID(uint index, uint id) { ids[index] = id; }
- function setData(uint index, uint x, uint y) { data[index].x = x; data[index].y = y; }
+ function setIDStatic(uint id) public { ids[2] = id; }
+ function setID(uint index, uint id) public { ids[index] = id; }
+ function setData(uint index, uint x, uint y) public { data[index].x = x; data[index].y = y; }
function getID(uint index) public returns (uint) { return ids[index]; }
function getData(uint index) public returns (uint x, uint y) { x = data[index].x; y = data[index].y; }
function getLengths() public returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; }
- function setLengths(uint l1, uint l2) { data.length = l1; ids.length = l2; }
+ function setLengths(uint l1, uint l2) public { data.length = l1; ids.length = l2; }
}
)";
compileAndRun(sourceCode);
@@ -4811,7 +4811,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_dyn_dyn)
contract c {
uint[] data1;
uint[] data2;
- function setData1(uint length, uint index, uint value) {
+ function setData1(uint length, uint index, uint value) public {
data1.length = length; if (index < length) data1[index] = value;
}
function copyStorageStorage() public { data2 = data1; }
@@ -5737,14 +5737,14 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base)
{
char const* sourceCode = R"(
contract Base {
- constructor(uint i)
+ constructor(uint i) public
{
m_i = i;
}
uint public m_i;
}
contract Derived is Base {
- constructor(uint i) Base(i)
+ constructor(uint i) Base(i) public
{}
}
contract Final is Derived(4) {
@@ -5782,14 +5782,14 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap)
{
char const* sourceCode = R"(
contract Base {
- constructor(uint i)
+ constructor(uint i) public
{
m_i = i;
}
uint public m_i;
}
contract Base1 is Base {
- constructor(uint k) {}
+ constructor(uint k) public {}
}
contract Derived is Base, Base1 {
constructor(uint i) Base(i) Base1(7) public {}
@@ -6368,7 +6368,7 @@ BOOST_AUTO_TEST_CASE(struct_assign_reference_to_struct)
testStruct data1;
testStruct data2;
testStruct data3;
- constructor()
+ constructor() public
{
data1.m_value = 2;
}
@@ -6400,7 +6400,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_member)
uint m_value;
}
testStruct data1;
- constructor()
+ constructor() public
{
data1.m_value = 2;
}
@@ -6427,7 +6427,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_struct_in_mapping)
}
mapping (uint => testStruct) campaigns;
- constructor()
+ constructor() public
{
campaigns[0].m_value = 2;
}
@@ -6470,14 +6470,14 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_call_fail)
{
char const* sourceCode = R"(
contract A {
- constructor()
+ constructor() public
{
this.call("123");
}
}
contract B {
uint public test = 1;
- function testIt()
+ function testIt() public
{
A a = new A();
++test;
@@ -6496,7 +6496,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund)
contract A {
uint public test = 1;
uint[3] arr;
- constructor()
+ constructor() public
{
uint index = 5;
test = arr[index];
@@ -6649,9 +6649,9 @@ BOOST_AUTO_TEST_CASE(return_multiple_strings_of_various_sizes)
"ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ"
"ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ"
);
- vector<size_t> lengths{0, 30, 32, 63, 64, 65, 210, 300};
- for (auto l1: lengths)
- for (auto l2: lengths)
+ vector<size_t> lengthes{0, 30, 32, 63, 64, 65, 210, 300};
+ for (auto l1: lengthes)
+ for (auto l2: lengthes)
{
bytes dyn1 = encodeArgs(u256(l1), s1.substr(0, l1));
bytes dyn2 = encodeArgs(u256(l2), s2.substr(0, l2));
@@ -6718,9 +6718,9 @@ BOOST_AUTO_TEST_CASE(bytes_in_function_calls)
compileAndRun(sourceCode, 0, "Main");
string s1("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
string s2("ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ");
- vector<size_t> lengths{0, 31, 64, 65};
- for (auto l1: lengths)
- for (auto l2: lengths)
+ vector<size_t> lengthes{0, 31, 64, 65};
+ for (auto l1: lengthes)
+ for (auto l2: lengthes)
{
bytes dyn1 = encodeArgs(u256(l1), s1.substr(0, l1));
bytes dyn2 = encodeArgs(u256(l2), s2.substr(0, l2));
@@ -6759,8 +6759,8 @@ BOOST_AUTO_TEST_CASE(return_bytes_internal)
)";
compileAndRun(sourceCode, 0, "Main");
string s1("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
- vector<size_t> lengths{0, 31, 64, 65};
- for (auto l1: lengths)
+ vector<size_t> lengthes{0, 31, 64, 65};
+ for (auto l1: lengthes)
{
bytes dyn1 = encodeArgs(u256(l1), s1.substr(0, l1));
bytes args1 = encodeArgs(u256(0x20)) + dyn1;
@@ -7038,7 +7038,7 @@ BOOST_AUTO_TEST_CASE(storage_array_ref)
contract Store is BinarySearch {
uint[] data;
- function add(uint v) {
+ function add(uint v) public {
data.length++;
data[data.length - 1] = v;
}
@@ -7121,7 +7121,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_index_access_write)
{
char const* sourceCode = R"(
contract Test {
- function set(uint24[3][4] memory x) {
+ function set(uint24[3][4] memory x) public {
x[2][2] = 1;
x[3][2] = 7;
}
@@ -7458,7 +7458,7 @@ BOOST_AUTO_TEST_CASE(string_as_mapping_key)
char const* sourceCode = R"(
contract Test {
mapping(string => uint) data;
- function set(string memory _s, uint _v) { data[_s] = _v; }
+ function set(string memory _s, uint _v) public { data[_s] = _v; }
function get(string memory _s) public returns (uint) { return data[_s]; }
}
)";
@@ -7764,7 +7764,7 @@ BOOST_AUTO_TEST_CASE(strings_in_struct)
string last;
}
- constructor(){
+ constructor() public {
bug = Buggy(10, 20, 30, "asdfghjkl");
}
function getFirst() public returns (uint)
@@ -7856,7 +7856,7 @@ BOOST_AUTO_TEST_CASE(using_library_structs)
char const* sourceCode = R"(
library Lib {
struct Data { uint a; uint[] b; }
- function set(Data storage _s)
+ function set(Data storage _s) public
{
_s.a = 7;
_s.b.length = 20;
@@ -8039,7 +8039,7 @@ BOOST_AUTO_TEST_CASE(calldata_offset)
{
address[] _arr;
string public last = "nd";
- constructor(address[] memory guardians)
+ constructor(address[] memory guardians) public
{
_arr = guardians;
}
@@ -8941,8 +8941,8 @@ BOOST_AUTO_TEST_CASE(inline_assembly_function_access)
char const* sourceCode = R"(
contract C {
uint public x;
- function g(uint y) { x = 2 * y; assembly { stop } }
- function f(uint _x) {
+ function g(uint y) public { x = 2 * y; assembly { stop } }
+ function f(uint _x) public {
assembly {
_x
jump(g)
@@ -9416,7 +9416,7 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types_for_structs)
BOOST_AUTO_TEST_CASE(failed_create)
{
char const* sourceCode = R"(
- contract D { constructor() payable {} }
+ contract D { constructor() public payable {} }
contract C {
uint public x;
constructor() public payable {}
@@ -9512,7 +9512,7 @@ BOOST_AUTO_TEST_CASE(break_in_modifier)
break;
}
}
- function f() run {
+ function f() run public {
uint k = x;
uint t = k + 1;
x = t;
@@ -9584,7 +9584,7 @@ BOOST_AUTO_TEST_CASE(stacked_return_with_modifiers)
break;
}
}
- function f() run {
+ function f() run public {
uint k = x;
uint t = k + 1;
x = t;
@@ -9611,8 +9611,8 @@ BOOST_AUTO_TEST_CASE(mutex)
}
contract Fund is mutexed {
uint shares;
- constructor() payable { shares = msg.value; }
- function withdraw(uint amount) protected returns (uint) {
+ constructor() public payable { shares = msg.value; }
+ function withdraw(uint amount) public protected returns (uint) {
// NOTE: It is very bad practice to write this function this way.
// Please refer to the documentation of how to do this properly.
if (amount > shares) throw;
@@ -9633,7 +9633,7 @@ BOOST_AUTO_TEST_CASE(mutex)
Fund public fund;
uint callDepth;
bool protected;
- function setProtected(bool _protected) { protected = _protected; }
+ function setProtected(bool _protected) public { protected = _protected; }
constructor(Fund _fund) public { fund = _fund; }
function attack() public returns (uint) {
callDepth = 0;
@@ -9730,7 +9730,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_asm)
BOOST_AUTO_TEST_CASE(calling_nonexisting_contract_throws)
{
char const* sourceCode = R"YY(
- contract D { function g(); }
+ contract D { function g() public; }
contract C {
D d = D(0x1212);
function f() public returns (uint) {
@@ -9757,7 +9757,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor)
{
char const* sourceCode = R"(
contract C {
- constructor() payable { }
+ constructor() public payable { }
}
)";
compileAndRun(sourceCode, 27, "C");
@@ -9792,7 +9792,7 @@ BOOST_AUTO_TEST_CASE(payable_function_calls_library)
function f() public returns (uint) { return 7; }
}
contract C {
- function f() payable public returns (uint) {
+ function f() public payable returns (uint) {
return L.f();
}
}
@@ -10015,7 +10015,7 @@ BOOST_AUTO_TEST_CASE(store_function)
contract C {
function (function (uint) external returns (uint)) internal returns (uint) ev;
function (uint) external returns (uint) x;
- function store(function(uint) external returns (uint) y) {
+ function store(function(uint) external returns (uint) y) public {
x = y;
}
function eval(function(uint) external returns (uint) y) public returns (uint) {
@@ -11594,7 +11594,7 @@ BOOST_AUTO_TEST_CASE(literal_empty_string)
contract C {
bytes32 public x;
uint public a;
- function f(bytes32 _x, uint _a) {
+ function f(bytes32 _x, uint _a) public {
x = _x;
a = _a;
}
@@ -12730,7 +12730,7 @@ BOOST_AUTO_TEST_CASE(senders_balance)
}
contract D {
C c = new C();
- constructor() payable { }
+ constructor() public payable { }
function f() public view returns (uint) {
return c.f();
}
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 43ae5f73..70cbb0fc 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -104,7 +104,7 @@ public:
"\nOptimized: " + toHex(optimizedOutput));
}
- /// @returns the number of instructions in the given bytecode, not taking the metadata hash
+ /// @returns the number of intructions in the given bytecode, not taking the metadata hash
/// into account.
size_t numInstructions(bytes const& _bytecode, boost::optional<Instruction> _which = boost::optional<Instruction>{})
{
@@ -394,12 +394,12 @@ BOOST_AUTO_TEST_CASE(computing_constants)
g();
return 1;
}
- function g() {
+ function g() public {
m_b = 0x817416927846239487123469187231298734162934871263941234127518276;
m_c = 0x817416927846239487123469187231298734162934871263941234127518276;
h();
}
- function h() {
+ function h() public {
m_d = 0xff05694900000000000000000000000000000000000000000000000000000000;
}
function get() public returns (uint ra, uint rb, uint rc, uint rd) {
@@ -600,7 +600,7 @@ BOOST_AUTO_TEST_CASE(init_empty_dynamic_arrays)
// not use any memory.
char const* sourceCode = R"(
contract Test {
- function f() pure returns (uint r) {
+ function f() public pure returns (uint r) {
uint[][] memory x = new uint[][](20000);
return x.length;
}
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index bfb0d739..16921a24 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -466,7 +466,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract)
},
"sources": {
"fileA": {
- "content": "contract B { } contract A { function f() { new B(); } }"
+ "content": "contract B { } contract A { function f() public { new B(); } }"
}
}
}
@@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import)
},
"sources": {
"fileA": {
- "content": "import \"fileB\"; contract A { function f() { new B(); } }"
+ "content": "import \"fileB\"; contract A { function f() public { new B(); } }"
},
"fileB": {
"content": "contract B { }"
@@ -712,7 +712,7 @@ BOOST_AUTO_TEST_CASE(library_linking)
"content": "library L { function g() public returns (uint) { return 1; } }"
},
"library2.sol": {
- "content": "library L2 { function g() { } }"
+ "content": "library L2 { function g() public { } }"
}
}
}