forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a multisource test for UserDefinedValueTypes and imports
Testing if `import {MyType} from "source";` works
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
test/libsolidity/semanticTests/userDefinedValueType/multisource.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
13 changes: 13 additions & 0 deletions
13
test/libsolidity/semanticTests/userDefinedValueType/multisource_module.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
10 changes: 10 additions & 0 deletions
10
test/libsolidity/syntaxTests/userDefinedValueType/multisource1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
10 changes: 10 additions & 0 deletions
10
test/libsolidity/syntaxTests/userDefinedValueType/multisource2.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/syntaxTests/userDefinedValueType/multisource3.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); } | ||
} | ||
// ---- |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/syntaxTests/userDefinedValueType/multisource4.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |