mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for error syntax.
This commit is contained in:
parent
01a267bd91
commit
f748f44a79
9
test/libsolidity/syntaxTests/errors/abi_decode_error.sol
Normal file
9
test/libsolidity/syntaxTests/errors/abi_decode_error.sol
Normal file
@ -0,0 +1,9 @@
|
||||
error E(uint);
|
||||
contract C {
|
||||
function f() public pure returns (bytes memory) {
|
||||
return abi.decode(msg.data, (E));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1039: (119-120): Argument has to be a type name.
|
||||
// TypeError 5132: (90-122): Different number of arguments in return statement than in returns declaration.
|
8
test/libsolidity/syntaxTests/errors/abi_encode_error.sol
Normal file
8
test/libsolidity/syntaxTests/errors/abi_encode_error.sol
Normal file
@ -0,0 +1,8 @@
|
||||
error E(uint);
|
||||
contract C {
|
||||
function f() public pure returns (bytes memory) {
|
||||
return abi.encode(E);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 2056: (108-109): This type cannot be encoded.
|
@ -0,0 +1,8 @@
|
||||
error E(uint);
|
||||
contract C {
|
||||
function f() public pure returns (bytes memory) {
|
||||
return abi.encode(E(2));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 2056: (108-112): This type cannot be encoded.
|
@ -0,0 +1,6 @@
|
||||
error E();
|
||||
function f(bool x) pure {
|
||||
assert(x, E());
|
||||
}
|
||||
// ----
|
||||
// TypeError 6160: (41-55): Wrong argument count for function call: 2 arguments given but expected 1.
|
@ -0,0 +1,6 @@
|
||||
error E();
|
||||
function f() pure {
|
||||
assert(E());
|
||||
}
|
||||
// ----
|
||||
// TypeError 9553: (42-45): Invalid type for argument in function call. Invalid implicit conversion from tuple() to bool requested.
|
@ -8,6 +8,6 @@ function g() pure {
|
||||
}
|
||||
// ----
|
||||
// TypeError 6473: (43-46): Tuple component cannot be empty.
|
||||
// TypeError 4423: (42-47): Expected error or string.
|
||||
// TypeError 4423: (42-47): Expected error instance or string.
|
||||
// TypeError 6473: (100-103): Tuple component cannot be empty.
|
||||
// TypeError 4423: (99-104): Expected error or string.
|
||||
// TypeError 4423: (99-104): Expected error instance or string.
|
||||
|
@ -0,0 +1,2 @@
|
||||
error E(address payable x);
|
||||
// ----
|
@ -0,0 +1,4 @@
|
||||
error E(uint);
|
||||
function f(E x) pure returns (uint) {}
|
||||
// ----
|
||||
// TypeError 5172: (26-27): Name has to refer to a struct, enum or contract.
|
@ -0,0 +1,4 @@
|
||||
interface C {
|
||||
error E(uint);
|
||||
}
|
||||
// ----
|
4
test/libsolidity/syntaxTests/errors/error_in_library.sol
Normal file
4
test/libsolidity/syntaxTests/errors/error_in_library.sol
Normal file
@ -0,0 +1,4 @@
|
||||
library L {
|
||||
error E(uint);
|
||||
}
|
||||
// ----
|
@ -0,0 +1,3 @@
|
||||
error E(uint[] memory);
|
||||
// ----
|
||||
// ParserError 2314: (15-21): Expected ',' but got 'memory'
|
@ -0,0 +1,3 @@
|
||||
error E(uint[] calldata);
|
||||
// ----
|
||||
// ParserError 2314: (15-23): Expected ',' but got 'calldata'
|
@ -1,3 +1,3 @@
|
||||
error Error(uint);
|
||||
// ----
|
||||
// SyntaxError 1855: (44-62): The built-in errors "Error" and "Panic" cannot be re-defined.
|
||||
// SyntaxError 1855: (0-18): The built-in errors "Error" and "Panic" cannot be re-defined.
|
||||
|
6
test/libsolidity/syntaxTests/errors/hash_collision.sol
Normal file
6
test/libsolidity/syntaxTests/errors/hash_collision.sol
Normal file
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
error gsf();
|
||||
error tgeo();
|
||||
}
|
||||
// ----
|
||||
// TypeError 4883: (0-52): Error signature hash collision for tgeo()
|
3
test/libsolidity/syntaxTests/errors/indexed_error.sol
Normal file
3
test/libsolidity/syntaxTests/errors/indexed_error.sol
Normal file
@ -0,0 +1,3 @@
|
||||
error E(uint indexed);
|
||||
// ----
|
||||
// ParserError 2314: (13-20): Expected ',' but got 'indexed'
|
@ -3,4 +3,4 @@ function f() pure {
|
||||
revert((E)());
|
||||
}
|
||||
// ----
|
||||
// TypeError 4423: (42-47): Expected error or string.
|
||||
// TypeError 4423: (42-47): Expected error instance or string.
|
||||
|
@ -1,7 +1,7 @@
|
||||
error E1(uint);
|
||||
error E1();
|
||||
error E2();
|
||||
function f() pure {
|
||||
revert(E1(E2));
|
||||
revert(E1(E2()));
|
||||
}
|
||||
// ----
|
||||
// TypeError 9553: (62-64): Invalid type for argument in function call. Invalid implicit conversion from function () pure to uint256 requested.
|
||||
// TypeError 6160: (55-63): Wrong argument count for function call: 1 arguments given but expected 0.
|
||||
|
@ -1,5 +1,3 @@
|
||||
// TODO: What if an error is imported and alias as Panic?
|
||||
// TODO I Think the best way would be to have Error in the global scope.
|
||||
error Panic(bytes2);
|
||||
// ----
|
||||
// SyntaxError 1855: (131-151): The built-in errors "Error" and "Panic" cannot be re-defined.
|
||||
// SyntaxError 1855: (0-20): The built-in errors "Error" and "Panic" cannot be re-defined.
|
||||
|
@ -4,4 +4,4 @@ function f() pure {
|
||||
revert(E1);
|
||||
}
|
||||
// ----
|
||||
// TypeError 4423: (55-57): Expected error or string.
|
||||
// TypeError 4423: (55-57): Expected error instance or string. Did you forget the "()" after the error?
|
||||
|
7
test/libsolidity/syntaxTests/errors/weird1.sol
Normal file
7
test/libsolidity/syntaxTests/errors/weird1.sol
Normal file
@ -0,0 +1,7 @@
|
||||
error E();
|
||||
|
||||
contract C {
|
||||
function() internal pure x = E;
|
||||
}
|
||||
// ----
|
||||
// TypeError 7407: (58-59): Type function () pure is not implicitly convertible to expected type function () pure. Special functions can not be converted to function types.
|
7
test/libsolidity/syntaxTests/errors/weird2.sol
Normal file
7
test/libsolidity/syntaxTests/errors/weird2.sol
Normal file
@ -0,0 +1,7 @@
|
||||
error E();
|
||||
|
||||
contract C {
|
||||
bytes4 t = E.selector;
|
||||
}
|
||||
// ----
|
||||
// TypeError 9582: (40-50): Member "selector" not found or not visible after argument-dependent lookup in function () pure.
|
7
test/libsolidity/syntaxTests/errors/weird3.sol
Normal file
7
test/libsolidity/syntaxTests/errors/weird3.sol
Normal file
@ -0,0 +1,7 @@
|
||||
error E();
|
||||
|
||||
contract C {
|
||||
E x;
|
||||
}
|
||||
// ----
|
||||
// TypeError 5172: (29-30): Name has to refer to a struct, enum or contract.
|
9
test/libsolidity/syntaxTests/errors/weird4.sol
Normal file
9
test/libsolidity/syntaxTests/errors/weird4.sol
Normal file
@ -0,0 +1,9 @@
|
||||
error E();
|
||||
|
||||
contract C {
|
||||
function f() public pure {
|
||||
E x;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 5172: (64-65): Name has to refer to a struct, enum or contract.
|
Loading…
Reference in New Issue
Block a user