mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Add ABI test for pure function
This commit is contained in:
		
							parent
							
								
									5668377c72
								
							
						
					
					
						commit
						e9a9a07d94
					
				| @ -2,7 +2,7 @@ | ||||
| 
 | ||||
| Features: | ||||
|  * Introduce ``pure`` functions. The pureness is not enforced yet, use with care. | ||||
|  * ABI JSON: Include new field ``statemutability`` with values ``view``, ``nonpayable`` and ``payable``. | ||||
|  * ABI JSON: Include new field ``statemutability`` with values ``pure``, ``view``, ``nonpayable`` and ``payable``. | ||||
|  * Analyzer: Experimental partial support for Z3 SMT checker. | ||||
|  * Parser: Display previous visibility specifier in error if multiple are found. | ||||
|  * Parser: Introduce ``view`` keyword on functions (``constant`` remains an alias for ``view``). | ||||
|  | ||||
| @ -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"( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user