diff options
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 30 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 122 |
2 files changed, 76 insertions, 76 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 73dd7d22..175a6f48 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -6525,7 +6525,7 @@ BOOST_AUTO_TEST_CASE(state_variable_under_contract_name) contract Scope { uint stateVar = 42; - function getStateVar() constant returns (uint stateVar) { + function getStateVar() view returns (uint stateVar) { stateVar = Scope.stateVar; } } @@ -6791,7 +6791,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type) { char const* sourceCode = R"( contract A { - function f(uint16 input) constant returns (uint16[5] arr) + function f(uint16 input) pure returns (uint16[5] arr) { arr[0] = input; arr[1] = ++input; @@ -6820,7 +6820,7 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library) { char const* sourceCode = R"( library Lib { - function find(uint16[] storage _haystack, uint16 _needle) constant returns (uint) + function find(uint16[] storage _haystack, uint16 _needle) pure returns (uint) { for (uint i = 0; i < _haystack.length; ++i) if (_haystack[i] == _needle) @@ -9913,12 +9913,12 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly) { char const* sourceCode = R"( contract C { - function f() returns (bytes32 ret) { + function f() pure returns (bytes32 ret) { assembly { ret := keccak256(0, 0) } } - function g() returns (bytes32 ret) { + function g() pure returns (bytes32 ret) { assembly { 0 0 @@ -9926,12 +9926,12 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly) =: ret } } - function h() returns (bytes32 ret) { + function h() pure returns (bytes32 ret) { assembly { ret := sha3(0, 0) } } - function i() returns (bytes32 ret) { + function i() pure returns (bytes32 ret) { assembly { 0 0 @@ -9979,7 +9979,7 @@ BOOST_AUTO_TEST_CASE(inlineasm_empty_let) { char const* sourceCode = R"( contract C { - function f() returns (uint a, uint b) { + function f() pure returns (uint a, uint b) { assembly { let x let y, z @@ -9998,13 +9998,13 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address) char const* sourceCode = R"( contract C { /// Calling into non-existant account is successful (creates the account) - function f() external constant returns (bool) { + function f() external view returns (bool) { return address(0x4242).call(); } - function g() external constant returns (bool) { + function g() external view returns (bool) { return address(0x4242).callcode(); } - function h() external constant returns (bool) { + function h() external view returns (bool) { return address(0x4242).delegatecall(); } } @@ -10023,16 +10023,16 @@ BOOST_AUTO_TEST_CASE(delegatecall_return_value) function set(uint _value) external { value = _value; } - function get() external constant returns (uint) { + function get() external view returns (uint) { return value; } - function get_delegated() external constant returns (bool) { + function get_delegated() external view returns (bool) { return this.delegatecall(bytes4(sha3("get()"))); } - function assert0() external constant { + function assert0() external view { assert(value == 0); } - function assert0_delegated() external constant returns (bool) { + function assert0_delegated() external view returns (bool) { return this.delegatecall(bytes4(sha3("assert0()"))); } } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 94404781..b9be4d91 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1615,7 +1615,7 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero) { char const* sourceCode = R"( contract test { - function f() returns (uint) { + function f() pure returns (uint) { var i = 1; return i; } @@ -1633,7 +1633,7 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero) CHECK_WARNING(sourceCode, "uint256, which can hold values between 0 and 115792089237316195423570985008687907853269984665640564039457584007913129639935"); sourceCode = R"( contract test { - function f() { + function f() pure { var i = -2; i; } @@ -1642,7 +1642,7 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero) CHECK_WARNING(sourceCode, "int8, which can hold values between -128 and 127"); sourceCode = R"( contract test { - function f() { + function f() pure { for (var i = 0; i < msg.data.length; i++) { } } } @@ -2642,7 +2642,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable) { char const* sourceCode = R"( contract C { - function f() { + function f() pure { mapping(uint => uint)[] storage x; x; } @@ -3973,7 +3973,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation) { char const* text = R"( contract test { - function f() { + function f() pure { ufixed16x2 a = 3.25; fixed16x2 b = -3.25; a; b; @@ -3983,7 +3983,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation) CHECK_SUCCESS_NO_WARNINGS(text); text = R"( contract test { - function f() { + function f() pure { ufixed16x2 a = +3.25; fixed16x2 b = -3.25; a; b; @@ -3993,7 +3993,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation) CHECK_WARNING(text, "Use of unary + is deprecated"); text = R"( contract test { - function f(uint x) { + function f(uint x) pure { uint y = +x; y; } @@ -4006,7 +4006,7 @@ BOOST_AUTO_TEST_CASE(leading_zero_rationals_convert) { char const* text = R"( contract A { - function f() { + function f() pure { ufixed16x2 a = 0.5; ufixed256x52 b = 0.0000000000000006661338147750939242541790008544921875; fixed16x2 c = -0.5; @@ -4519,7 +4519,7 @@ BOOST_AUTO_TEST_CASE(warn_about_callcode) { char const* text = R"( contract test { - function f() { + function f() pure { var x = address(0x12).callcode; x; } @@ -4532,7 +4532,7 @@ BOOST_AUTO_TEST_CASE(no_warn_about_callcode_as_function) { char const* text = R"( contract test { - function callcode() { + function callcode() pure { test.callcode(); } } @@ -5275,7 +5275,7 @@ BOOST_AUTO_TEST_CASE(warns_msg_value_in_non_payable_public_function) { char const* text = R"( contract C { - function f() { + function f() view { msg.value; } } @@ -5299,7 +5299,7 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_internal_function) { char const* text = R"( contract C { - function f() internal { + function f() view internal { msg.value; } } @@ -5311,7 +5311,7 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_library) { char const* text = R"( library C { - function f() { + function f() view { msg.value; } } @@ -5323,7 +5323,7 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_modifier_following_non_payable_p { char const* text = R"( contract c { - function f() { } + function f() pure { } modifier m() { msg.value; _; } } )"; @@ -5402,7 +5402,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_checksum) { char const* text = R"( contract C { - function f() { + function f() pure { address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E; x; } @@ -5415,7 +5415,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_no_checksum) { char const* text = R"( contract C { - function f() { + function f() pure { address x = 0xfa0bfc97e48458494ccd857e1a85dc91f7f0046e; x; } @@ -5428,7 +5428,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_length) { char const* text = R"( contract C { - function f() { + function f() pure { address x = 0xA0bFc97E48458494Ccd857e1A85DC91F7F0046E; x; } @@ -5678,7 +5678,7 @@ BOOST_AUTO_TEST_CASE(warn_about_throw) { char const* text = R"( contract C { - function f() { + function f() pure { throw; } } @@ -5690,7 +5690,7 @@ BOOST_AUTO_TEST_CASE(bare_revert) { char const* text = R"( contract C { - function f(uint x) { + function f(uint x) pure { if (x > 7) revert; } @@ -5701,17 +5701,17 @@ BOOST_AUTO_TEST_CASE(bare_revert) BOOST_AUTO_TEST_CASE(bare_others) { - CHECK_WARNING("contract C { function f() { selfdestruct; } }", "Statement has no effect."); - CHECK_WARNING("contract C { function f() { assert; } }", "Statement has no effect."); - CHECK_WARNING("contract C { function f() { require; } }", "Statement has no effect."); - CHECK_WARNING("contract C { function f() { suicide; } }", "Statement has no effect."); + CHECK_WARNING("contract C { function f() pure { selfdestruct; } }", "Statement has no effect."); + CHECK_WARNING("contract C { function f() pure { assert; } }", "Statement has no effect."); + CHECK_WARNING("contract C { function f() pure { require; } }", "Statement has no effect."); + CHECK_WARNING("contract C { function f() pure { suicide; } }", "Statement has no effect."); } BOOST_AUTO_TEST_CASE(pure_statement_in_for_loop) { char const* text = R"( contract C { - function f() { + function f() pure { for (uint x = 0; x < 10; true) x++; } @@ -5724,7 +5724,7 @@ BOOST_AUTO_TEST_CASE(pure_statement_check_for_regular_for_loop) { char const* text = R"( contract C { - function f() { + function f() pure { for (uint x = 0; true; x++) {} } @@ -5780,7 +5780,7 @@ BOOST_AUTO_TEST_CASE(nowarn_swap_memory) char const* text = R"( contract C { struct S { uint a; uint b; } - function f() { + function f() pure { S memory x; S memory y; (x, y) = (y, x); @@ -5811,7 +5811,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_local) { char const* text = R"( contract C { - function f() { + function f() pure { uint a; } } @@ -5823,7 +5823,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_local_assigned) { char const* text = R"( contract C { - function f() { + function f() pure { uint a = 1; } } @@ -5835,14 +5835,14 @@ BOOST_AUTO_TEST_CASE(warn_unused_param) { char const* text = R"( contract C { - function f(uint a) { + function f(uint a) pure { } } )"; CHECK_WARNING(text, "Unused"); text = R"( contract C { - function f(uint a) { + function f(uint a) pure { } } )"; @@ -5853,14 +5853,14 @@ BOOST_AUTO_TEST_CASE(warn_unused_return_param) { char const* text = R"( contract C { - function f() returns (uint a) { + function f() pure returns (uint a) { } } )"; CHECK_WARNING(text, "Unused"); text = R"( contract C { - function f() returns (uint a) { + function f() pure returns (uint a) { return; } } @@ -5868,14 +5868,14 @@ BOOST_AUTO_TEST_CASE(warn_unused_return_param) CHECK_WARNING(text, "Unused"); text = R"( contract C { - function f() returns (uint) { + function f() pure returns (uint) { } } )"; CHECK_SUCCESS_NO_WARNINGS(text); text = R"( contract C { - function f() returns (uint a) { + function f() pure returns (uint a) { a = 1; } } @@ -5883,7 +5883,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_return_param) CHECK_SUCCESS_NO_WARNINGS(text); text = R"( contract C { - function f() returns (uint a) { + function f() pure returns (uint a) { return 1; } } @@ -5895,7 +5895,7 @@ BOOST_AUTO_TEST_CASE(no_unused_warnings) { char const* text = R"( contract C { - function f(uint a) returns (uint b) { + function f(uint a) pure returns (uint b) { uint c = 1; b = a + c; } @@ -5908,7 +5908,7 @@ BOOST_AUTO_TEST_CASE(no_unused_dec_after_use) { char const* text = R"( contract C { - function f() { + function f() pure { a = 7; uint a; } @@ -5936,7 +5936,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_functions) { char const* text = R"( contract C { - function keccak256() {} + function keccak256() pure {} } )"; CHECK_WARNING(text, "shadows a builtin symbol"); @@ -5946,7 +5946,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_variables) { char const* text = R"( contract C { - function f() { + function f() pure { uint msg; msg; } @@ -5978,7 +5978,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_parameters) { char const* text = R"( contract C { - function f(uint require) { + function f(uint require) pure { require = 2; } } @@ -5990,7 +5990,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_return_parameters) { char const* text = R"( contract C { - function f() returns (uint require) { + function f() pure returns (uint require) { require = 2; } } @@ -6034,8 +6034,8 @@ BOOST_AUTO_TEST_CASE(function_overload_is_not_shadowing) { char const* text = R"( contract C { - function f() {} - function f(uint) {} + function f() pure {} + function f(uint) pure {} } )"; CHECK_SUCCESS_NO_WARNINGS(text); @@ -6044,9 +6044,9 @@ BOOST_AUTO_TEST_CASE(function_overload_is_not_shadowing) BOOST_AUTO_TEST_CASE(function_override_is_not_shadowing) { char const* text = R"( - contract D { function f() {} } + contract D { function f() pure {} } contract C is D { - function f(uint) {} + function f(uint) pure {} } )"; CHECK_SUCCESS_NO_WARNINGS(text); @@ -6140,7 +6140,7 @@ BOOST_AUTO_TEST_CASE(does_not_error_transfer_regular_function) { char const* text = R"( contract A { - function transfer() {} + function transfer() pure {} } contract B { @@ -6176,7 +6176,7 @@ BOOST_AUTO_TEST_CASE(warn_unspecified_storage) contract C { struct S { uint a; string b; } S x; - function f() { + function f() view { S storage y = x; y; } @@ -6187,7 +6187,7 @@ BOOST_AUTO_TEST_CASE(warn_unspecified_storage) contract C { struct S { uint a; } S x; - function f() { + function f() view { S y = x; y; } @@ -6213,21 +6213,21 @@ BOOST_AUTO_TEST_CASE(too_large_arrays_for_calldata) { char const* text = R"( contract C { - function f(uint[85678901234] a) external { + function f(uint[85678901234] a) pure external { } } )"; CHECK_ERROR(text, TypeError, "Array is too large to be encoded."); text = R"( contract C { - function f(uint[85678901234] a) internal { + function f(uint[85678901234] a) pure internal { } } )"; CHECK_ERROR(text, TypeError, "Array is too large to be encoded."); text = R"( contract C { - function f(uint[85678901234] a) { + function f(uint[85678901234] a) pure { } } )"; @@ -6238,7 +6238,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string) { char const* text = R"( contract C { - function f() { + function f() pure { string memory x = "abc"; x; } @@ -6247,7 +6247,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string) CHECK_SUCCESS_NO_WARNINGS(text); text = R"( contract C { - function f() { + function f() pure { string storage x = "abc"; } } @@ -6255,7 +6255,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string) CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer."); text = R"( contract C { - function f() { + function f() pure { string x = "abc"; } } @@ -6263,7 +6263,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string) CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer."); text = R"( contract C { - function f() { + function f() pure { string("abc"); } } @@ -6292,7 +6292,7 @@ BOOST_AUTO_TEST_CASE(using_this_in_constructor) function C() { this.f(); } - function f() { + function f() pure { } } )"; @@ -6559,7 +6559,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals) { char const* text = R"( contract C { - function f() returns (bytes32) { + function f() pure returns (bytes32) { return keccak256(1); } } @@ -6567,7 +6567,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals) CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8."); text = R"( contract C { - function f() returns (bytes32) { + function f() pure returns (bytes32) { return keccak256(uint8(1)); } } @@ -6575,7 +6575,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals) CHECK_SUCCESS_NO_WARNINGS(text); text = R"( contract C { - function f() returns (bytes32) { + function f() pure returns (bytes32) { return sha3(1); } } @@ -6583,7 +6583,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals) CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8."); text = R"( contract C { - function f() returns (bytes32) { + function f() pure returns (bytes32) { return sha256(1); } } @@ -6591,7 +6591,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals) CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8."); text = R"( contract C { - function f() returns (bytes32) { + function f() pure returns (bytes32) { return ripemd160(1); } } |