Added a multisource test for UserDefinedValueTypes and imports

Testing if `import {MyType} from "source";` works
This commit is contained in:
hrkrshnn 2021-09-14 16:02:42 +02:00
parent 48e16ceb88
commit 15fb427a99
6 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,14 @@
==== Source: A ====
type MyInt is int;
type MyAddress is address;
==== Source: B ====
import {MyInt, MyAddress as OurAddress} from "A";
contract A {
function f(int x) external view returns(MyInt) { return MyInt.wrap(x); }
function f(address x) external view returns(OurAddress) { return OurAddress.wrap(x); }
}
// ====
// compileViaYul: also
// ----
// f(int256): 5 -> 5
// f(address): 1 -> 1

View File

@ -0,0 +1,13 @@
==== Source: s1.sol ====
type MyInt is int;
==== Source: s2.sol ====
import "s1.sol" as M;
contract C {
function f(int x) public pure returns (M.MyInt) { return M.MyInt.wrap(x); }
function g(M.MyInt x) public pure returns (int) { return M.MyInt.unwrap(x); }
}
// ====
// compileViaYul: also
// ----
// f(int256): 5 -> 5
// g(int256): 1 -> 1

View File

@ -0,0 +1,10 @@
==== Source: A ====
type MyInt is int;
type MyAddress is address;
==== Source: B ====
import {MyAddress as OurAddress} from "A";
contract A {
function f(int x) external view returns(MyInt) { return MyInt.wrap(x); }
}
// ----
// DeclarationError 7920: (B:100-105): Identifier not found or not unique.

View File

@ -0,0 +1,10 @@
==== Source: A ====
type MyInt is int;
type MyAddress is address;
==== Source: B ====
import {MyAddress as OurAddress} from "A";
contract A {
function f(address x) external view returns(MyAddress) { return MyAddress.wrap(x); }
}
// ----
// DeclarationError 7920: (B:104-113): Identifier not found or not unique.

View File

@ -0,0 +1,9 @@
==== Source: s1.sol ====
type MyInt is int;
==== Source: s2.sol ====
import "s1.sol" as M;
contract C {
function f(int x) public pure returns (M.MyInt) { return M.MyInt.wrap(x); }
function g(M.MyInt x) public pure returns (int) { return M.MyInt.unwrap(x); }
}
// ----

View File

@ -0,0 +1,9 @@
==== Source: s1.sol ====
type MyInt is int;
==== Source: s2.sol ====
import "s1.sol" as M;
contract C {
function f(int x) public pure returns (MyInt) { return MyInt.wrap(x); }
}
// ----
// DeclarationError 7920: (s2.sol:76-81): Identifier not found or not unique.