mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Additional tests for using for directive
This commit is contained in:
parent
6ebefdd1f8
commit
b7d5d6bfaf
@ -0,0 +1,21 @@
|
||||
type Int is int32;
|
||||
|
||||
using {foo as +, foo as -} for Int;
|
||||
|
||||
function foo(Int, Int) pure returns(Int) {
|
||||
return Int.wrap(7);
|
||||
}
|
||||
|
||||
contract C {
|
||||
function f() pure public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
|
||||
function g() pure public returns (Int) {
|
||||
return Int.wrap(0) - Int.wrap(0);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// f() -> 7
|
||||
// g() -> 7
|
@ -0,0 +1,21 @@
|
||||
type Int is int16;
|
||||
|
||||
using {add as +, add} for Int;
|
||||
|
||||
function add(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(5) + Int.wrap(5);
|
||||
}
|
||||
|
||||
function g() pure public returns (Int) {
|
||||
return Int.wrap(7).add(Int.wrap(6));
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// f() -> 10
|
||||
// g() -> 13
|
@ -0,0 +1,13 @@
|
||||
type Int is int32;
|
||||
|
||||
using {add as +, add as +} for Int;
|
||||
|
||||
function add(Int, Int) pure returns(Int) {
|
||||
return Int.wrap(0);
|
||||
}
|
||||
|
||||
function f() pure {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
|
||||
// ----
|
@ -0,0 +1,14 @@
|
||||
type Int is int32;
|
||||
|
||||
using {add as +} for Int;
|
||||
using {add as +} for Int;
|
||||
|
||||
function add(Int, Int) pure returns(Int) {
|
||||
return Int.wrap(0);
|
||||
}
|
||||
|
||||
function f() pure {
|
||||
Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
|
||||
// ----
|
Loading…
Reference in New Issue
Block a user