Update test suite.

This commit is contained in:
Daniel Kirchner 2018-05-08 13:08:52 +02:00
parent f7153ee58a
commit 717c70a88f
6 changed files with 13 additions and 77 deletions

View File

@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(function_type)
CompilerStack c;
c.addSource("a",
"contract C { function f(function() external payable returns (uint) x) "
"returns (function() external constant returns (uint)) {} }"
"returns (function() external view returns (uint)) {} }"
);
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();

View File

@ -316,7 +316,7 @@ BOOST_AUTO_TEST_CASE(complex_control_flow)
// we previously considered. This of course reduces accuracy.
char const* sourceCode = R"(
contract log {
function ln(int128 x) constant returns (int128 result) {
function ln(int128 x) pure returns (int128 result) {
int128 t = x / 256;
int128 y = 5545177;
x = t;

View File

@ -306,62 +306,6 @@ BOOST_AUTO_TEST_CASE(view_function)
checkInterface(sourceCode, interface);
}
// constant is an alias to view above
BOOST_AUTO_TEST_CASE(constant_function)
{
char const* sourceCode = R"(
contract test {
function foo(uint a, uint b) returns(uint d) { return a + b; }
function boo(uint32 a) constant returns(uint b) { return a * 4; }
}
)";
char const* interface = R"([
{
"name": "foo",
"constant": false,
"payable" : false,
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
"name": "a",
"type": "uint256"
},
{
"name": "b",
"type": "uint256"
}
],
"outputs": [
{
"name": "d",
"type": "uint256"
}
]
},
{
"name": "boo",
"constant": true,
"payable" : false,
"stateMutability": "view",
"type": "function",
"inputs": [{
"name": "a",
"type": "uint32"
}],
"outputs": [
{
"name": "b",
"type": "uint256"
}
]
}
])";
checkInterface(sourceCode, interface);
}
BOOST_AUTO_TEST_CASE(pure_function)
{
char const* sourceCode = R"(

View File

@ -1,13 +1,9 @@
contract test1 {
constructor() constant {}
}
contract test2 {
constructor() view {}
}
contract test3 {
contract test2 {
constructor() pure {}
}
// ----
// TypeError: (19-44): Constructor must be payable or non-payable, but is "view".
// TypeError: (66-87): Constructor must be payable or non-payable, but is "view".
// TypeError: (109-130): Constructor must be payable or non-payable, but is "pure".
// TypeError: (19-40): Constructor must be payable or non-payable, but is "view".
// TypeError: (62-83): Constructor must be payable or non-payable, but is "pure".

View File

@ -1,16 +1,11 @@
contract test1 {
function test1() constant {}
function test1() view {}
}
contract test2 {
function test2() view {}
}
contract test3 {
function test3() pure {}
function test2() pure {}
}
// ----
// Warning: (21-49): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (73-97): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (121-145): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (21-49): Constructor must be payable or non-payable, but is "view".
// TypeError: (73-97): Constructor must be payable or non-payable, but is "view".
// TypeError: (121-145): Constructor must be payable or non-payable, but is "pure".
// Warning: (21-45): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (69-93): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (21-45): Constructor must be payable or non-payable, but is "view".
// TypeError: (69-93): Constructor must be payable or non-payable, but is "pure".

View File

@ -1,7 +1,8 @@
contract C {
uint s;
// this test should fail starting from 0.5.0
function f() public constant returns (uint) {
return s;
}
}
// ----
// ParserError: (43-51): The state mutability modifier "constant" was removed in version 0.5.0. Use "view" or "pure" instead.