aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-24 21:53:13 +0800
committerGitHub <noreply@github.com>2017-08-24 21:53:13 +0800
commitd3fd6a8800ddd15be509971b516bb823bbd93b86 (patch)
tree49ef0252dd6902d46aed69b581494984e4697c41 /test/libsolidity
parent65d78f36c1f5b88546261bc005ef952065d34adf (diff)
parentf646247dfb7d398255b3e2cc1aa6e25fe8424af3 (diff)
downloaddexon-solidity-d3fd6a8800ddd15be509971b516bb823bbd93b86.tar
dexon-solidity-d3fd6a8800ddd15be509971b516bb823bbd93b86.tar.gz
dexon-solidity-d3fd6a8800ddd15be509971b516bb823bbd93b86.tar.bz2
dexon-solidity-d3fd6a8800ddd15be509971b516bb823bbd93b86.tar.lz
dexon-solidity-d3fd6a8800ddd15be509971b516bb823bbd93b86.tar.xz
dexon-solidity-d3fd6a8800ddd15be509971b516bb823bbd93b86.tar.zst
dexon-solidity-d3fd6a8800ddd15be509971b516bb823bbd93b86.zip
Merge pull request #2745 from ethereum/statemutability-pure
Introduce pure specifier on functions
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp55
-rw-r--r--test/libsolidity/SolidityParser.cpp10
2 files changed, 65 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index 12fb1f9c..dd51d926 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -361,6 +361,61 @@ BOOST_AUTO_TEST_CASE(constant_function)
checkInterface(sourceCode, interface);
}
+BOOST_AUTO_TEST_CASE(pure_function)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function foo(uint a, uint b) returns(uint d) { return a + b; }
+ function boo(uint32 a) pure 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": "pure",
+ "type": "function",
+ "inputs": [{
+ "name": "a",
+ "type": "uint32"
+ }],
+ "outputs": [
+ {
+ "name": "b",
+ "type": "uint256"
+ }
+ ]
+ }
+ ])";
+
+ checkInterface(sourceCode, interface);
+}
+
BOOST_AUTO_TEST_CASE(events)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 8e84ead1..a39e0958 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -928,6 +928,16 @@ BOOST_AUTO_TEST_CASE(multiple_statemutability_specifiers)
function f() payable constant {}
})";
CHECK_PARSE_ERROR(text, "State mutability already specified as \"payable\".");
+ text = R"(
+ contract c {
+ function f() pure payable {}
+ })";
+ CHECK_PARSE_ERROR(text, "State mutability already specified as \"pure\".");
+ text = R"(
+ contract c {
+ function f() pure constant {}
+ })";
+ CHECK_PARSE_ERROR(text, "State mutability already specified as \"pure\".");
}
BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations)