mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Refactor error/event selector tests
- Remove redundant semantic tests for error selector - Consolidate semanticTests/error/ and semanticTests/errors/ dirs - Make "selector syntax test" for errors and event an actual test for syntax rather than a copy of the same semantic test
This commit is contained in:
parent
acbdcc3711
commit
5375dfff9d
@ -1,18 +0,0 @@
|
|||||||
library L {
|
|
||||||
error E();
|
|
||||||
}
|
|
||||||
library S {
|
|
||||||
error E(uint);
|
|
||||||
}
|
|
||||||
library T {
|
|
||||||
error E();
|
|
||||||
}
|
|
||||||
contract C {
|
|
||||||
function f() public pure returns (bytes4, bytes4) {
|
|
||||||
assert(L.E.selector == T.E.selector);
|
|
||||||
assert(L.E.selector != S.E.selector);
|
|
||||||
return (L.E.selector, S.E.selector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ----
|
|
||||||
// f() -> 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x2ff06700000000000000000000000000000000000000000000000000000000
|
|
@ -1,48 +1,34 @@
|
|||||||
library L {
|
library L {
|
||||||
error E();
|
error E(bytes4, bool, bytes);
|
||||||
}
|
|
||||||
library S {
|
|
||||||
error E(uint);
|
|
||||||
}
|
|
||||||
library T {
|
|
||||||
error E();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error E();
|
error E(bytes4, bool, bytes);
|
||||||
|
|
||||||
interface I {
|
interface I {
|
||||||
error E();
|
error E(bytes4, bool, bytes);
|
||||||
function f() external pure;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract D {
|
contract B {
|
||||||
error F();
|
error E(bytes4, bool, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C is D {
|
contract C is B {
|
||||||
function test1() public pure returns (bytes4, bytes4, bytes4, bytes4) {
|
bytes4 public librarySelector = L.E.selector;
|
||||||
assert(L.E.selector == T.E.selector);
|
bytes4 internal freeSelector = E.selector;
|
||||||
assert(L.E.selector != S.E.selector);
|
bytes4 internal contractSelector = B.E.selector;
|
||||||
assert(E.selector == L.E.selector);
|
bytes4 private interfaceSelector = I.E.selector;
|
||||||
assert(I.E.selector == L.E.selector);
|
|
||||||
return (L.E.selector, S.E.selector, E.selector, I.E.selector);
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes4 s1 = L.E.selector;
|
function f(bool condition) public view {
|
||||||
bytes4 s2 = S.E.selector;
|
assert(librarySelector == L.E.selector);
|
||||||
bytes4 s3 = T.E.selector;
|
assert(E.selector == B.E.selector);
|
||||||
bytes4 s4 = I.E.selector;
|
|
||||||
|
|
||||||
function test2() view external returns (bytes4, bytes4, bytes4, bytes4) {
|
if (condition)
|
||||||
return (s1, s2, s3, s4);
|
revert E(E.selector, true, "123");
|
||||||
}
|
else
|
||||||
|
revert L.E((B.E.selector), true, "123");
|
||||||
function test3() pure external returns (bytes4) {
|
|
||||||
return (F.selector);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 2519: (16-26): This declaration shadows an existing declaration.
|
// Warning 2519: (16-45): This declaration shadows an existing declaration.
|
||||||
// Warning 2519: (45-59): This declaration shadows an existing declaration.
|
// Warning 2519: (98-127): This declaration shadows an existing declaration.
|
||||||
// Warning 2519: (78-88): This declaration shadows an existing declaration.
|
// Warning 2519: (148-177): This declaration shadows an existing declaration.
|
||||||
// Warning 2519: (122-132): This declaration shadows an existing declaration.
|
|
||||||
|
@ -6,7 +6,6 @@ contract D {
|
|||||||
function test1() external pure returns (bytes32) {
|
function test1() external pure returns (bytes32) {
|
||||||
return Y.E.selector;
|
return Y.E.selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// TypeError 9582: (123-135): Member "selector" not found or not visible after argument-dependent lookup in function ().
|
// TypeError 9582: (123-135): Member "selector" not found or not visible after argument-dependent lookup in function ().
|
||||||
|
@ -1,37 +1,20 @@
|
|||||||
library L {
|
library L {
|
||||||
event E();
|
event E(bytes32, bool, bytes indexed);
|
||||||
}
|
|
||||||
library S {
|
|
||||||
event E(uint);
|
|
||||||
}
|
|
||||||
library T {
|
|
||||||
event E();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract D {
|
contract B {
|
||||||
event F();
|
event E(bytes32, bool, bytes indexed);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C is D {
|
contract C is B {
|
||||||
function test1() external pure returns (bytes32, bytes32) {
|
bytes32 public librarySelector = L.E.selector;
|
||||||
assert(L.E.selector == T.E.selector);
|
bytes32 inheritedSelector = E.selector;
|
||||||
|
|
||||||
assert(L.E.selector != S.E.selector);
|
function f() public {
|
||||||
assert(T.E.selector != S.E.selector);
|
assert(librarySelector == L.E.selector);
|
||||||
|
assert(E.selector == B.E.selector);
|
||||||
|
|
||||||
return (L.E.selector, S.E.selector);
|
emit E(E.selector, true, "123");
|
||||||
}
|
emit L.E((B.E.selector), true, "123");
|
||||||
|
|
||||||
bytes32 s1 = L.E.selector;
|
|
||||||
bytes32 s2 = S.E.selector;
|
|
||||||
bytes32 s3 = T.E.selector;
|
|
||||||
|
|
||||||
function test2() view external returns (bytes32, bytes32, bytes32) {
|
|
||||||
return (s1, s2, s3);
|
|
||||||
}
|
|
||||||
|
|
||||||
function test3() pure external returns (bytes32) {
|
|
||||||
return (F.selector);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
|
||||||
|
Loading…
Reference in New Issue
Block a user