Updates unit test to specify visibility.

This commit is contained in:
Erik Kundt 2018-06-29 16:52:41 +02:00
parent b42929975f
commit fc2b006fe1
12 changed files with 104 additions and 104 deletions

View File

@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_simple)
contract C { contract C {
uint public _a; uint public _a;
uint[] public _b; uint[] public _b;
constructor(uint a, uint[] b) { constructor(uint a, uint[] b) public {
_a = a; _a = a;
_b = b; _b = b;
} }
@ -310,24 +310,24 @@ BOOST_AUTO_TEST_CASE(decode_function_type)
string sourceCode = R"( string sourceCode = R"(
contract D { contract D {
function () external returns (uint) public _a; function () external returns (uint) public _a;
constructor(function () external returns (uint) a) { constructor(function () external returns (uint) a) public {
_a = a; _a = a;
} }
} }
contract C { contract C {
function f() returns (uint) { function f() public returns (uint) {
return 3; return 3;
} }
function g(function () external returns (uint) _f) returns (uint) { function g(function () external returns (uint) _f) public returns (uint) {
return _f(); return _f();
} }
// uses "decode from memory" // uses "decode from memory"
function test1() returns (uint) { function test1() public returns (uint) {
D d = new D(this.f); D d = new D(this.f);
return d._a()(); return d._a()();
} }
// uses "decode from calldata" // uses "decode from calldata"
function test2() returns (uint) { function test2() public returns (uint) {
return this.g(this.f); return this.g(this.f);
} }
} }
@ -344,13 +344,13 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array)
string sourceCode = R"( string sourceCode = R"(
contract D { contract D {
function () external returns (uint)[] public _a; function () external returns (uint)[] public _a;
constructor(function () external returns (uint)[] a) { constructor(function () external returns (uint)[] a) public {
_a = a; _a = a;
} }
} }
contract E { contract E {
function () external returns (uint)[3] public _a; function () external returns (uint)[3] public _a;
constructor(function () external returns (uint)[3] a) { constructor(function () external returns (uint)[3] a) public {
_a = a; _a = a;
} }
} }
@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_complex)
uint public _a; uint public _a;
uint[] public _b; uint[] public _b;
bytes[2] public _c; bytes[2] public _c;
constructor(uint a, uint[] b, bytes[2] c) { constructor(uint a, uint[] b, bytes[2] c) public {
_a = a; _a = a;
_b = b; _b = b;
_c = c; _c = c;

View File

@ -44,7 +44,7 @@ BOOST_AUTO_TEST_SUITE(SolidityASTJSON)
BOOST_AUTO_TEST_CASE(short_type_name) BOOST_AUTO_TEST_CASE(short_type_name)
{ {
CompilerStack c; 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.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze(); c.parseAndAnalyze();
map<string, unsigned> sourceIndices; map<string, unsigned> sourceIndices;
@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(short_type_name)
BOOST_AUTO_TEST_CASE(short_type_name_ref) BOOST_AUTO_TEST_CASE(short_type_name_ref)
{ {
CompilerStack c; 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.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze(); c.parseAndAnalyze();
map<string, unsigned> sourceIndices; map<string, unsigned> sourceIndices;

View File

@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(enum_value)
BOOST_AUTO_TEST_CASE(modifier_definition) BOOST_AUTO_TEST_CASE(modifier_definition)
{ {
CompilerStack c; 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.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze(); c.parseAndAnalyze();
map<string, unsigned> sourceIndices; map<string, unsigned> sourceIndices;
@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(modifier_definition)
BOOST_AUTO_TEST_CASE(modifier_invocation) BOOST_AUTO_TEST_CASE(modifier_invocation)
{ {
CompilerStack c; 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.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze(); c.parseAndAnalyze();
map<string, unsigned> sourceIndices; map<string, unsigned> sourceIndices;
@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(array_type_name)
BOOST_AUTO_TEST_CASE(short_type_name) BOOST_AUTO_TEST_CASE(short_type_name)
{ {
CompilerStack c; 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.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze(); c.parseAndAnalyze();
map<string, unsigned> sourceIndices; map<string, unsigned> sourceIndices;
@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(short_type_name)
BOOST_AUTO_TEST_CASE(short_type_name_ref) BOOST_AUTO_TEST_CASE(short_type_name_ref)
{ {
CompilerStack c; 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.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze(); c.parseAndAnalyze();
map<string, unsigned> sourceIndices; map<string, unsigned> sourceIndices;
@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(placeholder_statement)
BOOST_AUTO_TEST_CASE(non_utf8) BOOST_AUTO_TEST_CASE(non_utf8)
{ {
CompilerStack c; 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.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze(); c.parseAndAnalyze();
map<string, unsigned> sourceIndices; map<string, unsigned> sourceIndices;

View File

@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(location_test)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f() returns (uint256 a) { function f() public returns (uint256 a) {
return 16; return 16;
} }
} }

View File

@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { 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"( char const* sourceCode = R"(
contract test { contract test {
function f(uint a) returns(uint d) { return a * 7; } function f(uint a) public returns (uint d) { return a * 7; }
function g(uint b) returns(uint e) { return b * 8; } 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"( char const* sourceCode = R"(
contract test { 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 // methods are expected to be in alpabetical order
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f(uint a) returns(uint d) { return a * 7; } function f(uint a) public returns (uint d) { return a * 7; }
function c(uint b) returns(uint e) { return b * 8; } 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"( char const* sourceCode = R"(
contract test { 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; } 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"( char const* sourceCode = R"(
contract test { 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; } function boo(uint32 a) pure returns(uint b) { return a * 4; }
} }
)"; )";
@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(events)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { 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 e1(uint b, address indexed c);
event e2(); event e2();
event e2(uint a); event e2(uint a);
@ -463,11 +463,11 @@ BOOST_AUTO_TEST_CASE(inherited)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract Base { 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); event baseEvent(bytes32 indexed evtArgBase);
} }
contract Derived is Base { 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); event derivedEvent(uint indexed evtArgDerived);
} }
)"; )";
@ -537,7 +537,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { 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; uint g = 8;
ret_k = k; ret_k = k;
ret_g = g; ret_g = g;
@ -582,7 +582,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f(uint k) returns(uint) { function f(uint k) public returns (uint) {
return k; return k;
} }
} }
@ -683,7 +683,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
constructor(ActionChoices param) {} constructor(ActionChoices param) {}
function ret() returns(ActionChoices) { function ret() public returns (ActionChoices) {
ActionChoices action = ActionChoices.GoLeft; ActionChoices action = ActionChoices.GoLeft;
return action; return action;
} }
@ -756,7 +756,7 @@ BOOST_AUTO_TEST_CASE(library_function)
char const* sourceCode = R"( char const* sourceCode = R"(
library test { library test {
struct StructType { uint a; } 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 { contract C {
struct S { uint a; T[] sub; } struct S { uint a; T[] sub; }
struct T { uint[2] x; } 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; pragma experimental ABIEncoderV2;
contract C { contract C {
struct S { C[] x; C y; } struct S { C[] x; C y; }
function f() returns (S s, C c) { function f() public returns (S s, C c) {
} }
} }
)"; )";

View File

@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions)
char const* sourceCode = R"( char const* sourceCode = R"(
contract C { contract C {
uint x; uint x;
constructor() { f(); } constructor() public { f(); }
function f() internal { for (uint i = 0; i < 10; ++i) x += 3 + i; } function f() internal { for (uint i = 0; i < 10; ++i) x += 3 + i; }
} }
)"; )";

View File

@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(literal_true)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f() { bool x = true; } function f() public { bool x = true; }
} }
)"; )";
bytes code = compileFirstExpression(sourceCode); bytes code = compileFirstExpression(sourceCode);
@ -384,7 +384,7 @@ BOOST_AUTO_TEST_CASE(unary_inc_dec)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { 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"}}); 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); FunctionType::Kind::BlockHash, false, StateMutability::View);
bytes code = compileFirstExpression(sourceCode, {}, {}, {make_shared<MagicVariableDeclaration>("blockhash", blockhashFun)}); bytes code = compileFirstExpression(sourceCode, {}, {}, {make_shared<MagicVariableDeclaration>("blockhash", blockhashFun)});
bytes expectation({byte(Instruction::PUSH1), 0x03, bytes expectation({byte(Instruction::PUSH1), 0x03,
@ -523,7 +523,7 @@ BOOST_AUTO_TEST_CASE(gas_left)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f() returns (uint256 val) { function f() public returns (uint256 val) {
return gasleft(); return gasleft();
} }
} }

View File

@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(abstract_contract)
{ {
SourceUnit const* sourceUnit = nullptr; SourceUnit const* sourceUnit = nullptr;
char const* text = R"( char const* text = R"(
contract base { function foo(); } contract base { function foo() public; }
contract derived is base { function foo() public {} } contract derived is base { function foo() public {} }
)"; )";
sourceUnit = parseAndAnalyse(text); sourceUnit = parseAndAnalyse(text);
@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(abstract_contract_with_overload)
{ {
SourceUnit const* sourceUnit = nullptr; SourceUnit const* sourceUnit = nullptr;
char const* text = R"( char const* text = R"(
contract base { function foo(bool); } contract base { function foo(bool) public; }
contract derived is base { function foo(uint) public {} } contract derived is base { function foo(uint) public {} }
)"; )";
sourceUnit = parseAndAnalyse(text); sourceUnit = parseAndAnalyse(text);
@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor)
{ {
SourceUnit const* sourceUnit = nullptr; SourceUnit const* sourceUnit = nullptr;
char const* text = R"( char const* text = R"(
contract base { function foo(); } contract base { function foo() public; }
contract foo is base { constructor() public {} } contract foo is base { constructor() public {} }
)"; )";
sourceUnit = parseAndAnalyse(text); sourceUnit = parseAndAnalyse(text);

View File

@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(user_basic_test)
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
/// @notice Multiplies `a` by 7 /// @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 { contract test {
/// @notice Multiplies `a` by 7 /// @notice Multiplies `a` by 7
/// @dev Multiplies a number 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 { contract test {
/// @notice Multiplies `a` by 7 /// @notice Multiplies `a` by 7
/// and then adds `b` /// 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; return (a * 7) + b;
} }
} }
@ -148,17 +148,17 @@ BOOST_AUTO_TEST_CASE(user_multiple_functions)
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
/// @notice Multiplies `a` by 7 and then adds `b` /// @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; return (a * 7) + b;
} }
/// @notice Divides `input` by `div` /// @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; return input / div;
} }
/// @notice Subtracts 3 from `input` /// @notice Subtracts 3 from `input`
function sub(int input) returns(int d) { function sub(int input) public returns (int d) {
return input - 3; return input - 3;
} }
} }
@ -189,10 +189,10 @@ BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function mul(uint a) returns(uint d) { function mul(uint a) public returns (uint d) {
return a * 7; return a * 7;
} }
function sub(int input) returns(int d) { function sub(int input) public returns (int d) {
return input - 3; return input - 3;
} }
} }
@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
/// Multiplies a number by 7 and adds second parameter /// Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter /// @param a Documentation for the first parameter
/// @param second Documentation for the second 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 /// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter /// @param a Documentation for the first parameter
/// @param second Documentation for the second 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" " /// @dev Multiplies a number by 7 and adds second parameter\n"
" /// @param a Documentation for the first parameter\n" " /// @param a Documentation for the first parameter\n"
" /// @param second Documentation for the second 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"; "}\n";
char const* natspec = "{" char const* natspec = "{"
@ -287,7 +287,7 @@ BOOST_AUTO_TEST_CASE(dev_mutiline_param_description)
/// @param a Documentation for the first parameter starts here. /// @param a Documentation for the first parameter starts here.
/// Since it's a really complicated parameter we need 2 lines /// Since it's a really complicated parameter we need 2 lines
/// @param second Documentation for the second 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; }
} }
)"; )";
@ -312,18 +312,18 @@ BOOST_AUTO_TEST_CASE(dev_multiple_functions)
/// @dev Multiplies a number by 7 and adds second parameter /// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter /// @param a Documentation for the first parameter
/// @param second Documentation for the second 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; return a * 7 + second;
} }
/// @dev Divides 2 numbers /// @dev Divides 2 numbers
/// @param input Documentation for the input parameter /// @param input Documentation for the input parameter
/// @param div Documentation for the div 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; return input / div;
} }
/// @dev Subtracts 3 from `input` /// @dev Subtracts 3 from `input`
/// @param input Documentation for the input parameter /// @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; return input - 3;
} }
} }
@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(dev_return)
/// Since it's a really complicated parameter we need 2 lines /// Since it's a really complicated parameter we need 2 lines
/// @param second Documentation for the second parameter /// @param second Documentation for the second parameter
/// @return The result of the multiplication /// @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 /// @param second Documentation for the second parameter
/// @return /// @return
/// The result of the multiplication /// 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; return a * 7 + second;
} }
} }
@ -425,7 +425,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
/// @param second Documentation for the second parameter /// @param second Documentation for the second parameter
/// @return The result of the multiplication /// @return The result of the multiplication
/// and cookies with nutella /// 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; return a * 7 + second;
} }
} }
@ -458,7 +458,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_comment)
* @return The result of the multiplication * @return The result of the multiplication
* and cookies with nutella * 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; return a * 7 + second;
} }
} }
@ -484,7 +484,7 @@ BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
/// @dev Mul function /// @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 /// @title Just a test contract
contract test { contract test {
/// @dev Mul function /// @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 { contract test {
/// @dev Mul function /// @dev Mul function
/// @author John Doe /// @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"( char const* sourceCode = R"(
contract test { contract test {
/// I do something awesome /// 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 { contract test {
/// I do something awesome /// I do something awesome
/// which requires two lines to explain /// 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 { contract test {
/// @dev Mul function /// @dev Mul function
/// @title I really should not be here /// @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 /// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter /// @param a Documentation for the first parameter
/// @param not_existing Documentation for the second 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 /// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter /// @param a Documentation for the first parameter
/// @param /// @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 /// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter /// @param a Documentation for the first parameter
/// @param se /// @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 /// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter /// @param a Documentation for the first parameter
/// @param second /// @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; }
} }
)"; )";

View File

@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f(uint a) returns (uint b) { function f(uint a) public returns (uint b) {
return a; return a;
} }
} }
@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(identities)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { 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))); return int(0) | (int(1) * (int(0) ^ (0 + a)));
} }
} }
@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
uint data; uint data;
function f() returns (uint a, uint b) { function f() public returns (uint a, uint b) {
10 + 20; 10 + 20;
data; data;
} }
@ -180,7 +180,7 @@ BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
// literals as late as possible // literals as late as possible
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { 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); return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
} }
} }
@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(storage_access)
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
uint8[40] data; 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[2] = data[7] = uint8(x);
data[4] = data[2] * 10 + data[3]; data[4] = data[2] * 10 + data[3];
} }
@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(array_copy)
contract test { contract test {
bytes2[] data1; bytes2[] data1;
bytes5[] data2; 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; data1.length = msg.data.length;
for (uint i = 0; i < msg.data.length; ++i) for (uint i = 0; i < msg.data.length; ++i)
data1[i] = msg.data[i]; data1[i] = msg.data[i];
@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(function_calls)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f1(uint x) returns (uint) { return x*x; } function f1(uint x) public returns (uint) { return x*x; }
function f(uint x) returns (uint) { return f1(7+x) - this.f1(x**9); } function f(uint x) public returns (uint) { return f1(7+x) - this.f1(x**9); }
} }
)"; )";
compileBothVersions(sourceCode); compileBothVersions(sourceCode);
@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(storage_write_in_loops)
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
uint d; uint d;
function f(uint a) returns (uint r) { function f(uint a) public returns (uint r) {
uint x = d; uint x = d;
for (uint i = 1; i < a * a; i++) { for (uint i = 1; i < a * a; i++) {
r = d; r = d;
@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(retain_information_in_branches)
contract c { contract c {
bytes32 d; bytes32 d;
uint a; 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)); bytes32 z = keccak256(abi.encodePacked(y));
if (x > 8) { if (x > 8) {
z = keccak256(abi.encodePacked(y)); z = keccak256(abi.encodePacked(y));
@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug)
contract C contract C
{ {
mapping(uint => uint) data; mapping(uint => uint) data;
function f() returns (uint) function f() public returns (uint)
{ {
if(data[now] == 0) if(data[now] == 0)
data[uint(-7)] = 5; 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. // to storage), so the sequence number should be incremented.
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { 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); compileBothVersions(sourceCode);
@ -385,10 +385,10 @@ BOOST_AUTO_TEST_CASE(computing_constants)
uint m_b; uint m_b;
uint m_c; uint m_c;
uint m_d; uint m_d;
constructor() { constructor() public {
set(); set();
} }
function set() returns (uint) { function set() public returns (uint) {
m_a = 0x77abc0000000000000000000000000000000000000000000000000000000001; m_a = 0x77abc0000000000000000000000000000000000000000000000000000000001;
m_b = 0x817416927846239487123469187231298734162934871263941234127518276; m_b = 0x817416927846239487123469187231298734162934871263941234127518276;
g(); g();
@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE(computing_constants)
function h() { function h() {
m_d = 0xff05694900000000000000000000000000000000000000000000000000000000; 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; ra = m_a;
rb = m_b; rb = m_b;
rc = m_c; rc = m_c;
@ -444,7 +444,7 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit)
pragma solidity ^0.4.0; pragma solidity ^0.4.0;
contract HexEncoding { contract HexEncoding {
function hexEncodeTest(address addr) returns (bytes32 ret) { function hexEncodeTest(address addr) public returns (bytes32 ret) {
uint x = uint(addr) / 2**32; uint x = uint(addr) / 2**32;
// Nibble interleave // Nibble interleave
@ -561,11 +561,11 @@ BOOST_AUTO_TEST_CASE(dead_code_elimination_across_assemblies)
char const* sourceCode = R"( char const* sourceCode = R"(
contract DCE { contract DCE {
function () internal returns (uint) stored; function () internal returns (uint) stored;
constructor() { constructor() public {
stored = f; stored = f;
} }
function f() internal returns (uint) { return 7; } function f() internal returns (uint) { return 7; }
function test() returns (uint) { return stored(); } function test() public returns (uint) { return stored(); }
} }
)"; )";
compileBothVersions(sourceCode); compileBothVersions(sourceCode);
@ -577,12 +577,12 @@ BOOST_AUTO_TEST_CASE(invalid_state_at_control_flow_join)
char const* sourceCode = R"( char const* sourceCode = R"(
contract Test { contract Test {
uint256 public totalSupply = 100; uint256 public totalSupply = 100;
function f() returns (uint r) { function f() public returns (uint r) {
if (false) if (false)
r = totalSupply; r = totalSupply;
totalSupply -= 10; totalSupply -= 10;
} }
function test() returns (uint) { function test() public returns (uint) {
f(); f();
return this.totalSupply(); return this.totalSupply();
} }

View File

@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation)
contract test { contract test {
uint256 stateVar; uint256 stateVar;
/// This is a test function /// This is a test function
function functionName(bytes32 input) returns (bytes32 out) {} function functionName(bytes32 input) public returns (bytes32 out) {}
} }
)"; )";
BOOST_CHECK(successParse(text)); BOOST_CHECK(successParse(text));
@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(function_normal_comments)
contract test { contract test {
uint256 stateVar; uint256 stateVar;
// We won't see this comment // 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)); BOOST_CHECK(successParse(text));
@ -157,13 +157,13 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation)
contract test { contract test {
uint256 stateVar; uint256 stateVar;
/// This is test function 1 /// 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 /// This is test function 2
function functionName2(bytes32 input) returns (bytes32 out) {} function functionName2(bytes32 input) public returns (bytes32 out) {}
// nothing to see here // nothing to see here
function functionName3(bytes32 input) returns (bytes32 out) {} function functionName3(bytes32 input) public returns (bytes32 out) {}
/// This is test function 4 /// This is test function 4
function functionName4(bytes32 input) returns (bytes32 out) {} function functionName4(bytes32 input) public returns (bytes32 out) {}
} }
)"; )";
BOOST_CHECK(successParse(text)); BOOST_CHECK(successParse(text));
@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation)
uint256 stateVar; uint256 stateVar;
/// This is a test function /// This is a test function
/// and it has 2 lines /// and it has 2 lines
function functionName1(bytes32 input) returns (bytes32 out) {} function functionName1(bytes32 input) public returns (bytes32 out) {}
} }
)"; )";
BOOST_CHECK(successParse(text)); BOOST_CHECK(successParse(text));
@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body)
} }
/// This is a test function /// This is a test function
/// and it has 2 lines /// and it has 2 lines
function fun(bytes32 input) returns (bytes32 out) {} function fun(bytes32 input) public returns (bytes32 out) {}
} }
)"; )";
BOOST_CHECK(successParse(text)); BOOST_CHECK(successParse(text));

View File

@ -556,10 +556,10 @@ BOOST_AUTO_TEST_CASE(library_filename_with_colon)
}, },
"sources": { "sources": {
"fileA": { "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": { "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": { "sources": {
"fileA": { "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": { "library.sol": {
"content": "library L { function g() returns (uint) { return 1; } }" "content": "library L { function g() public returns (uint) { return 1; } }"
}, },
"library2.sol": { "library2.sol": {
"content": "library L2 { function g() { } }" "content": "library L2 { function g() { } }"