forked from MystenLabs/sui
-
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.
[move-compiler] Treat
entry
functions as public
in test_only and …
…test contexts (MystenLabs#14416) ## Description - entry functions are callable outside of the module, but only from the adapter level - Allowing entry functions to be called from tests should improve usability of entry functions in unit tests, without the need for public wrappers ## Test Plan - Added Tests --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [X] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes In this release, the Move compiler now allows `entry` functions to be called within unit-test environments, `#[test]` and `#[test_only]` functions, without the need of an additional `#[test_only] public` wrapper function.
- Loading branch information
Showing
8 changed files
with
184 additions
and
21 deletions.
There are no files selected for viewing
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
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
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
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
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
21 changes: 21 additions & 0 deletions
21
...ove/crates/move-compiler/tests/move_check/unit_test/entry_is_public_in_test_contexts.move
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,21 @@ | ||
// entry functions are public if called from test or test_only | ||
|
||
module a::m { | ||
entry fun internal(_ :u64) {} | ||
} | ||
|
||
#[test_only] | ||
module a::test_only { | ||
fun example() { | ||
// force a type error to make sure visibility is allowed | ||
a::m::internal(0u8) | ||
} | ||
} | ||
|
||
module a::tests { | ||
#[test] | ||
fun test() { | ||
// force a type error to make sure visibility is allowed | ||
a::m::internal(0u8) | ||
} | ||
} |
Empty file.
Oops, something went wrong.