User-defined operators: Tests

This commit is contained in:
wechman
2023-01-25 00:29:10 +01:00
committed by Kamil Śliwak
parent fd6359000e
commit 1edb74dbc9
85 changed files with 2138 additions and 1 deletions
@@ -0,0 +1,17 @@
type X is uint24;
type Y is uint16;
using {addX as +} for X;
using {addY as +} for Y;
function addX(X, X) pure returns (X) {}
function addY(Y, Y) pure returns (Y) { revert(); }
contract C {
function f() public pure {
X.wrap(1) + X.wrap(Y.unwrap(Y.wrap(2) + Y.wrap(3)));
X.wrap(4) + X.wrap(5); // Unreachable
}
}
// ----
// Warning 5740: (293-314): Unreachable code.
@@ -0,0 +1,17 @@
type X is uint24;
type Y is uint16;
using {unsubX as -} for X;
using {unsubY as -} for Y;
function unsubX(X) pure returns (X) {}
function unsubY(Y) pure returns (Y) { revert(); }
contract C {
function f() public pure {
-X.wrap(Y.unwrap(-Y.wrap(1)));
-X.wrap(Y.unwrap(Y.wrap(2))); // Unreachable
}
}
// ----
// Warning 5740: (273-301): Unreachable code.