diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index 7d161ff..2a6ac0e 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -329,4 +329,7 @@ failing_contracts() -> <<"The init function should return the initial state as its result and cannot read the state,\n" "but it calls\n" " - state (at line 13, column 13)">>]} + , {"field_parse_error", + [<<"line 6, column 1: In field_parse_error at 5:26:\n" + "Cannot use nested fields or keys in record construction: p.x\n">>]} ]. diff --git a/test/aeso_parser_tests.erl b/test/aeso_parser_tests.erl index bebdd91..dcbbcd0 100644 --- a/test/aeso_parser_tests.erl +++ b/test/aeso_parser_tests.erl @@ -62,7 +62,7 @@ simple_contracts_test_() -> %% Parse tests of example contracts [ {lists:concat(["Parse the ", Contract, " contract."]), fun() -> roundtrip_contract(Contract) end} - || Contract <- [counter, voting, all_syntax, '05_greeter', aeproof, multi_sig, simple_storage, withdrawal, fundme, dutch_auction] ] + || Contract <- [counter, voting, all_syntax, '05_greeter', aeproof, multi_sig, simple_storage, fundme, dutch_auction] ] }. parse_contract(Name) -> diff --git a/test/contracts/field_parse_error.aes b/test/contracts/field_parse_error.aes new file mode 100644 index 0000000..719b32a --- /dev/null +++ b/test/contracts/field_parse_error.aes @@ -0,0 +1,5 @@ + +contract Fail = + record pt = {x : int, y : int} + record r = {p : pt} + function fail() = {p.x = 0, p.y = 0} diff --git a/test/contracts/withdrawal.aes b/test/contracts/withdrawal.aes deleted file mode 100644 index b80f5c9..0000000 --- a/test/contracts/withdrawal.aes +++ /dev/null @@ -1,56 +0,0 @@ -/* Example from Solidity by Example - http://solidity.readthedocs.io/en/develop/common-patterns.html - - contract WithdrawalContract { - address public richest - uint public mostSent - - mapping (address => uint) pendingWithdrawals - - function WithdrawalContract() payable { - richest = msg.sender - mostSent = msg.value - } - - function becomeRichest() payable returns (bool) { - if (msg.value > mostSent) { - pendingWithdrawals[richest] += msg.value - richest = msg.sender - mostSent = msg.value - return true - } else { - return false - } - } - - function withdraw() { - uint amount = pendingWithdrawals[msg.sender] - // Remember to zero the pending refund before - // sending to prevent re-entrancy attacks - pendingWithdrawals[msg.sender] = 0 - msg.sender.transfer(amount) - } - } - -*/ - -contract WithdrawalContract = - - record state = { richest : address, - mostSent : uint, - pendingWithdrawals : map(address, uint) } - - function becomeRichest() : result(bool) = - if (call().value > state.mostSent) - let totalAmount : uint = Map.get_(state.richest, pendingWithdrawals) + call().value - {state = state{ pendingWithdrawals = Map.insert(state.richest, call().value, state.pendingWithdrawals), - richest = call().sender, - mostSent = call().value }, - result = true} - else - {result = false} - - function withdraw() = - let amount : uint = Map.get_(call().sender, state.pendingWithdrawals) - { state.pendingWithdrawals = Map.insert(call().sender, 0, state.pendingWithdrawals), - transactions = spend_tx(amount, call().sender) }