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;
|
using {foo as +, foo as -} for Int;
|
||||||
|
|
||||||
function foo(Int, Int) pure returns(Int) {
|
function foo(Int a, Int b) pure returns(Int) {
|
||||||
return Int.wrap(7);
|
return Int.wrap(Int.unwrap(a) + Int.unwrap(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
function f() pure public returns (Int) {
|
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) {
|
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
|
// g() -> 7
|
||||||
|
@ -9,8 +9,10 @@ function add(Int, Int) returns (Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contract B {
|
contract B {
|
||||||
function f() pure external returns (Int) {
|
Int s;
|
||||||
return Int.wrap(3);
|
function f() external returns (Int) {
|
||||||
|
s = Int.wrap(3);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
type SmallInt is int;
|
type SmallInt is int;
|
||||||
type BigInt is int;
|
type BigInt is int;
|
||||||
|
|
||||||
using {add1 as +} for SmallInt;
|
using {addSmall as +} for SmallInt;
|
||||||
using {add2 as +} for BigInt;
|
using {addBig as +} for BigInt;
|
||||||
|
|
||||||
function add1(SmallInt, SmallInt) pure returns (SmallInt) {
|
function addSmall(SmallInt a, SmallInt b) pure returns (SmallInt) {
|
||||||
return SmallInt.wrap(1);
|
return SmallInt.wrap(SmallInt.unwrap(a) + SmallInt.unwrap(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
function add2(BigInt, BigInt) pure returns (BigInt) {
|
function addBig(BigInt a, BigInt b) pure returns (BigInt) {
|
||||||
return BigInt.wrap(2);
|
return BigInt.wrap(10 * (BigInt.unwrap(a) + BigInt.unwrap(b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
function f() public pure returns (SmallInt) {
|
function small() public pure returns (SmallInt) {
|
||||||
return SmallInt.wrap(0) + SmallInt.wrap(0);
|
return SmallInt.wrap(1) + SmallInt.wrap(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
function g() public pure returns (BigInt) {
|
function big() public pure returns (BigInt) {
|
||||||
return BigInt.wrap(0) + BigInt.wrap(0);
|
return BigInt.wrap(3) + BigInt.wrap(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// f() -> 1
|
// small() -> 3
|
||||||
// g() -> 2
|
// big() -> 70
|
||||||
|
@ -26,8 +26,6 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====
|
|
||||||
// compileViaYul: also
|
|
||||||
// ----
|
// ----
|
||||||
// f() -> 7
|
// f() -> 7
|
||||||
// g() -> 5
|
// g() -> 5
|
||||||
|
@ -1,29 +1,42 @@
|
|||||||
type Int is int128;
|
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);
|
return Int.wrap(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
function another_add(Int, Int) pure returns (Int) {
|
function addC(Int, Int) pure returns (Int) {
|
||||||
return Int.wrap(7);
|
return Int.wrap(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract B {
|
contract A {
|
||||||
using {add as +} for Int;
|
using {addA as +} for Int;
|
||||||
|
|
||||||
function f() pure public returns (Int) {
|
function testA() pure public returns (Int) {
|
||||||
return Int.wrap(0) + Int.wrap(0);
|
return Int.wrap(0) + Int.wrap(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C is B {
|
contract B is A {
|
||||||
using {another_add as +} for Int;
|
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);
|
return Int.wrap(0) + Int.wrap(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// f() -> 3
|
// testA() -> 1
|
||||||
// g() -> 7
|
// testB() -> 3
|
||||||
|
// testC() -> 7
|
||||||
|
Loading…
Reference in New Issue
Block a user