Update and extend tests for return expressions.

This commit is contained in:
Daniel Kirchner
2018-08-07 20:49:52 +02:00
parent cc83e69469
commit bb518b59aa
8 changed files with 84 additions and 28 deletions
@@ -0,0 +1,14 @@
contract C
{
function f() public pure returns (uint)
{
return;
}
function g() public pure returns (uint)
{
return (1, 2);
}
}
// ----
// TypeError: (71-78): Return arguments required.
// TypeError: (143-156): Different number of arguments in return statement than in returns declaration.
@@ -0,0 +1,14 @@
contract C
{
function f() public pure returns (uint a)
{
return;
}
function g() public pure returns (uint a)
{
return (1, 2);
}
}
// ----
// TypeError: (73-80): Return arguments required.
// TypeError: (147-160): Different number of arguments in return statement than in returns declaration.
@@ -0,0 +1,19 @@
contract C
{
function f() public pure returns (uint, uint)
{
return 1;
}
function g() public pure returns (uint, uint)
{
return (1, 2, 3);
}
function h() public pure returns (uint, uint)
{
return;
}
}
// ----
// TypeError: (77-85): Different number of arguments in return statement than in returns declaration.
// TypeError: (157-173): Different number of arguments in return statement than in returns declaration.
// TypeError: (245-252): Return arguments required.
@@ -0,0 +1,19 @@
contract C
{
function f() public pure returns (uint a, uint b)
{
return 1;
}
function g() public pure returns (uint a, uint b)
{
return (1, 2, 3);
}
function h() public pure returns (uint a, uint b)
{
return;
}
}
// ----
// TypeError: (81-89): Different number of arguments in return statement than in returns declaration.
// TypeError: (165-181): Different number of arguments in return statement than in returns declaration.
// TypeError: (257-264): Return arguments required.
@@ -0,0 +1,18 @@
contract C
{
function f() public pure {
return;
}
function g() public pure returns (uint) {
return 1;
}
function h() public pure returns (uint a) {
return 1;
}
function i() public pure returns (uint, uint) {
return (1, 2);
}
function j() public pure returns (uint a, uint b) {
return (1, 2);
}
}