Merge pull request #4354 from ethereum/constructorSyntaxTests

Updates tests to new constructor syntax
This commit is contained in:
chriseth 2018-06-29 15:45:26 +02:00 committed by GitHub
commit e289c36158
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 154 additions and 160 deletions

View File

@ -101,7 +101,7 @@ contract multiowned {
// constructor is given number of sigs required to do protected "onlymanyowners" transactions
// as well as the selection of addresses capable of confirming them.
function multiowned(address[] _owners, uint _required) {
constructor(address[] _owners, uint _required) {
m_numOwners = _owners.length + 1;
m_owners[1] = uint(msg.sender);
m_ownerIndex[uint(msg.sender)] = 1;
@ -288,7 +288,7 @@ contract daylimit is multiowned {
// METHODS
// constructor - stores initial daily limit and records the present day's index.
function daylimit(uint _limit) {
constructor(uint _limit) {
m_dailyLimit = _limit;
m_lastDay = today();
}
@ -369,7 +369,7 @@ contract Wallet is multisig, multiowned, daylimit {
// constructor - just pass on the owner array to the multiowned and
// the limit to daylimit
function Wallet(address[] _owners, uint _required, uint _daylimit) payable
constructor(address[] _owners, uint _required, uint _daylimit) payable
multiowned(_owners, _required) daylimit(_daylimit) {
}

View File

@ -287,7 +287,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_simple)
contract C {
uint public _a;
uint[] public _b;
function C(uint a, uint[] b) {
constructor(uint a, uint[] b) {
_a = a;
_b = b;
}
@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE(decode_function_type)
string sourceCode = R"(
contract D {
function () external returns (uint) public _a;
function D(function () external returns (uint) a) {
constructor(function () external returns (uint) a) {
_a = a;
}
}
@ -346,13 +346,13 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array)
string sourceCode = R"(
contract D {
function () external returns (uint)[] public _a;
function D(function () external returns (uint)[] a) {
constructor(function () external returns (uint)[] a) {
_a = a;
}
}
contract E {
function () external returns (uint)[3] public _a;
function E(function () external returns (uint)[3] a) {
constructor(function () external returns (uint)[3] a) {
_a = a;
}
}
@ -414,7 +414,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_complex)
uint public _a;
uint[] public _b;
bytes[2] public _c;
function C(uint a, uint[] b, bytes[2] c) {
constructor(uint a, uint[] b, bytes[2] c) {
_a = a;
_b = b;
_c = c;

View File

@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(store_keccak256)
char const* sourceCode = R"(
contract test {
bytes32 public shaValue;
function test(uint a) {
constructor(uint a) {
shaValue = keccak256(abi.encodePacked(a));
}
}
@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(updating_store)
contract test {
uint data;
uint data2;
function test() {
constructor() {
data = 1;
data = 2;
data2 = 0;

View File

@ -672,7 +672,7 @@ BOOST_AUTO_TEST_CASE(constructor_abi)
{
char const* sourceCode = R"(
contract test {
function test(uint param1, test param2, bool param3) {}
constructor(uint param1, test param2, bool param3) {}
}
)";
@ -704,7 +704,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor_abi)
{
char const* sourceCode = R"(
contract test {
function test(uint param1, test param2, bool param3) payable {}
constructor(uint param1, test param2, bool param3) payable {}
}
)";
@ -738,7 +738,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test(ActionChoices param) {}
constructor(ActionChoices param) {}
function ret() returns(ActionChoices) {
ActionChoices action = ActionChoices.GoLeft;
return action;

View File

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

View File

@ -1280,7 +1280,7 @@ BOOST_AUTO_TEST_CASE(deleteStruct)
uint nestedValue;
mapping (uint => bool) nestedMapping;
}
function test(){
constructor(){
toDelete = 5;
str.topValue = 1;
str.topMapping[0] = 1;
@ -1358,7 +1358,7 @@ BOOST_AUTO_TEST_CASE(constructor)
char const* sourceCode = R"(
contract test {
mapping(uint => uint) data;
function test() {
constructor() {
data[7] = 8;
}
function get(uint key) returns (uint value) {
@ -1382,7 +1382,7 @@ BOOST_AUTO_TEST_CASE(simple_accessor)
char const* sourceCode = R"(
contract test {
uint256 public data;
function test() {
constructor() {
data = 8;
}
}
@ -1401,7 +1401,7 @@ BOOST_AUTO_TEST_CASE(array_accessor)
struct st { uint a; uint[] finalArray; }
mapping(uint256 => mapping(uint256 => st[5])) public multiple_map;
function test() {
constructor() {
data[0] = 8;
dynamicData.length = 3;
dynamicData[2] = 8;
@ -1431,7 +1431,7 @@ BOOST_AUTO_TEST_CASE(accessors_mapping_for_array)
contract test {
mapping(uint => uint[8]) public data;
mapping(uint => uint[]) public dynamicData;
function test() {
constructor() {
data[2][2] = 8;
dynamicData[2].length = 3;
dynamicData[2][2] = 8;
@ -1453,7 +1453,7 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
bytes6 public name;
bytes32 public a_hash;
address public an_address;
function test() {
constructor() {
data = 8;
name = "Celina";
a_hash = keccak256("\x7b");
@ -1479,7 +1479,7 @@ BOOST_AUTO_TEST_CASE(complex_accessors)
mapping(uint256 => bool) public to_bool_map;
mapping(uint256 => uint256) public to_uint_map;
mapping(uint256 => mapping(uint256 => uint256)) public to_multiple_map;
function test() {
constructor() {
to_string_map[42] = "24";
to_bool_map[42] = false;
to_uint_map[42] = 12;
@ -1500,7 +1500,7 @@ BOOST_AUTO_TEST_CASE(struct_accessor)
contract test {
struct Data { uint a; uint8 b; mapping(uint => uint) c; bool d; }
mapping(uint => Data) public data;
function test() {
constructor() {
data[7].a = 1;
data[7].b = 2;
data[7].c[0] = 3;
@ -1516,7 +1516,7 @@ BOOST_AUTO_TEST_CASE(balance)
{
char const* sourceCode = R"(
contract test {
function test() payable {}
constructor() payable {}
function getBalance() returns (uint256 balance) {
return address(this).balance;
}
@ -1530,7 +1530,7 @@ BOOST_AUTO_TEST_CASE(blockchain)
{
char const* sourceCode = R"(
contract test {
function test() payable {}
constructor() payable {}
function someInfo() payable returns (uint256 value, address coinbase, uint256 blockNumber) {
value = msg.value;
coinbase = block.coinbase;
@ -1780,7 +1780,7 @@ BOOST_AUTO_TEST_CASE(send_ether)
{
char const* sourceCode = R"(
contract test {
function test() payable {}
constructor() payable {}
function a(address addr, uint amount) returns (uint ret) {
addr.send(amount);
return address(this).balance;
@ -1798,7 +1798,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
{
char const* sourceCode = R"(
contract A {
function A() payable {}
constructor() payable {}
function a(address addr, uint amount) returns (uint) {
addr.transfer(amount);
return this.balance;
@ -1955,7 +1955,7 @@ BOOST_AUTO_TEST_CASE(log_in_constructor)
{
char const* sourceCode = R"(
contract test {
function test() {
constructor() {
log1(1, 2);
}
}
@ -1972,7 +1972,7 @@ BOOST_AUTO_TEST_CASE(selfdestruct)
{
char const* sourceCode = R"(
contract test {
function test() payable {}
constructor() payable {}
function a(address receiver) returns (uint ret) {
selfdestruct(receiver);
return 10;
@ -2378,7 +2378,7 @@ BOOST_AUTO_TEST_CASE(constructor_arguments_internal)
bytes3 name;
bool flag;
function Helper(bytes3 x, bool f) {
constructor(bytes3 x, bool f) {
name = x;
flag = f;
}
@ -2387,7 +2387,7 @@ BOOST_AUTO_TEST_CASE(constructor_arguments_internal)
}
contract Main {
Helper h;
function Main() {
constructor() {
h = new Helper("abc", true);
}
function getFlag() returns (bool ret) { return h.getFlag(); }
@ -2406,7 +2406,7 @@ BOOST_AUTO_TEST_CASE(constructor_arguments_external)
bytes3 name;
bool flag;
function Main(bytes3 x, bool f) {
constructor(bytes3 x, bool f) {
name = x;
flag = f;
}
@ -2426,7 +2426,7 @@ BOOST_AUTO_TEST_CASE(constructor_with_long_arguments)
string public a;
string public b;
function Main(string _a, string _b) {
constructor(string _a, string _b) {
a = _a;
b = _b;
}
@ -2454,7 +2454,7 @@ BOOST_AUTO_TEST_CASE(constructor_static_array_argument)
uint public a;
uint[3] public b;
function C(uint _a, uint[3] _b) {
constructor(uint _a, uint[3] _b) {
a = _a;
b = _b;
}
@ -2474,7 +2474,7 @@ BOOST_AUTO_TEST_CASE(constant_var_as_array_length)
uint constant LEN = 3;
uint[LEN] public a;
function C(uint[LEN] _a) {
constructor(uint[LEN] _a) {
a = _a;
}
}
@ -2491,7 +2491,7 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
contract Test {
bytes3 name;
bool flag;
function Test() {
constructor() {
setName("abc");
}
function getName() returns (bytes3 ret) { return name; }
@ -2510,7 +2510,7 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses)
}
contract test {
helper h;
function test() payable { h = new helper(); h.send(5); }
constructor() payable { h = new helper(); h.send(5); }
function getBalance() returns (uint256 myBalance, uint256 helperBalance) {
myBalance = this.balance;
helperBalance = h.balance;
@ -2535,7 +2535,7 @@ BOOST_AUTO_TEST_CASE(gas_and_value_basic)
}
contract test {
helper h;
function test() payable { h = new helper(); }
constructor() payable { h = new helper(); }
function sendAmount(uint amount) payable returns (uint256 bal) {
return h.getBalance.value(amount)();
}
@ -2566,7 +2566,7 @@ BOOST_AUTO_TEST_CASE(value_complex)
}
contract test {
helper h;
function test() payable { h = new helper(); }
constructor() payable { h = new helper(); }
function sendAmount(uint amount) payable returns (uint256 bal) {
var x1 = h.getBalance.value(amount);
uint someStackElement = 20;
@ -2589,7 +2589,7 @@ BOOST_AUTO_TEST_CASE(value_insane)
}
contract test {
helper h;
function test() payable { h = new helper(); }
constructor() payable { h = new helper(); }
function sendAmount(uint amount) returns (uint256 bal) {
var x1 = h.getBalance.value;
var x2 = x1(amount).gas;
@ -2608,7 +2608,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
contract Helper {
bytes3 name;
bool flag;
function Helper(bytes3 x, bool f) payable {
constructor(bytes3 x, bool f) payable {
name = x;
flag = f;
}
@ -2617,7 +2617,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
}
contract Main {
Helper h;
function Main() payable {
constructor() payable {
h = (new Helper).value(10)("abc", true);
}
function getFlag() returns (bool ret) { return h.getFlag(); }
@ -2711,12 +2711,12 @@ BOOST_AUTO_TEST_CASE(base_constructor_arguments)
char const* sourceCode = R"(
contract BaseBase {
uint m_a;
function BaseBase(uint a) {
constructor(uint a) {
m_a = a;
}
}
contract Base is BaseBase(7) {
function Base() {
constructor() {
m_a *= m_a;
}
}
@ -2733,7 +2733,7 @@ BOOST_AUTO_TEST_CASE(function_usage_in_constructor_arguments)
char const* sourceCode = R"(
contract BaseBase {
uint m_a;
function BaseBase(uint a) {
constructor(uint a) {
m_a = a;
}
function g() returns (uint r) { return 2; }
@ -2753,7 +2753,7 @@ BOOST_AUTO_TEST_CASE(virtual_function_usage_in_constructor_arguments)
char const* sourceCode = R"(
contract BaseBase {
uint m_a;
function BaseBase(uint a) {
constructor(uint a) {
m_a = a;
}
function overridden() returns (uint r) { return 1; }
@ -2775,7 +2775,7 @@ BOOST_AUTO_TEST_CASE(constructor_argument_overriding)
char const* sourceCode = R"(
contract BaseBase {
uint m_a;
function BaseBase(uint a) {
constructor(uint a) {
m_a = a;
}
}
@ -2792,7 +2792,7 @@ BOOST_AUTO_TEST_CASE(internal_constructor)
{
char const* sourceCode = R"(
contract C {
function C() internal {}
constructor() internal {}
}
)";
BOOST_CHECK(compileAndRunWithoutCheck(sourceCode, 0, "C").empty());
@ -2885,7 +2885,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_calling_functions_in_creation_context)
char const* sourceCode = R"(
contract A {
uint data;
function A() mod1 { f1(); }
constructor() mod1 { f1(); }
function f1() mod2 { data |= 0x1; }
function f2() { data |= 0x20; }
function f3() { }
@ -2908,7 +2908,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_for_constructor)
char const* sourceCode = R"(
contract A {
uint data;
function A() mod1 { data |= 2; }
constructor() mod1 { data |= 2; }
modifier mod1 { data |= 1; _; }
function getData() returns (uint r) { return data; }
}
@ -3034,7 +3034,7 @@ BOOST_AUTO_TEST_CASE(super_in_constructor)
contract A { function f() returns (uint r) { return 1; } }
contract B is A { function f() returns (uint r) { return super.f() | 2; } }
contract C is A { function f() returns (uint r) { return super.f() | 4; } }
contract D is B, C { uint data; function D() { data = super.f() | 8; } function f() returns (uint r) { return data; } }
contract D is B, C { uint data; constructor() { data = super.f() | 8; } function f() returns (uint r) { return data; } }
)";
compileAndRun(sourceCode, 0, "D");
ABI_CHECK(callContractFunction("f()"), encodeArgs(1 | 2 | 4 | 8));
@ -3655,7 +3655,7 @@ BOOST_AUTO_TEST_CASE(generic_call)
function receive(uint256 x) payable { received = x; }
}
contract sender {
function sender() payable {}
constructor() payable {}
function doSend(address rec) returns (uint d)
{
bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)")));
@ -3678,14 +3678,14 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
uint public received;
address public sender;
uint public value;
function Receiver() payable {}
constructor() payable {}
function receive(uint256 x) payable { received = x; sender = msg.sender; value = msg.value; }
}
contract Sender {
uint public received;
address public sender;
uint public value;
function Sender() payable {}
constructor() payable {}
function doSend(address rec) payable
{
bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)")));
@ -3805,7 +3805,7 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes)
function() external { received = 0x80; }
}
contract sender {
function sender() { rec = new receiver(); }
constructor() { rec = new receiver(); }
function() external { savedData = msg.data; }
function forward() returns (bool) { !rec.call(savedData); return true; }
function clear() returns (bool) { delete savedData; return true; }
@ -3875,7 +3875,7 @@ BOOST_AUTO_TEST_CASE(copying_bytes_multiassign)
function() external { received = 0x80; }
}
contract sender {
function sender() { rec = new receiver(); }
constructor() { rec = new receiver(); }
function() external { savedData1 = savedData2 = msg.data; }
function forward(bool selector) returns (bool) {
if (selector) { rec.call(savedData1); delete savedData1; }
@ -4089,7 +4089,7 @@ BOOST_AUTO_TEST_CASE(using_enums)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test()
constructor()
{
choices = ActionChoices.GoStraight;
}
@ -4109,7 +4109,7 @@ BOOST_AUTO_TEST_CASE(enum_explicit_overflow)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight }
function test()
constructor()
{
}
function getChoiceExp(uint x) returns (uint d)
@ -4254,7 +4254,7 @@ BOOST_AUTO_TEST_CASE(inline_member_init)
{
char const* sourceCode = R"(
contract test {
function test(){
constructor(){
m_b = 6;
m_c = 8;
}
@ -4276,12 +4276,12 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence)
{
char const* sourceCode = R"(
contract Base {
function Base(){}
constructor(){}
uint m_base = 5;
function getBMember() returns (uint i) { return m_base; }
}
contract Derived is Base {
function Derived(){}
constructor(){}
uint m_derived = 6;
function getDMember() returns (uint i) { return m_derived; }
}
@ -5477,14 +5477,14 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base)
{
char const* sourceCode = R"(
contract Base {
function Base(uint i)
constructor(uint i)
{
m_i = i;
}
uint public m_i;
}
contract Derived is Base {
function Derived(uint i) Base(i)
constructor(uint i) Base(i)
{}
}
contract Final is Derived(4) {
@ -5498,17 +5498,17 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base)
{
char const* sourceCode = R"(
contract Base {
function Base(uint j)
constructor(uint j)
{
m_i = j;
}
uint public m_i;
}
contract Base1 is Base {
function Base1(uint k) Base(k*k) {}
constructor(uint k) Base(k*k) {}
}
contract Derived is Base, Base1 {
function Derived(uint i) Base(i) Base1(i)
constructor(uint i) Base(i) Base1(i)
{}
}
contract Final is Derived(4) {
@ -5522,7 +5522,7 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap)
{
char const* sourceCode = R"(
contract Base {
function Base(uint i)
constructor(uint i)
{
m_i = i;
}
@ -5530,7 +5530,7 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap)
}
contract Base1 is Base(3) {}
contract Derived is Base, Base1 {
function Derived(uint i) Base(i) {}
constructor(uint i) Base(i) {}
}
contract Final is Derived(4) {
}
@ -5893,7 +5893,7 @@ BOOST_AUTO_TEST_CASE(packed_storage_signed)
BOOST_AUTO_TEST_CASE(external_types_in_calls)
{
char const* sourceCode = R"(
contract C1 { C1 public bla; function C1(C1 x) { bla = x; } }
contract C1 { C1 public bla; constructor(C1 x) { bla = x; } }
contract C {
function test() returns (C1 x, C1 y) {
C1 c = new C1(C1(9));
@ -6106,7 +6106,7 @@ BOOST_AUTO_TEST_CASE(struct_assign_reference_to_struct)
testStruct data1;
testStruct data2;
testStruct data3;
function test()
constructor()
{
data1.m_value = 2;
}
@ -6138,7 +6138,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_member)
uint m_value;
}
testStruct data1;
function test()
constructor()
{
data1.m_value = 2;
}
@ -6165,7 +6165,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_struct_in_mapping)
}
mapping (uint => testStruct) campaigns;
function test()
constructor()
{
campaigns[0].m_value = 2;
}
@ -6208,7 +6208,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_call_fail)
{
char const* sourceCode = R"(
contract A {
function A()
constructor()
{
this.call("123");
}
@ -6234,7 +6234,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund)
contract A {
uint public test = 1;
uint[3] arr;
function A()
constructor()
{
uint index = 5;
test = arr[index];
@ -6270,7 +6270,7 @@ BOOST_AUTO_TEST_CASE(failing_send)
}
}
contract Main {
function Main() payable {}
constructor() payable {}
function callHelper(address _a) returns (bool r, uint bal) {
r = !_a.send(5);
bal = this.balance;
@ -6293,7 +6293,7 @@ BOOST_AUTO_TEST_CASE(send_zero_ether)
}
}
contract Main {
function Main() payable {}
constructor() payable {}
function s() returns (bool) {
var r = new Receiver();
return r.send(0);
@ -6310,7 +6310,7 @@ BOOST_AUTO_TEST_CASE(reusing_memory)
char const* sourceCode = R"(
contract Helper {
uint public flag;
function Helper(uint x) {
constructor(uint x) {
flag = x;
}
}
@ -6541,7 +6541,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_unpacker)
contract Test {
uint public m_x;
bytes public m_s;
function Test(uint x, bytes s) {
constructor(uint x, bytes s) {
m_x = x;
m_s = s;
}
@ -6562,7 +6562,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer)
contract Base {
uint public m_x;
bytes m_s;
function Base(uint x, bytes s) {
constructor(uint x, bytes s) {
m_x = x;
m_s = s;
}
@ -6571,7 +6571,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer)
}
}
contract Main is Base {
function Main(bytes s, uint x) Base(x, f(s)) {}
constructor(bytes s, uint x) Base(x, f(s)) {}
function f(bytes s) returns (bytes) {
return s;
}
@ -6601,7 +6601,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_constructors)
contract Base {
uint public m_x;
address[] m_s;
function Base(uint x, address[] s) {
constructor(uint x, address[] s) {
m_x = x;
m_s = s;
}
@ -6610,7 +6610,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_constructors)
}
}
contract Main is Base {
function Main(address[] s, uint x) Base(x, f(s)) {}
constructor(address[] s, uint x) Base(x, f(s)) {}
function f(address[] s) returns (address[]) {
return s;
}
@ -6640,7 +6640,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_in_constructors)
contract Creator {
uint public r;
address public ch;
function Creator(address[3] s, uint x) {
constructor(address[3] s, uint x) {
r = x;
ch = s[2];
}
@ -7060,7 +7060,7 @@ BOOST_AUTO_TEST_CASE(struct_constructor_nested)
struct X { uint x1; uint x2; }
struct S { uint s1; uint[3] s2; X s3; }
S s;
function C() {
constructor() {
uint[3] memory s2;
s2[1] = 9;
s = S(1, s2, X(4, 5));
@ -7086,7 +7086,7 @@ BOOST_AUTO_TEST_CASE(struct_named_constructor)
contract C {
struct S { uint a; bool x; }
S public s;
function C() {
constructor() {
s = S({a: 1, x: true});
}
}
@ -7368,7 +7368,7 @@ BOOST_AUTO_TEST_CASE(constant_string_literal)
bytes32 constant public b = "abcdefghijklmnopq";
string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
function Test() {
constructor() {
var xx = x;
var bb = b;
}
@ -7501,7 +7501,7 @@ BOOST_AUTO_TEST_CASE(strings_in_struct)
string last;
}
function buggystruct(){
constructor(){
bug = Buggy(10, 20, 30, "asdfghjkl");
}
function getFirst() returns (uint)
@ -7776,7 +7776,7 @@ BOOST_AUTO_TEST_CASE(calldata_offset)
{
address[] _arr;
string public last = "nd";
function CB(address[] guardians)
constructor(address[] guardians)
{
_arr = guardians;
}
@ -7801,7 +7801,7 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
char const* sourceCode = R"(
library lib {}
contract c {
function c() payable {}
constructor() payable {}
function f(address x) returns (bool) {
return x.send(1);
}
@ -8222,7 +8222,7 @@ BOOST_AUTO_TEST_CASE(string_allocation_bug)
{
struct s { uint16 x; uint16 y; string a; string b;}
s[2] public p;
function Sample() {
constructor() {
s memory m;
m.x = 0xbbbb;
m.y = 0xcccc;
@ -9158,10 +9158,10 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types_for_structs)
BOOST_AUTO_TEST_CASE(failed_create)
{
char const* sourceCode = R"(
contract D { function D() payable {} }
contract D { constructor() payable {} }
contract C {
uint public x;
function C() payable {}
constructor() payable {}
function f(uint amount) returns (address) {
x++;
return (new D).value(amount)();
@ -9204,7 +9204,7 @@ BOOST_AUTO_TEST_CASE(correctly_initialize_memory_array_in_constructor)
char const* sourceCode = R"(
contract C {
bool public success;
function C() public {
constructor() public {
// Make memory dirty.
assembly {
for { let i := 0 } lt(i, 64) { i := add(i, 1) } {
@ -9301,7 +9301,7 @@ BOOST_AUTO_TEST_CASE(mutex)
}
contract Fund is mutexed {
uint shares;
function Fund() payable { shares = msg.value; }
constructor() payable { shares = msg.value; }
function withdraw(uint amount) protected returns (uint) {
// NOTE: It is very bad practice to write this function this way.
// Please refer to the documentation of how to do this properly.
@ -9324,7 +9324,7 @@ BOOST_AUTO_TEST_CASE(mutex)
uint callDepth;
bool protected;
function setProtected(bool _protected) { protected = _protected; }
function Attacker(Fund _fund) { fund = _fund; }
constructor(Fund _fund) { fund = _fund; }
function attack() returns (uint) {
callDepth = 0;
return attackInternal();
@ -9447,7 +9447,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor)
{
char const* sourceCode = R"(
contract C {
function C() payable { }
constructor() payable { }
}
)";
compileAndRun(sourceCode, 27, "C");
@ -9729,7 +9729,7 @@ BOOST_AUTO_TEST_CASE(store_function_in_constructor)
contract C {
uint public result_in_constructor;
function (uint) internal returns (uint) x;
function C () {
constructor() {
x = double;
result_in_constructor = use(2);
}
@ -9754,7 +9754,7 @@ BOOST_AUTO_TEST_CASE(store_internal_unused_function_in_constructor)
char const* sourceCode = R"(
contract C {
function () internal returns (uint) x;
function C () {
constructor() {
x = unused;
}
function unused() internal returns (uint) {
@ -9776,7 +9776,7 @@ BOOST_AUTO_TEST_CASE(store_internal_unused_library_function_in_constructor)
library L { function x() internal returns (uint) { return 7; } }
contract C {
function () internal returns (uint) x;
function C () {
constructor() {
x = L.x;
}
function t() returns (uint) {
@ -9794,7 +9794,7 @@ BOOST_AUTO_TEST_CASE(same_function_in_construction_and_runtime)
char const* sourceCode = R"(
contract C {
uint public initial;
function C() {
constructor() {
initial = double(2);
}
function double(uint _arg) returns (uint _ret) {
@ -9816,7 +9816,7 @@ BOOST_AUTO_TEST_CASE(same_function_in_construction_and_runtime_equality_check)
char const* sourceCode = R"(
contract C {
function (uint) internal returns (uint) x;
function C() {
constructor() {
x = double;
}
function test() returns (bool) {
@ -9907,7 +9907,7 @@ BOOST_AUTO_TEST_CASE(mapping_of_functions)
success = true;
}
function Flow() {
constructor() {
stages[msg.sender] = stage0;
}
@ -10900,7 +10900,7 @@ BOOST_AUTO_TEST_CASE(include_creation_bytecode_only_once)
contract D {
bytes a = hex"1237651237125387136581271652831736512837126583171583712358126123765123712538713658127165283173651283712658317158371235812612376512371253871365812716528317365128371265831715837123581261237651237125387136581271652831736512837126583171583712358126";
bytes b = hex"1237651237125327136581271252831736512837126583171383712358126123765125712538713658127165253173651283712658357158371235812612376512371a5387136581271652a317365128371265a317158371235812612a765123712538a13658127165a83173651283712a58317158371235a126";
function D(uint) {}
constructor(uint) {}
}
contract Double {
function f() {
@ -11224,7 +11224,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create)
{
char const* sourceCode = R"(
contract E {
function E() {
constructor() {
revert("message");
}
}

View File

@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination)
{
char const* sourceCode = R"(
contract test {
function test () {
constructor() {
var x = 1 wei;
}
}
@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination)
{
char const* sourceCode = R"(
contract test {
function test () {
constructor() {
var x = 1 szabo;
}
}
@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination)
{
char const* sourceCode = R"(
contract test {
function test ()
constructor()
{
var x = 1 finney;
}
@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination)
{
char const* sourceCode = R"(
contract test {
function test () {
constructor() {
var x = 1 ether;
}
}

View File

@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor)
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
contract base { function foo(); }
contract foo is base { function foo() public {} }
contract foo is base { constructor() public {} }
)";
sourceUnit = parseAndAnalyse(text);
std::vector<ASTPointer<ASTNode>> nodes = sourceUnit->nodes();

View File

@ -385,7 +385,7 @@ BOOST_AUTO_TEST_CASE(computing_constants)
uint m_b;
uint m_c;
uint m_d;
function C() {
constructor() {
set();
}
function set() returns (uint) {
@ -561,7 +561,7 @@ BOOST_AUTO_TEST_CASE(dead_code_elimination_across_assemblies)
char const* sourceCode = R"(
contract DCE {
function () internal returns (uint) stored;
function DCE() {
constructor() {
stored = f;
}
function f() internal returns (uint) { return 7; }

View File

@ -0,0 +1,3 @@
contract A { constructor() {} }
// ----
// Warning: (13-29): No visibility specified. Defaulting to "public".

View File

@ -0,0 +1,4 @@
pragma experimental "v0.5.0";
contract A { constructor() {} }
// ----
// SyntaxError: (43-59): No visibility specified.

View File

@ -1,6 +1,10 @@
// It is fine to "override" constructor of a base class since it is invisible
contract A { function A() public { } }
contract A { constructor() public {} }
contract B is A { function A() public pure returns (uint8) {} }
contract C is A { function A() public pure returns (uint8) {} }
contract D is B { function B() public pure returns (uint8) {} }
contract E is D { function B() public pure returns (uint8) {} }
// ----
// Warning: (91-114): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (135-178): This declaration shadows an existing declaration.
// Warning: (57-100): This declaration shadows an existing declaration.
// Warning: (121-164): This declaration shadows an existing declaration.
// Warning: (185-228): This declaration shadows an existing declaration.
// Warning: (249-292): This declaration shadows an existing declaration.

View File

@ -1,5 +1,4 @@
contract A { function A(uint a) public { } }
contract A { constructor(uint a) public { } }
contract B is A { }
// ----
// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning.

View File

@ -1,5 +1,4 @@
contract A { function A(uint a) public { } }
contract A { constructor(uint a) public { } }
contract B is A { }
// ----
// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning.

View File

@ -1,8 +1,7 @@
contract c {
function c () public {
constructor() public {
a = 115792089237316195423570985008687907853269984665640564039458;
}
uint256 a;
}
// ----
// Warning: (17-119): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.

View File

@ -1,9 +1,8 @@
contract c {
function c () public {
constructor() public {
a = 115792089237316195423570985008687907853269984665640564039458 ether;
}
uint256 a;
}
// ----
// Warning: (17-125): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (52-118): Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256.

View File

@ -1,11 +1,10 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test()
constructor()
{
choices = ActionChoices.GoStraight;
}
ActionChoices choices;
}
// ----
// Warning: (80-151): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (80-151): No visibility specified. Defaulting to "public".
// Warning: (80-149): No visibility specified. Defaulting to "public".

View File

@ -1,10 +1,9 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
choices = ActionChoices.RunAroundWavingYourHands;
}
ActionChoices choices;
}
// ----
// Warning: (80-168): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (123-161): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices)
// TypeError: (121-159): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices)

View File

@ -1,10 +1,9 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
choices = Sit;
}
ActionChoices choices;
}
// ----
// Warning: (80-133): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// DeclarationError: (123-126): Undeclared identifier.
// DeclarationError: (121-124): Undeclared identifier.

View File

@ -1,6 +1,6 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
a = uint256(ActionChoices.GoStraight);
b = uint64(ActionChoices.Sit);
}
@ -8,4 +8,3 @@ contract test {
uint64 b;
}
// ----
// Warning: (80-196): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.

View File

@ -1,6 +1,6 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
a = 2;
b = ActionChoices(a);
}
@ -8,4 +8,3 @@ contract test {
ActionChoices b;
}
// ----
// Warning: (80-155): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.

View File

@ -1,10 +1,9 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
a = ActionChoices.GoStraight;
}
uint256 a;
}
// ----
// Warning: (80-148): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (117-141): Type enum test.ActionChoices is not implicitly convertible to expected type uint256.
// TypeError: (115-139): Type enum test.ActionChoices is not implicitly convertible to expected type uint256.

View File

@ -1,10 +1,9 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
b = ActionChoices.Sit;
}
uint64 b;
}
// ----
// Warning: (80-141): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (117-134): Type enum test.ActionChoices is not implicitly convertible to expected type uint64.
// TypeError: (115-132): Type enum test.ActionChoices is not implicitly convertible to expected type uint64.

View File

@ -1,10 +1,9 @@
contract test {
enum Paper { Up, Down, Left, Right }
enum Ground { North, South, West, East }
function test() public {
constructor() public {
Ground(Paper.Up);
}
}
// ----
// Warning: (106-162): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (139-155): Explicit type conversion not allowed from "enum test.Paper" to "enum test.Ground".
// TypeError: (137-153): Explicit type conversion not allowed from "enum test.Paper" to "enum test.Ground".

View File

@ -1,5 +1,5 @@
contract C {
function C() { }
constructor() { }
}
contract D {
function f() public returns (uint) {
@ -8,5 +8,4 @@ contract D {
}
}
// ----
// Warning: (17-33): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (98-111): Member "value" not found or not visible after argument-dependent lookup in function () returns (contract C) - did you forget the "payable" modifier?
// TypeError: (99-112): Member "value" not found or not visible after argument-dependent lookup in function () returns (contract C) - did you forget the "payable" modifier?

View File

@ -1,7 +1,6 @@
contract test {
struct S { uint x; }
function test(uint k) public { S[k]; }
constructor(uint k) public { S[k]; }
}
// ----
// Warning: (45-83): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (78-79): Integer constant expected.
// TypeError: (76-77): Integer constant expected.

View File

@ -1,10 +1,9 @@
contract C {
struct S { uint a; bool x; }
S public s;
function C() public {
constructor() public {
3({a: 1, x: true});
}
}
// ----
// Warning: (66-121): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (96-114): Type is not callable
// TypeError: (97-115): Type is not callable

View File

@ -1,10 +1,9 @@
contract c {
enum validEnum { Value1, Value2, Value3, Value4 }
function c() {
constructor() {
a = validEnum.Value3;
}
validEnum a;
}
// ----
// Warning: (71-121): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (71-121): No visibility specified. Defaulting to "public".
// Warning: (71-122): No visibility specified. Defaulting to "public".

View File

@ -1,10 +1,9 @@
contract c {
function c ()
constructor()
{
a = 1 wei * 100 wei + 7 szabo - 3;
}
uint256 a;
}
// ----
// Warning: (17-86): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (17-86): No visibility specified. Defaulting to "public".