From 5668377c721c48f03518a02d0b3e45b5b61a52f6 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 15 Aug 2017 02:26:24 +0100 Subject: Introduce pure specifier on functions --- test/libsolidity/SolidityParser.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') 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) -- cgit v1.2.3 From e9a9a07d94d35fd9b84b16b7bd4bf8ab0b396d22 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 15 Aug 2017 19:13:05 +0100 Subject: Add ABI test for pure function --- test/libsolidity/SolidityABIJSON.cpp | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'test') 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"( -- cgit v1.2.3