mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update and extend tests for return expressions.
This commit is contained in:
@@ -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.
|
||||
+14
@@ -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.
|
||||
+19
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user