mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Semantic tests update after review
This commit is contained in:
parent
8bb8373436
commit
d414469014
@ -2,20 +2,20 @@ type Int is int32;
|
||||
|
||||
using {foo as +, foo as -} for Int;
|
||||
|
||||
function foo(Int, Int) pure returns(Int) {
|
||||
return Int.wrap(7);
|
||||
function foo(Int a, Int b) pure returns(Int) {
|
||||
return Int.wrap(Int.unwrap(a) + Int.unwrap(b));
|
||||
}
|
||||
|
||||
contract C {
|
||||
function f() pure public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
return Int.wrap(2) + Int.wrap(3);
|
||||
}
|
||||
|
||||
function g() pure public returns (Int) {
|
||||
return Int.wrap(0) - Int.wrap(0);
|
||||
return Int.wrap(6) - Int.wrap(1);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// f() -> 7
|
||||
// f() -> 5
|
||||
// g() -> 7
|
||||
|
@ -9,8 +9,10 @@ function add(Int, Int) returns (Int) {
|
||||
}
|
||||
|
||||
contract B {
|
||||
function f() pure external returns (Int) {
|
||||
return Int.wrap(3);
|
||||
Int s;
|
||||
function f() external returns (Int) {
|
||||
s = Int.wrap(3);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,27 +1,27 @@
|
||||
type SmallInt is int;
|
||||
type BigInt is int;
|
||||
|
||||
using {add1 as +} for SmallInt;
|
||||
using {add2 as +} for BigInt;
|
||||
using {addSmall as +} for SmallInt;
|
||||
using {addBig as +} for BigInt;
|
||||
|
||||
function add1(SmallInt, SmallInt) pure returns (SmallInt) {
|
||||
return SmallInt.wrap(1);
|
||||
function addSmall(SmallInt a, SmallInt b) pure returns (SmallInt) {
|
||||
return SmallInt.wrap(SmallInt.unwrap(a) + SmallInt.unwrap(b));
|
||||
}
|
||||
|
||||
function add2(BigInt, BigInt) pure returns (BigInt) {
|
||||
return BigInt.wrap(2);
|
||||
function addBig(BigInt a, BigInt b) pure returns (BigInt) {
|
||||
return BigInt.wrap(10 * (BigInt.unwrap(a) + BigInt.unwrap(b)));
|
||||
}
|
||||
|
||||
contract C {
|
||||
function f() public pure returns (SmallInt) {
|
||||
return SmallInt.wrap(0) + SmallInt.wrap(0);
|
||||
function small() public pure returns (SmallInt) {
|
||||
return SmallInt.wrap(1) + SmallInt.wrap(2);
|
||||
}
|
||||
|
||||
function g() public pure returns (BigInt) {
|
||||
return BigInt.wrap(0) + BigInt.wrap(0);
|
||||
function big() public pure returns (BigInt) {
|
||||
return BigInt.wrap(3) + BigInt.wrap(4);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// f() -> 1
|
||||
// g() -> 2
|
||||
// small() -> 3
|
||||
// big() -> 70
|
||||
|
@ -26,8 +26,6 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 7
|
||||
// g() -> 5
|
||||
|
@ -1,29 +1,42 @@
|
||||
type Int is int128;
|
||||
|
||||
function add(Int, Int) pure returns (Int) {
|
||||
function addA(Int, Int) pure returns (Int) {
|
||||
return Int.wrap(1);
|
||||
}
|
||||
|
||||
function addB(Int, Int) pure returns (Int) {
|
||||
return Int.wrap(3);
|
||||
}
|
||||
|
||||
function another_add(Int, Int) pure returns (Int) {
|
||||
function addC(Int, Int) pure returns (Int) {
|
||||
return Int.wrap(7);
|
||||
}
|
||||
|
||||
contract B {
|
||||
using {add as +} for Int;
|
||||
contract A {
|
||||
using {addA as +} for Int;
|
||||
|
||||
function f() pure public returns (Int) {
|
||||
function testA() pure public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
|
||||
contract C is B {
|
||||
using {another_add as +} for Int;
|
||||
contract B is A {
|
||||
using {addB as +} for Int;
|
||||
|
||||
function g() pure public returns (Int) {
|
||||
function testB() pure public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
|
||||
contract C is A, B {
|
||||
using {addC as +} for Int;
|
||||
|
||||
function testC() pure public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// f() -> 3
|
||||
// g() -> 7
|
||||
// testA() -> 1
|
||||
// testB() -> 3
|
||||
// testC() -> 7
|
||||
|
Loading…
Reference in New Issue
Block a user