From bc47265b3f6d5c15b5c57c3edc927448a8599096 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 8 May 2018 13:08:52 +0200 Subject: Replace constant with view in the tests. --- .../parsing/constant_state_modifier.sol | 7 +++++ .../syntaxTests/parsing/empty_function.sol | 8 +++--- .../multiple_statemutability_specifiers.sol | 33 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol create mode 100644 test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol (limited to 'test/libsolidity/syntaxTests/parsing') diff --git a/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol b/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol new file mode 100644 index 00000000..da068351 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol @@ -0,0 +1,7 @@ +contract C { + uint s; + // this test should fail starting from 0.5.0 + function f() public constant returns (uint) { + return s; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/empty_function.sol b/test/libsolidity/syntaxTests/parsing/empty_function.sol index 4f845189..218fd9a7 100644 --- a/test/libsolidity/syntaxTests/parsing/empty_function.sol +++ b/test/libsolidity/syntaxTests/parsing/empty_function.sol @@ -1,10 +1,10 @@ contract test { uint256 stateVar; - function functionName(bytes20 arg1, address addr) constant returns (int id) { } + function functionName(bytes20 arg1, address addr) view returns (int id) { } } // ---- -// Warning: (36-115): No visibility specified. Defaulting to "public". +// Warning: (36-111): No visibility specified. Defaulting to "public". // Warning: (58-70): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (72-84): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (104-110): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (36-115): Function state mutability can be restricted to pure +// Warning: (100-106): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (36-111): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol b/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol new file mode 100644 index 00000000..a05bf452 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol @@ -0,0 +1,33 @@ +contract c1 { + function f() payable payable {} +} +contract c2 { + function f() view view {} +} +contract c3 { + function f() pure pure {} +} +contract c4 { + function f() pure view {} +} +contract c5 { + function f() payable view {} +} +contract c6 { + function f() pure payable {} +} +contract c7 { + function f() pure constant {} +} +contract c8 { + function f() view constant {} +} +// ---- +// ParserError: (39-46): State mutability already specified as "payable". +// ParserError: (88-92): State mutability already specified as "view". +// ParserError: (134-138): State mutability already specified as "pure". +// ParserError: (180-184): State mutability already specified as "pure". +// ParserError: (229-233): State mutability already specified as "payable". +// ParserError: (275-282): State mutability already specified as "pure". +// ParserError: (324-332): State mutability already specified as "pure". +// ParserError: (374-382): State mutability already specified as "view". -- cgit