diff options
Diffstat (limited to 'test/libsolidity')
11 files changed, 105 insertions, 27 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 97cf0410..3081b8f2 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -5823,7 +5823,7 @@ BOOST_AUTO_TEST_CASE(bare_others) CHECK_WARNING("contract C { function f() pure public { assert; } }", "Statement has no effect."); // This is different because it does have overloads. CHECK_ERROR("contract C { function f() pure public { require; } }", TypeError, "No matching declaration found after variable lookup."); - CHECK_WARNING("contract C { function f() pure public { suicide; } }", "Statement has no effect."); + CHECK_WARNING("contract C { function f() pure public { selfdestruct; } }", "Statement has no effect."); } BOOST_AUTO_TEST_CASE(pure_statement_in_for_loop) @@ -6958,31 +6958,6 @@ BOOST_AUTO_TEST_CASE(invalid_literal_in_tuple) CHECK_SUCCESS(text); } -BOOST_AUTO_TEST_CASE(warn_about_sha3) -{ - char const* text = R"( - contract test { - function f() pure public { - bytes32 x = sha3(uint8(1)); - x; - } - } - )"; - CHECK_WARNING(text, "\"sha3\" has been deprecated in favour of \"keccak256\""); -} - -BOOST_AUTO_TEST_CASE(warn_about_suicide) -{ - char const* text = R"( - contract test { - function f() public { - suicide(1); - } - } - )"; - CHECK_WARNING(text, "\"suicide\" has been deprecated in favour of \"selfdestruct\""); -} - BOOST_AUTO_TEST_CASE(address_overload_resolution) { char const* text = R"( diff --git a/test/libsolidity/syntaxTests/deprecated_functions.sol b/test/libsolidity/syntaxTests/deprecated_functions.sol new file mode 100644 index 00000000..57ee484a --- /dev/null +++ b/test/libsolidity/syntaxTests/deprecated_functions.sol @@ -0,0 +1,12 @@ +contract test { + function f() pure public { + bytes32 x = sha3(uint8(1)); + x; + } + function g() public { + suicide(1); + } +} +// ---- +// Warning: (58-72): "sha3" has been deprecated in favour of "keccak256" +// Warning: (107-117): "suicide" has been deprecated in favour of "selfdestruct" diff --git a/test/libsolidity/syntaxTests/deprecated_functions_050.sol b/test/libsolidity/syntaxTests/deprecated_functions_050.sol new file mode 100644 index 00000000..7e36543b --- /dev/null +++ b/test/libsolidity/syntaxTests/deprecated_functions_050.sol @@ -0,0 +1,13 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + bytes32 x = sha3(uint8(1)); + x; + } + function g() public { + suicide(1); + } +} +// ---- +// TypeError: (88-102): "sha3" has been deprecated in favour of "keccak256" +// TypeError: (137-147): "suicide" has been deprecated in favour of "selfdestruct" diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol index 617af543..ef6da75d 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol @@ -19,7 +19,7 @@ contract C { // ---- // TypeError: (117-118): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// Warning: (191-198): "sha3" has been deprecated in favour of "keccak256" +// TypeError: (191-198): "sha3" has been deprecated in favour of "keccak256" // TypeError: (196-197): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. // TypeError: (277-278): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. // TypeError: (361-362): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol new file mode 100644 index 00000000..3e40b155 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol @@ -0,0 +1,10 @@ +pragma solidity ^0.4.3; +contract C { + event SomeEvent(); + function a() public { + (SomeEvent(), 7); + } +} +// ---- +// Warning: (95-106): Invoking events without "emit" prefix is deprecated. +// Warning: (95-106): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol new file mode 100644 index 00000000..aec5ff2a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol @@ -0,0 +1,10 @@ +pragma experimental "v0.5.0"; +contract C { + event SomeEvent(); + function a() public { + (SomeEvent(), 7); + } +} +// ---- +// TypeError: (101-112): Event invocations have to be prefixed by "emit". +// TypeError: (101-112): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol new file mode 100644 index 00000000..05b54442 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol @@ -0,0 +1,12 @@ +pragma solidity ^0.4.3; +contract C { + function f() private pure {} + function a() public pure { + bool x = true; + bool y = true; + (x) ? (f(), y = false) : (f(), y = false); + } +} +// ---- +// Warning: (162-165): Tuple component cannot be empty. +// Warning: (181-184): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol new file mode 100644 index 00000000..c4b9e03f --- /dev/null +++ b/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract C { + function f() private pure {} + function a() public pure { + bool x = true; + bool y = true; + (x) ? (f(), y = false) : (f(), y = false); + } +} +// ---- +// TypeError: (168-171): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol new file mode 100644 index 00000000..cba30c1b --- /dev/null +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol @@ -0,0 +1,13 @@ +pragma solidity ^0.4.3; +contract C { + function f() private pure {} + function a() public { + uint x; + uint y; + (x, y) = (f(), f()); + } +} +// ---- +// Warning: (146-149): Tuple component cannot be empty. +// Warning: (151-154): Tuple component cannot be empty. +// TypeError: (145-155): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256). diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol new file mode 100644 index 00000000..b0691778 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract C { + function f() private pure {} + function a() public { + uint x; + uint y; + (x, y) = (f(), f()); + } +} +// ---- +// TypeError: (152-155): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol new file mode 100644 index 00000000..f8b2ae7e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol @@ -0,0 +1,11 @@ +pragma solidity ^0.4.3; +contract C { + function f() private pure {} + function a() public { + uint x; + uint y; + (x, y) = [f(), f()]; + } +} +// ---- +// TypeError: (146-149): Array component cannot be empty. |