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 {
|
||||
error E();
|
||||
}
|
||||
library S {
|
||||
error E(uint);
|
||||
}
|
||||
library T {
|
||||
error E();
|
||||
error E(bytes4, bool, bytes);
|
||||
}
|
||||
|
||||
error E();
|
||||
error E(bytes4, bool, bytes);
|
||||
|
||||
interface I {
|
||||
error E();
|
||||
function f() external pure;
|
||||
error E(bytes4, bool, bytes);
|
||||
}
|
||||
|
||||
contract D {
|
||||
error F();
|
||||
contract B {
|
||||
error E(bytes4, bool, bytes);
|
||||
}
|
||||
|
||||
contract C is D {
|
||||
function test1() public pure returns (bytes4, bytes4, bytes4, bytes4) {
|
||||
assert(L.E.selector == T.E.selector);
|
||||
assert(L.E.selector != S.E.selector);
|
||||
assert(E.selector == L.E.selector);
|
||||
assert(I.E.selector == L.E.selector);
|
||||
return (L.E.selector, S.E.selector, E.selector, I.E.selector);
|
||||
}
|
||||
contract C is B {
|
||||
bytes4 public librarySelector = L.E.selector;
|
||||
bytes4 internal freeSelector = E.selector;
|
||||
bytes4 internal contractSelector = B.E.selector;
|
||||
bytes4 private interfaceSelector = I.E.selector;
|
||||
|
||||
bytes4 s1 = L.E.selector;
|
||||
bytes4 s2 = S.E.selector;
|
||||
bytes4 s3 = T.E.selector;
|
||||
bytes4 s4 = I.E.selector;
|
||||
function f(bool condition) public view {
|
||||
assert(librarySelector == L.E.selector);
|
||||
assert(E.selector == B.E.selector);
|
||||
|
||||
function test2() view external returns (bytes4, bytes4, bytes4, bytes4) {
|
||||
return (s1, s2, s3, s4);
|
||||
}
|
||||
|
||||
function test3() pure external returns (bytes4) {
|
||||
return (F.selector);
|
||||
if (condition)
|
||||
revert E(E.selector, true, "123");
|
||||
else
|
||||
revert L.E((B.E.selector), true, "123");
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 2519: (16-26): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (45-59): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (78-88): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (122-132): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (16-45): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (98-127): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (148-177): This declaration shadows an existing declaration.
|
||||
|
@ -6,7 +6,6 @@ contract D {
|
||||
function test1() external pure returns (bytes32) {
|
||||
return Y.E.selector;
|
||||
}
|
||||
|
||||
}
|
||||
// ----
|
||||
// TypeError 9582: (123-135): Member "selector" not found or not visible after argument-dependent lookup in function ().
|
||||
|
@ -1,37 +1,20 @@
|
||||
library L {
|
||||
event E();
|
||||
}
|
||||
library S {
|
||||
event E(uint);
|
||||
}
|
||||
library T {
|
||||
event E();
|
||||
event E(bytes32, bool, bytes indexed);
|
||||
}
|
||||
|
||||
contract D {
|
||||
event F();
|
||||
contract B {
|
||||
event E(bytes32, bool, bytes indexed);
|
||||
}
|
||||
|
||||
contract C is D {
|
||||
function test1() external pure returns (bytes32, bytes32) {
|
||||
assert(L.E.selector == T.E.selector);
|
||||
contract C is B {
|
||||
bytes32 public librarySelector = L.E.selector;
|
||||
bytes32 inheritedSelector = E.selector;
|
||||
|
||||
assert(L.E.selector != S.E.selector);
|
||||
assert(T.E.selector != S.E.selector);
|
||||
function f() public {
|
||||
assert(librarySelector == L.E.selector);
|
||||
assert(E.selector == B.E.selector);
|
||||
|
||||
return (L.E.selector, S.E.selector);
|
||||
}
|
||||
|
||||
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);
|
||||
emit E(E.selector, true, "123");
|
||||
emit L.E((B.E.selector), true, "123");
|
||||
}
|
||||
}
|
||||
// ----
|
||||
|
Loading…
Reference in New Issue
Block a user