mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update tests for view
This commit is contained in:
parent
9e8d2a561f
commit
70bb1e7478
@ -250,7 +250,63 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
||||
checkInterface(sourceCode, interface);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(const_function)
|
||||
BOOST_AUTO_TEST_CASE(view_function)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
function foo(uint a, uint b) returns(uint d) { return a + b; }
|
||||
function boo(uint32 a) view 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);
|
||||
}
|
||||
|
||||
// constant is an alias to view above
|
||||
BOOST_AUTO_TEST_CASE(constant_function)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
|
@ -918,6 +918,11 @@ BOOST_AUTO_TEST_CASE(multiple_statemutability_specifiers)
|
||||
function f() constant constant {}
|
||||
})";
|
||||
CHECK_PARSE_ERROR(text, "State mutability already specified as \"view\".");
|
||||
text = R"(
|
||||
contract c {
|
||||
function f() constant view {}
|
||||
})";
|
||||
CHECK_PARSE_ERROR(text, "State mutability already specified as \"view\".");
|
||||
text = R"(
|
||||
contract c {
|
||||
function f() payable constant {}
|
||||
|
Loading…
Reference in New Issue
Block a user