aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/ABIDecoderTests.cpp18
-rw-r--r--test/libsolidity/ASTJSON.cpp4
-rw-r--r--test/libsolidity/ASTLegacyJSON.cpp10
-rw-r--r--test/libsolidity/Assembly.cpp2
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp34
-rw-r--r--test/libsolidity/SolidityCompiler.cpp2
-rw-r--r--test/libsolidity/SolidityExpressionCompiler.cpp10
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp6
-rw-r--r--test/libsolidity/SolidityNatspecJSON.cpp58
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp40
-rw-r--r--test/libsolidity/SolidityParser.cpp16
-rw-r--r--test/libsolidity/StandardCompiler.cpp8
12 files changed, 104 insertions, 104 deletions
diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp
index b4f829ca..6504f6bc 100644
--- a/test/libsolidity/ABIDecoderTests.cpp
+++ b/test/libsolidity/ABIDecoderTests.cpp
@@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_simple)
contract C {
uint public _a;
uint[] public _b;
- constructor(uint a, uint[] b) {
+ constructor(uint a, uint[] b) public {
_a = a;
_b = b;
}
@@ -310,24 +310,24 @@ BOOST_AUTO_TEST_CASE(decode_function_type)
string sourceCode = R"(
contract D {
function () external returns (uint) public _a;
- constructor(function () external returns (uint) a) {
+ constructor(function () external returns (uint) a) public {
_a = a;
}
}
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
return 3;
}
- function g(function () external returns (uint) _f) returns (uint) {
+ function g(function () external returns (uint) _f) public returns (uint) {
return _f();
}
// uses "decode from memory"
- function test1() returns (uint) {
+ function test1() public returns (uint) {
D d = new D(this.f);
return d._a()();
}
// uses "decode from calldata"
- function test2() returns (uint) {
+ function test2() public returns (uint) {
return this.g(this.f);
}
}
@@ -344,13 +344,13 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array)
string sourceCode = R"(
contract D {
function () external returns (uint)[] public _a;
- constructor(function () external returns (uint)[] a) {
+ constructor(function () external returns (uint)[] a) public {
_a = a;
}
}
contract E {
function () external returns (uint)[3] public _a;
- constructor(function () external returns (uint)[3] a) {
+ constructor(function () external returns (uint)[3] a) public {
_a = a;
}
}
@@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_complex)
uint public _a;
uint[] public _b;
bytes[2] public _c;
- constructor(uint a, uint[] b, bytes[2] c) {
+ constructor(uint a, uint[] b, bytes[2] c) public {
_a = a;
_b = b;
_c = c;
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
index 5d5b14e8..03e74097 100644
--- a/test/libsolidity/ASTJSON.cpp
+++ b/test/libsolidity/ASTJSON.cpp
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_SUITE(SolidityASTJSON)
BOOST_AUTO_TEST_CASE(short_type_name)
{
CompilerStack c;
- c.addSource("a", "contract c { function f() { uint[] memory x; } }");
+ c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(short_type_name)
BOOST_AUTO_TEST_CASE(short_type_name_ref)
{
CompilerStack c;
- c.addSource("a", "contract c { function f() { uint[][] memory rows; } }");
+ c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
diff --git a/test/libsolidity/ASTLegacyJSON.cpp b/test/libsolidity/ASTLegacyJSON.cpp
index cd8384ea..69cb1bb9 100644
--- a/test/libsolidity/ASTLegacyJSON.cpp
+++ b/test/libsolidity/ASTLegacyJSON.cpp
@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(enum_value)
BOOST_AUTO_TEST_CASE(modifier_definition)
{
CompilerStack c;
- c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) {} }");
+ c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) public {} }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(modifier_definition)
BOOST_AUTO_TEST_CASE(modifier_invocation)
{
CompilerStack c;
- c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) {} }");
+ c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) public {} }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(array_type_name)
BOOST_AUTO_TEST_CASE(short_type_name)
{
CompilerStack c;
- c.addSource("a", "contract c { function f() { uint[] memory x; } }");
+ c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(short_type_name)
BOOST_AUTO_TEST_CASE(short_type_name_ref)
{
CompilerStack c;
- c.addSource("a", "contract c { function f() { uint[][] memory rows; } }");
+ c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(placeholder_statement)
BOOST_AUTO_TEST_CASE(non_utf8)
{
CompilerStack c;
- c.addSource("a", "contract C { function f() { var x = hex\"ff\"; } }");
+ c.addSource("a", "contract C { function f() public { var x = hex\"ff\"; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp
index 7b3df043..9c20c003 100644
--- a/test/libsolidity/Assembly.cpp
+++ b/test/libsolidity/Assembly.cpp
@@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(location_test)
{
char const* sourceCode = R"(
contract test {
- function f() returns (uint256 a) {
+ function f() public returns (uint256 a) {
return 16;
}
}
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index 6994a290..c366e866 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
+ function f(uint a) public returns (uint d) { return a * 7; }
}
)";
@@ -111,8 +111,8 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
- function g(uint b) returns(uint e) { return b * 8; }
+ function f(uint a) public returns (uint d) { return a * 7; }
+ function g(uint b) public returns (uint e) { return b * 8; }
}
)";
@@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
{
char const* sourceCode = R"(
contract test {
- function f(uint a, uint b) returns(uint d) { return a + b; }
+ function f(uint a, uint b) public returns (uint d) { return a + b; }
}
)";
@@ -202,8 +202,8 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
// methods are expected to be in alpabetical order
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
- function c(uint b) returns(uint e) { return b * 8; }
+ function f(uint a) public returns (uint d) { return a * 7; }
+ function c(uint b) public returns (uint e) { return b * 8; }
}
)";
@@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(view_function)
{
char const* sourceCode = R"(
contract test {
- function foo(uint a, uint b) returns(uint d) { return a + b; }
+ function foo(uint a, uint b) public returns (uint d) { return a + b; }
function boo(uint32 a) view returns(uint b) { return a * 4; }
}
)";
@@ -310,7 +310,7 @@ BOOST_AUTO_TEST_CASE(pure_function)
{
char const* sourceCode = R"(
contract test {
- function foo(uint a, uint b) returns(uint d) { return a + b; }
+ function foo(uint a, uint b) public returns (uint d) { return a + b; }
function boo(uint32 a) pure returns(uint b) { return a * 4; }
}
)";
@@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(events)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
+ function f(uint a) public returns (uint d) { return a * 7; }
event e1(uint b, address indexed c);
event e2();
event e2(uint a);
@@ -463,11 +463,11 @@ BOOST_AUTO_TEST_CASE(inherited)
{
char const* sourceCode = R"(
contract Base {
- function baseFunction(uint p) returns (uint i) { return p; }
+ function baseFunction(uint p) public returns (uint i) { return p; }
event baseEvent(bytes32 indexed evtArgBase);
}
contract Derived is Base {
- function derivedFunction(bytes32 p) returns (bytes32 i) { return p; }
+ function derivedFunction(bytes32 p) public returns (bytes32 i) { return p; }
event derivedEvent(uint indexed evtArgDerived);
}
)";
@@ -537,7 +537,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
{
char const* sourceCode = R"(
contract test {
- function f(uint, uint k) returns(uint ret_k, uint ret_g) {
+ function f(uint, uint k) public returns (uint ret_k, uint ret_g) {
uint g = 8;
ret_k = k;
ret_g = g;
@@ -582,7 +582,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
{
char const* sourceCode = R"(
contract test {
- function f(uint k) returns(uint) {
+ function f(uint k) public returns (uint) {
return k;
}
}
@@ -683,7 +683,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
constructor(ActionChoices param) {}
- function ret() returns(ActionChoices) {
+ function ret() public returns (ActionChoices) {
ActionChoices action = ActionChoices.GoLeft;
return action;
}
@@ -756,7 +756,7 @@ BOOST_AUTO_TEST_CASE(library_function)
char const* sourceCode = R"(
library test {
struct StructType { uint a; }
- function f(StructType storage b, uint[] storage c, test d) returns (uint[] e, StructType storage f) {}
+ function f(StructType storage b, uint[] storage c, test d) public returns (uint[] e, StructType storage f) {}
}
)";
@@ -891,7 +891,7 @@ BOOST_AUTO_TEST_CASE(return_structs)
contract C {
struct S { uint a; T[] sub; }
struct T { uint[2] x; }
- function f() returns (uint x, S s) {
+ function f() public returns (uint x, S s) {
}
}
)";
@@ -940,7 +940,7 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
pragma experimental ABIEncoderV2;
contract C {
struct S { C[] x; C y; }
- function f() returns (S s, C c) {
+ function f() public returns (S s, C c) {
}
}
)";
diff --git a/test/libsolidity/SolidityCompiler.cpp b/test/libsolidity/SolidityCompiler.cpp
index 3348bac5..0cc80dd8 100644
--- a/test/libsolidity/SolidityCompiler.cpp
+++ b/test/libsolidity/SolidityCompiler.cpp
@@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions)
char const* sourceCode = R"(
contract C {
uint x;
- constructor() { f(); }
+ constructor() public { f(); }
function f() internal { for (uint i = 0; i < 10; ++i) x += 3 + i; }
}
)";
diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp
index 2ea0247e..949045ea 100644
--- a/test/libsolidity/SolidityExpressionCompiler.cpp
+++ b/test/libsolidity/SolidityExpressionCompiler.cpp
@@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(literal_true)
{
char const* sourceCode = R"(
contract test {
- function f() { bool x = true; }
+ function f() public { bool x = true; }
}
)";
bytes code = compileFirstExpression(sourceCode);
@@ -384,7 +384,7 @@ BOOST_AUTO_TEST_CASE(unary_inc_dec)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns (uint x) { x = --a ^ (a-- ^ (++a ^ a++)); }
+ function f(uint a) public returns (uint x) { x = --a ^ (a-- ^ (++a ^ a++)); }
}
)";
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "x"}});
@@ -509,9 +509,9 @@ BOOST_AUTO_TEST_CASE(blockhash)
}
)";
- auto blockhashFun = make_shared<FunctionType>(strings{"uint256"}, strings{"bytes32"},
+ auto blockhashFun = make_shared<FunctionType>(strings{"uint256"}, strings{"bytes32"},
FunctionType::Kind::BlockHash, false, StateMutability::View);
-
+
bytes code = compileFirstExpression(sourceCode, {}, {}, {make_shared<MagicVariableDeclaration>("blockhash", blockhashFun)});
bytes expectation({byte(Instruction::PUSH1), 0x03,
@@ -523,7 +523,7 @@ BOOST_AUTO_TEST_CASE(gas_left)
{
char const* sourceCode = R"(
contract test {
- function f() returns (uint256 val) {
+ function f() public returns (uint256 val) {
return gasleft();
}
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index ff0a45f0..e6d93b36 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(abstract_contract)
{
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
- contract base { function foo(); }
+ contract base { function foo() public; }
contract derived is base { function foo() public {} }
)";
sourceUnit = parseAndAnalyse(text);
@@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(abstract_contract_with_overload)
{
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
- contract base { function foo(bool); }
+ contract base { function foo(bool) public; }
contract derived is base { function foo(uint) public {} }
)";
sourceUnit = parseAndAnalyse(text);
@@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor)
{
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
- contract base { function foo(); }
+ contract base { function foo() public; }
contract foo is base { constructor() public {} }
)";
sourceUnit = parseAndAnalyse(text);
diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp
index eeebeb74..98a3bba9 100644
--- a/test/libsolidity/SolidityNatspecJSON.cpp
+++ b/test/libsolidity/SolidityNatspecJSON.cpp
@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(user_basic_test)
char const* sourceCode = R"(
contract test {
/// @notice Multiplies `a` by 7
- function mul(uint a) returns(uint d) { return a * 7; }
+ function mul(uint a) public returns(uint d) { return a * 7; }
}
)";
@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
contract test {
/// @notice Multiplies `a` by 7
/// @dev Multiplies a number by 7
- function mul(uint a) returns(uint d) { return a * 7; }
+ function mul(uint a) public returns (uint d) { return a * 7; }
}
)";
@@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(user_multiline_comment)
contract test {
/// @notice Multiplies `a` by 7
/// and then adds `b`
- function mul_and_add(uint a, uint256 b) returns(uint256 d) {
+ function mul_and_add(uint a, uint256 b) public returns (uint256 d) {
return (a * 7) + b;
}
}
@@ -148,17 +148,17 @@ BOOST_AUTO_TEST_CASE(user_multiple_functions)
char const* sourceCode = R"(
contract test {
/// @notice Multiplies `a` by 7 and then adds `b`
- function mul_and_add(uint a, uint256 b) returns(uint256 d) {
+ function mul_and_add(uint a, uint256 b) public returns (uint256 d) {
return (a * 7) + b;
}
/// @notice Divides `input` by `div`
- function divide(uint input, uint div) returns(uint d) {
+ function divide(uint input, uint div) public returns (uint d) {
return input / div;
}
/// @notice Subtracts 3 from `input`
- function sub(int input) returns(int d) {
+ function sub(int input) public returns (int d) {
return input - 3;
}
}
@@ -189,10 +189,10 @@ BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
{
char const* sourceCode = R"(
contract test {
- function mul(uint a) returns(uint d) {
+ function mul(uint a) public returns (uint d) {
return a * 7;
}
- function sub(int input) returns(int d) {
+ function sub(int input) public returns (int d) {
return input - 3;
}
}
@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
/// Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param second Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE(dev_multiple_params)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param second Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(dev_multiple_params_mixed_whitespace)
" /// @dev Multiplies a number by 7 and adds second parameter\n"
" /// @param a Documentation for the first parameter\n"
" /// @param second Documentation for the second parameter\n"
- " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ " function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }\n"
"}\n";
char const* natspec = "{"
@@ -287,7 +287,7 @@ BOOST_AUTO_TEST_CASE(dev_mutiline_param_description)
/// @param a Documentation for the first parameter starts here.
/// Since it's a really complicated parameter we need 2 lines
/// @param second Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -312,18 +312,18 @@ BOOST_AUTO_TEST_CASE(dev_multiple_functions)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param second Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) {
+ function mul(uint a, uint second) public returns (uint d) {
return a * 7 + second;
}
/// @dev Divides 2 numbers
/// @param input Documentation for the input parameter
/// @param div Documentation for the div parameter
- function divide(uint input, uint div) returns(uint d) {
+ function divide(uint input, uint div) public returns (uint d) {
return input / div;
}
/// @dev Subtracts 3 from `input`
/// @param input Documentation for the input parameter
- function sub(int input) returns(int d) {
+ function sub(int input) public returns (int d) {
return input - 3;
}
}
@@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(dev_return)
/// Since it's a really complicated parameter we need 2 lines
/// @param second Documentation for the second parameter
/// @return The result of the multiplication
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -393,7 +393,7 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
/// @param second Documentation for the second parameter
/// @return
/// The result of the multiplication
- function mul(uint a, uint second) returns(uint d) {
+ function mul(uint a, uint second) public returns (uint d) {
return a * 7 + second;
}
}
@@ -425,7 +425,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
/// @param second Documentation for the second parameter
/// @return The result of the multiplication
/// and cookies with nutella
- function mul(uint a, uint second) returns(uint d) {
+ function mul(uint a, uint second) public returns (uint d) {
return a * 7 + second;
}
}
@@ -458,7 +458,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_comment)
* @return The result of the multiplication
* and cookies with nutella
*/
- function mul(uint a, uint second) returns(uint d) {
+ function mul(uint a, uint second) public returns (uint d) {
return a * 7 + second;
}
}
@@ -484,7 +484,7 @@ BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
char const* sourceCode = R"(
contract test {
/// @dev Mul function
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -506,7 +506,7 @@ BOOST_AUTO_TEST_CASE(dev_contract_doc)
/// @title Just a test contract
contract test {
/// @dev Mul function
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -531,7 +531,7 @@ BOOST_AUTO_TEST_CASE(dev_author_at_function)
contract test {
/// @dev Mul function
/// @author John Doe
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -554,7 +554,7 @@ BOOST_AUTO_TEST_CASE(natspec_notice_without_tag)
char const* sourceCode = R"(
contract test {
/// I do something awesome
- function mul(uint a) returns(uint d) { return a * 7; }
+ function mul(uint a) public returns (uint d) { return a * 7; }
}
)";
@@ -578,7 +578,7 @@ BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag)
contract test {
/// I do something awesome
/// which requires two lines to explain
- function mul(uint a) returns(uint d) { return a * 7; }
+ function mul(uint a) public returns (uint d) { return a * 7; }
}
)";
@@ -619,7 +619,7 @@ BOOST_AUTO_TEST_CASE(dev_title_at_function_error)
contract test {
/// @dev Mul function
/// @title I really should not be here
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -633,7 +633,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_nonexistent_param)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param not_existing Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -647,7 +647,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_no_paramname)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -661,7 +661,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_no_paramname_end)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param se
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -675,7 +675,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_no_param_description)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param second
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 04d9ee16..d375beff 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns (uint b) {
+ function f(uint a) public returns (uint b) {
return a;
}
}
@@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(identities)
{
char const* sourceCode = R"(
contract test {
- function f(int a) returns (int b) {
+ function f(int a) public returns (int b) {
return int(0) | (int(1) * (int(0) ^ (0 + a)));
}
}
@@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
char const* sourceCode = R"(
contract test {
uint data;
- function f() returns (uint a, uint b) {
+ function f() public returns (uint a, uint b) {
10 + 20;
data;
}
@@ -180,7 +180,7 @@ BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
// literals as late as possible
char const* sourceCode = R"(
contract test {
- function f(uint x) returns (uint y) {
+ function f(uint x) public returns (uint y) {
return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
}
}
@@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(storage_access)
char const* sourceCode = R"(
contract test {
uint8[40] data;
- function f(uint x) returns (uint y) {
+ function f(uint x) public returns (uint y) {
data[2] = data[7] = uint8(x);
data[4] = data[2] * 10 + data[3];
}
@@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(array_copy)
contract test {
bytes2[] data1;
bytes5[] data2;
- function f(uint x) returns (uint l, uint y) {
+ function f(uint x) public returns (uint l, uint y) {
data1.length = msg.data.length;
for (uint i = 0; i < msg.data.length; ++i)
data1[i] = msg.data[i];
@@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(function_calls)
{
char const* sourceCode = R"(
contract test {
- function f1(uint x) returns (uint) { return x*x; }
- function f(uint x) returns (uint) { return f1(7+x) - this.f1(x**9); }
+ function f1(uint x) public returns (uint) { return x*x; }
+ function f(uint x) public returns (uint) { return f1(7+x) - this.f1(x**9); }
}
)";
compileBothVersions(sourceCode);
@@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(storage_write_in_loops)
char const* sourceCode = R"(
contract test {
uint d;
- function f(uint a) returns (uint r) {
+ function f(uint a) public returns (uint r) {
uint x = d;
for (uint i = 1; i < a * a; i++) {
r = d;
@@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(retain_information_in_branches)
contract c {
bytes32 d;
uint a;
- function f(uint x, bytes32 y) returns (uint r_a, bytes32 r_d) {
+ function f(uint x, bytes32 y) public returns (uint r_a, bytes32 r_d) {
bytes32 z = keccak256(abi.encodePacked(y));
if (x > 8) {
z = keccak256(abi.encodePacked(y));
@@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug)
contract C
{
mapping(uint => uint) data;
- function f() returns (uint)
+ function f() public returns (uint)
{
if(data[now] == 0)
data[uint(-7)] = 5;
@@ -370,7 +370,7 @@ BOOST_AUTO_TEST_CASE(sequence_number_for_calls)
// to storage), so the sequence number should be incremented.
char const* sourceCode = R"(
contract test {
- function f(string a, string b) returns (bool) { return sha256(bytes(a)) == sha256(bytes(b)); }
+ function f(string a, string b) public returns (bool) { return sha256(bytes(a)) == sha256(bytes(b)); }
}
)";
compileBothVersions(sourceCode);
@@ -385,10 +385,10 @@ BOOST_AUTO_TEST_CASE(computing_constants)
uint m_b;
uint m_c;
uint m_d;
- constructor() {
+ constructor() public {
set();
}
- function set() returns (uint) {
+ function set() public returns (uint) {
m_a = 0x77abc0000000000000000000000000000000000000000000000000000000001;
m_b = 0x817416927846239487123469187231298734162934871263941234127518276;
g();
@@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE(computing_constants)
function h() {
m_d = 0xff05694900000000000000000000000000000000000000000000000000000000;
}
- function get() returns (uint ra, uint rb, uint rc, uint rd) {
+ function get() public returns (uint ra, uint rb, uint rc, uint rd) {
ra = m_a;
rb = m_b;
rc = m_c;
@@ -444,7 +444,7 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit)
pragma solidity ^0.4.0;
contract HexEncoding {
- function hexEncodeTest(address addr) returns (bytes32 ret) {
+ function hexEncodeTest(address addr) public returns (bytes32 ret) {
uint x = uint(addr) / 2**32;
// Nibble interleave
@@ -561,11 +561,11 @@ BOOST_AUTO_TEST_CASE(dead_code_elimination_across_assemblies)
char const* sourceCode = R"(
contract DCE {
function () internal returns (uint) stored;
- constructor() {
+ constructor() public {
stored = f;
}
function f() internal returns (uint) { return 7; }
- function test() returns (uint) { return stored(); }
+ function test() public returns (uint) { return stored(); }
}
)";
compileBothVersions(sourceCode);
@@ -577,12 +577,12 @@ BOOST_AUTO_TEST_CASE(invalid_state_at_control_flow_join)
char const* sourceCode = R"(
contract Test {
uint256 public totalSupply = 100;
- function f() returns (uint r) {
+ function f() public returns (uint r) {
if (false)
r = totalSupply;
totalSupply -= 10;
}
- function test() returns (uint) {
+ function test() public returns (uint) {
f();
return this.totalSupply();
}
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 1ffbd771..5432e9b5 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation)
contract test {
uint256 stateVar;
/// This is a test function
- function functionName(bytes32 input) returns (bytes32 out) {}
+ function functionName(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
@@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(function_normal_comments)
contract test {
uint256 stateVar;
// We won't see this comment
- function functionName(bytes32 input) returns (bytes32 out) {}
+ function functionName(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
@@ -157,13 +157,13 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation)
contract test {
uint256 stateVar;
/// This is test function 1
- function functionName1(bytes32 input) returns (bytes32 out) {}
+ function functionName1(bytes32 input) public returns (bytes32 out) {}
/// This is test function 2
- function functionName2(bytes32 input) returns (bytes32 out) {}
+ function functionName2(bytes32 input) public returns (bytes32 out) {}
// nothing to see here
- function functionName3(bytes32 input) returns (bytes32 out) {}
+ function functionName3(bytes32 input) public returns (bytes32 out) {}
/// This is test function 4
- function functionName4(bytes32 input) returns (bytes32 out) {}
+ function functionName4(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
@@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation)
uint256 stateVar;
/// This is a test function
/// and it has 2 lines
- function functionName1(bytes32 input) returns (bytes32 out) {}
+ function functionName1(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
@@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body)
}
/// This is a test function
/// and it has 2 lines
- function fun(bytes32 input) returns (bytes32 out) {}
+ function fun(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 63c03881..bfb0d739 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -556,10 +556,10 @@ BOOST_AUTO_TEST_CASE(library_filename_with_colon)
},
"sources": {
"fileA": {
- "content": "import \"git:library.sol\"; contract A { function f() returns (uint) { return L.g(); } }"
+ "content": "import \"git:library.sol\"; contract A { function f() public returns (uint) { return L.g(); } }"
},
"git:library.sol": {
- "content": "library L { function g() returns (uint) { return 1; } }"
+ "content": "library L { function g() public returns (uint) { return 1; } }"
}
}
}
@@ -706,10 +706,10 @@ BOOST_AUTO_TEST_CASE(library_linking)
},
"sources": {
"fileA": {
- "content": "import \"library.sol\"; import \"library2.sol\"; contract A { function f() returns (uint) { L2.g(); return L.g(); } }"
+ "content": "import \"library.sol\"; import \"library2.sol\"; contract A { function f() public returns (uint) { L2.g(); return L.g(); } }"
},
"library.sol": {
- "content": "library L { function g() returns (uint) { return 1; } }"
+ "content": "library L { function g() public returns (uint) { return 1; } }"
},
"library2.sol": {
"content": "library L2 { function g() { } }"