mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Change tests to use view or pure as appropriate
This commit is contained in:
parent
5470da4d9a
commit
50047bf82c
@ -6525,7 +6525,7 @@ BOOST_AUTO_TEST_CASE(state_variable_under_contract_name)
|
|||||||
contract Scope {
|
contract Scope {
|
||||||
uint stateVar = 42;
|
uint stateVar = 42;
|
||||||
|
|
||||||
function getStateVar() constant returns (uint stateVar) {
|
function getStateVar() view returns (uint stateVar) {
|
||||||
stateVar = Scope.stateVar;
|
stateVar = Scope.stateVar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6791,7 +6791,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract A {
|
contract A {
|
||||||
function f(uint16 input) constant returns (uint16[5] arr)
|
function f(uint16 input) pure returns (uint16[5] arr)
|
||||||
{
|
{
|
||||||
arr[0] = input;
|
arr[0] = input;
|
||||||
arr[1] = ++input;
|
arr[1] = ++input;
|
||||||
@ -6820,7 +6820,7 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
library Lib {
|
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)
|
for (uint i = 0; i < _haystack.length; ++i)
|
||||||
if (_haystack[i] == _needle)
|
if (_haystack[i] == _needle)
|
||||||
@ -9913,12 +9913,12 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes32 ret) {
|
function f() pure returns (bytes32 ret) {
|
||||||
assembly {
|
assembly {
|
||||||
ret := keccak256(0, 0)
|
ret := keccak256(0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function g() returns (bytes32 ret) {
|
function g() pure returns (bytes32 ret) {
|
||||||
assembly {
|
assembly {
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
@ -9926,12 +9926,12 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly)
|
|||||||
=: ret
|
=: ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function h() returns (bytes32 ret) {
|
function h() pure returns (bytes32 ret) {
|
||||||
assembly {
|
assembly {
|
||||||
ret := sha3(0, 0)
|
ret := sha3(0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function i() returns (bytes32 ret) {
|
function i() pure returns (bytes32 ret) {
|
||||||
assembly {
|
assembly {
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
@ -9979,7 +9979,7 @@ BOOST_AUTO_TEST_CASE(inlineasm_empty_let)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (uint a, uint b) {
|
function f() pure returns (uint a, uint b) {
|
||||||
assembly {
|
assembly {
|
||||||
let x
|
let x
|
||||||
let y, z
|
let y, z
|
||||||
@ -9998,13 +9998,13 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
/// Calling into non-existant account is successful (creates the account)
|
/// 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();
|
return address(0x4242).call();
|
||||||
}
|
}
|
||||||
function g() external constant returns (bool) {
|
function g() external view returns (bool) {
|
||||||
return address(0x4242).callcode();
|
return address(0x4242).callcode();
|
||||||
}
|
}
|
||||||
function h() external constant returns (bool) {
|
function h() external view returns (bool) {
|
||||||
return address(0x4242).delegatecall();
|
return address(0x4242).delegatecall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10023,16 +10023,16 @@ BOOST_AUTO_TEST_CASE(delegatecall_return_value)
|
|||||||
function set(uint _value) external {
|
function set(uint _value) external {
|
||||||
value = _value;
|
value = _value;
|
||||||
}
|
}
|
||||||
function get() external constant returns (uint) {
|
function get() external view returns (uint) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
function get_delegated() external constant returns (bool) {
|
function get_delegated() external view returns (bool) {
|
||||||
return this.delegatecall(bytes4(sha3("get()")));
|
return this.delegatecall(bytes4(sha3("get()")));
|
||||||
}
|
}
|
||||||
function assert0() external constant {
|
function assert0() external view {
|
||||||
assert(value == 0);
|
assert(value == 0);
|
||||||
}
|
}
|
||||||
function assert0_delegated() external constant returns (bool) {
|
function assert0_delegated() external view returns (bool) {
|
||||||
return this.delegatecall(bytes4(sha3("assert0()")));
|
return this.delegatecall(bytes4(sha3("assert0()")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1615,7 +1615,7 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f() returns (uint) {
|
function f() pure returns (uint) {
|
||||||
var i = 1;
|
var i = 1;
|
||||||
return i;
|
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");
|
CHECK_WARNING(sourceCode, "uint256, which can hold values between 0 and 115792089237316195423570985008687907853269984665640564039457584007913129639935");
|
||||||
sourceCode = R"(
|
sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f() {
|
function f() pure {
|
||||||
var i = -2;
|
var i = -2;
|
||||||
i;
|
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");
|
CHECK_WARNING(sourceCode, "int8, which can hold values between -128 and 127");
|
||||||
sourceCode = R"(
|
sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f() {
|
function f() pure {
|
||||||
for (var i = 0; i < msg.data.length; i++) { }
|
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"(
|
char const* sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
mapping(uint => uint)[] storage x;
|
mapping(uint => uint)[] storage x;
|
||||||
x;
|
x;
|
||||||
}
|
}
|
||||||
@ -3973,7 +3973,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f() {
|
function f() pure {
|
||||||
ufixed16x2 a = 3.25;
|
ufixed16x2 a = 3.25;
|
||||||
fixed16x2 b = -3.25;
|
fixed16x2 b = -3.25;
|
||||||
a; b;
|
a; b;
|
||||||
@ -3983,7 +3983,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
|
|||||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||||
text = R"(
|
text = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f() {
|
function f() pure {
|
||||||
ufixed16x2 a = +3.25;
|
ufixed16x2 a = +3.25;
|
||||||
fixed16x2 b = -3.25;
|
fixed16x2 b = -3.25;
|
||||||
a; b;
|
a; b;
|
||||||
@ -3993,7 +3993,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
|
|||||||
CHECK_WARNING(text, "Use of unary + is deprecated");
|
CHECK_WARNING(text, "Use of unary + is deprecated");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f(uint x) {
|
function f(uint x) pure {
|
||||||
uint y = +x;
|
uint y = +x;
|
||||||
y;
|
y;
|
||||||
}
|
}
|
||||||
@ -4006,7 +4006,7 @@ BOOST_AUTO_TEST_CASE(leading_zero_rationals_convert)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract A {
|
contract A {
|
||||||
function f() {
|
function f() pure {
|
||||||
ufixed16x2 a = 0.5;
|
ufixed16x2 a = 0.5;
|
||||||
ufixed256x52 b = 0.0000000000000006661338147750939242541790008544921875;
|
ufixed256x52 b = 0.0000000000000006661338147750939242541790008544921875;
|
||||||
fixed16x2 c = -0.5;
|
fixed16x2 c = -0.5;
|
||||||
@ -4519,7 +4519,7 @@ BOOST_AUTO_TEST_CASE(warn_about_callcode)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f() {
|
function f() pure {
|
||||||
var x = address(0x12).callcode;
|
var x = address(0x12).callcode;
|
||||||
x;
|
x;
|
||||||
}
|
}
|
||||||
@ -4532,7 +4532,7 @@ BOOST_AUTO_TEST_CASE(no_warn_about_callcode_as_function)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function callcode() {
|
function callcode() pure {
|
||||||
test.callcode();
|
test.callcode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5275,7 +5275,7 @@ BOOST_AUTO_TEST_CASE(warns_msg_value_in_non_payable_public_function)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() view {
|
||||||
msg.value;
|
msg.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5299,7 +5299,7 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_internal_function)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() internal {
|
function f() view internal {
|
||||||
msg.value;
|
msg.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5311,7 +5311,7 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_library)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
library C {
|
library C {
|
||||||
function f() {
|
function f() view {
|
||||||
msg.value;
|
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"(
|
char const* text = R"(
|
||||||
contract c {
|
contract c {
|
||||||
function f() { }
|
function f() pure { }
|
||||||
modifier m() { msg.value; _; }
|
modifier m() { msg.value; _; }
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -5402,7 +5402,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_checksum)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
|
address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
|
||||||
x;
|
x;
|
||||||
}
|
}
|
||||||
@ -5415,7 +5415,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_no_checksum)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
address x = 0xfa0bfc97e48458494ccd857e1a85dc91f7f0046e;
|
address x = 0xfa0bfc97e48458494ccd857e1a85dc91f7f0046e;
|
||||||
x;
|
x;
|
||||||
}
|
}
|
||||||
@ -5428,7 +5428,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_length)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
address x = 0xA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
|
address x = 0xA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
|
||||||
x;
|
x;
|
||||||
}
|
}
|
||||||
@ -5678,7 +5678,7 @@ BOOST_AUTO_TEST_CASE(warn_about_throw)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5690,7 +5690,7 @@ BOOST_AUTO_TEST_CASE(bare_revert)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f(uint x) {
|
function f(uint x) pure {
|
||||||
if (x > 7)
|
if (x > 7)
|
||||||
revert;
|
revert;
|
||||||
}
|
}
|
||||||
@ -5701,17 +5701,17 @@ BOOST_AUTO_TEST_CASE(bare_revert)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(bare_others)
|
BOOST_AUTO_TEST_CASE(bare_others)
|
||||||
{
|
{
|
||||||
CHECK_WARNING("contract C { function f() { selfdestruct; } }", "Statement has no effect.");
|
CHECK_WARNING("contract C { function f() pure { selfdestruct; } }", "Statement has no effect.");
|
||||||
CHECK_WARNING("contract C { function f() { assert; } }", "Statement has no effect.");
|
CHECK_WARNING("contract C { function f() pure { assert; } }", "Statement has no effect.");
|
||||||
CHECK_WARNING("contract C { function f() { require; } }", "Statement has no effect.");
|
CHECK_WARNING("contract C { function f() pure { require; } }", "Statement has no effect.");
|
||||||
CHECK_WARNING("contract C { function f() { suicide; } }", "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)
|
BOOST_AUTO_TEST_CASE(pure_statement_in_for_loop)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
for (uint x = 0; x < 10; true)
|
for (uint x = 0; x < 10; true)
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
@ -5724,7 +5724,7 @@ BOOST_AUTO_TEST_CASE(pure_statement_check_for_regular_for_loop)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
for (uint x = 0; true; x++)
|
for (uint x = 0; true; x++)
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
@ -5780,7 +5780,7 @@ BOOST_AUTO_TEST_CASE(nowarn_swap_memory)
|
|||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
struct S { uint a; uint b; }
|
struct S { uint a; uint b; }
|
||||||
function f() {
|
function f() pure {
|
||||||
S memory x;
|
S memory x;
|
||||||
S memory y;
|
S memory y;
|
||||||
(x, y) = (y, x);
|
(x, y) = (y, x);
|
||||||
@ -5811,7 +5811,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_local)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
uint a;
|
uint a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5823,7 +5823,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_local_assigned)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
uint a = 1;
|
uint a = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5835,14 +5835,14 @@ BOOST_AUTO_TEST_CASE(warn_unused_param)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f(uint a) {
|
function f(uint a) pure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_WARNING(text, "Unused");
|
CHECK_WARNING(text, "Unused");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
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"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (uint a) {
|
function f() pure returns (uint a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_WARNING(text, "Unused");
|
CHECK_WARNING(text, "Unused");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (uint a) {
|
function f() pure returns (uint a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5868,14 +5868,14 @@ BOOST_AUTO_TEST_CASE(warn_unused_return_param)
|
|||||||
CHECK_WARNING(text, "Unused");
|
CHECK_WARNING(text, "Unused");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (uint) {
|
function f() pure returns (uint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (uint a) {
|
function f() pure returns (uint a) {
|
||||||
a = 1;
|
a = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5883,7 +5883,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_return_param)
|
|||||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (uint a) {
|
function f() pure returns (uint a) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5895,7 +5895,7 @@ BOOST_AUTO_TEST_CASE(no_unused_warnings)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f(uint a) returns (uint b) {
|
function f(uint a) pure returns (uint b) {
|
||||||
uint c = 1;
|
uint c = 1;
|
||||||
b = a + c;
|
b = a + c;
|
||||||
}
|
}
|
||||||
@ -5908,7 +5908,7 @@ BOOST_AUTO_TEST_CASE(no_unused_dec_after_use)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
a = 7;
|
a = 7;
|
||||||
uint a;
|
uint a;
|
||||||
}
|
}
|
||||||
@ -5936,7 +5936,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_functions)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function keccak256() {}
|
function keccak256() pure {}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_WARNING(text, "shadows a builtin symbol");
|
CHECK_WARNING(text, "shadows a builtin symbol");
|
||||||
@ -5946,7 +5946,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_variables)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
uint msg;
|
uint msg;
|
||||||
msg;
|
msg;
|
||||||
}
|
}
|
||||||
@ -5978,7 +5978,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_parameters)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f(uint require) {
|
function f(uint require) pure {
|
||||||
require = 2;
|
require = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5990,7 +5990,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_return_parameters)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (uint require) {
|
function f() pure returns (uint require) {
|
||||||
require = 2;
|
require = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6034,8 +6034,8 @@ BOOST_AUTO_TEST_CASE(function_overload_is_not_shadowing)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {}
|
function f() pure {}
|
||||||
function f(uint) {}
|
function f(uint) pure {}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
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)
|
BOOST_AUTO_TEST_CASE(function_override_is_not_shadowing)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract D { function f() {} }
|
contract D { function f() pure {} }
|
||||||
contract C is D {
|
contract C is D {
|
||||||
function f(uint) {}
|
function f(uint) pure {}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||||
@ -6140,7 +6140,7 @@ BOOST_AUTO_TEST_CASE(does_not_error_transfer_regular_function)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract A {
|
contract A {
|
||||||
function transfer() {}
|
function transfer() pure {}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract B {
|
contract B {
|
||||||
@ -6176,7 +6176,7 @@ BOOST_AUTO_TEST_CASE(warn_unspecified_storage)
|
|||||||
contract C {
|
contract C {
|
||||||
struct S { uint a; string b; }
|
struct S { uint a; string b; }
|
||||||
S x;
|
S x;
|
||||||
function f() {
|
function f() view {
|
||||||
S storage y = x;
|
S storage y = x;
|
||||||
y;
|
y;
|
||||||
}
|
}
|
||||||
@ -6187,7 +6187,7 @@ BOOST_AUTO_TEST_CASE(warn_unspecified_storage)
|
|||||||
contract C {
|
contract C {
|
||||||
struct S { uint a; }
|
struct S { uint a; }
|
||||||
S x;
|
S x;
|
||||||
function f() {
|
function f() view {
|
||||||
S y = x;
|
S y = x;
|
||||||
y;
|
y;
|
||||||
}
|
}
|
||||||
@ -6213,21 +6213,21 @@ BOOST_AUTO_TEST_CASE(too_large_arrays_for_calldata)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
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.");
|
CHECK_ERROR(text, TypeError, "Array is too large to be encoded.");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
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.");
|
CHECK_ERROR(text, TypeError, "Array is too large to be encoded.");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
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"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
string memory x = "abc";
|
string memory x = "abc";
|
||||||
x;
|
x;
|
||||||
}
|
}
|
||||||
@ -6247,7 +6247,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string)
|
|||||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
string storage x = "abc";
|
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.");
|
CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
string x = "abc";
|
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.");
|
CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() {
|
function f() pure {
|
||||||
string("abc");
|
string("abc");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6292,7 +6292,7 @@ BOOST_AUTO_TEST_CASE(using_this_in_constructor)
|
|||||||
function C() {
|
function C() {
|
||||||
this.f();
|
this.f();
|
||||||
}
|
}
|
||||||
function f() {
|
function f() pure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -6559,7 +6559,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals)
|
|||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes32) {
|
function f() pure returns (bytes32) {
|
||||||
return keccak256(1);
|
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.");
|
CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8.");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes32) {
|
function f() pure returns (bytes32) {
|
||||||
return keccak256(uint8(1));
|
return keccak256(uint8(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6575,7 +6575,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals)
|
|||||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes32) {
|
function f() pure returns (bytes32) {
|
||||||
return sha3(1);
|
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.");
|
CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8.");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes32) {
|
function f() pure returns (bytes32) {
|
||||||
return sha256(1);
|
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.");
|
CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8.");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes32) {
|
function f() pure returns (bytes32) {
|
||||||
return ripemd160(1);
|
return ripemd160(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user