-
Notifications
You must be signed in to change notification settings - Fork 578
[tests] Cover interface method desugaring parity #12610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simonrozsival
wants to merge
6
commits into
main
Choose a base branch
from
simonrozsival-interface-desugaring-parity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fb1f04a
[tests] Cover interface method desugaring parity
simonrozsival bdc5073
[tests] Isolate interface desugaring packages
simonrozsival 85651d6
[tests] Address interface desugaring review feedback
simonrozsival 1777498
[tests] Scope cached dexdump method matching
simonrozsival 8c8be5b
[tests] Harden cached dexdump edge handling
simonrozsival e8fb44f
[tests] Preserve interface test failures during cleanup
simonrozsival File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DexUtilsTests.cs
This file contains hidden or 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,93 @@ | ||
| using NUnit.Framework; | ||
| using Xamarin.ProjectTools; | ||
|
|
||
| namespace Xamarin.Android.Build.Tests; | ||
|
|
||
| [TestFixture] | ||
| public class DexUtilsTests | ||
| { | ||
| [Test] | ||
| public void ContainsClassWithMethodScopesSignatureToMethod () | ||
| { | ||
| var dexDump = new [] { | ||
| " Class descriptor : 'Lexample/Peer;'", | ||
| " name : 'target'", | ||
| " type : '(I)V'", | ||
| " name : 'other'", | ||
| " type : '()V'", | ||
| }; | ||
|
|
||
| Assert.IsTrue (DexUtils.ContainsClassWithMethod ("Lexample/Peer;", "target", "(I)V", dexDump)); | ||
| Assert.IsFalse (DexUtils.ContainsClassWithMethod ("Lexample/Peer;", "target", "()V", dexDump)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ContainsClassWithMethodMatchesExactNames () | ||
| { | ||
| var dexDump = new [] { | ||
| " Class descriptor : 'Lexample/PeerExtension;'", | ||
| " name : 'getValueExtension'", | ||
| " type : '()I'", | ||
| }; | ||
|
|
||
| Assert.IsFalse (DexUtils.ContainsClassWithMethod ("Lexample/Peer;", "getValue", "()I", dexDump)); | ||
| } | ||
|
|
||
| [TestCase ("()Ljava/lang/Object;")] | ||
| [TestCase ("()Ljava/lang/String;")] | ||
| public void ContainsClassWithMethodMatchesOverloads (string signature) | ||
| { | ||
| var dexDump = new [] { | ||
| " Class descriptor : 'Lexample/Derived;'", | ||
| " name : 'getValue'", | ||
| " type : '()Ljava/lang/Object;'", | ||
| " name : 'getValue'", | ||
| " type : '()Ljava/lang/String;'", | ||
| }; | ||
|
|
||
| Assert.IsTrue (DexUtils.ContainsClassWithMethod ("Lexample/Derived;", "getValue", signature, dexDump)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ContainsClassWithMethodRejectsMissingSignature () | ||
| { | ||
| var dexDump = new [] { | ||
| " Class descriptor : 'Lexample/Peer;'\r", | ||
| " name : '$default$getValue'\r", | ||
| " access : 0x0009 (PUBLIC STATIC)\r", | ||
| " type : '()I'\r", | ||
| }; | ||
|
|
||
| Assert.IsFalse (DexUtils.ContainsClassWithMethod ("Lexample/Peer;", "$default$getValue", "()I", dexDump)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ContainsClassWithMethodHandlesWhitespaceAndCrLf () | ||
| { | ||
| var dexDump = new [] { | ||
| "\tClass descriptor : 'Lexample/Peer$-CC;' \r", | ||
| " name : '$default$getValue'\r", | ||
| " type : '(Lexample/Peer;)I'\r", | ||
| }; | ||
|
|
||
| Assert.IsTrue (DexUtils.ContainsClassWithMethod ( | ||
| "Lexample/Peer$-CC;", | ||
| "$default$getValue", | ||
| "(Lexample/Peer;)I", | ||
| dexDump)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ContainsClassWithMethodResetsAtRepeatedClassDescriptor () | ||
| { | ||
| var dexDump = new [] { | ||
| " Class descriptor : 'Lexample/Peer;'", | ||
| " name : 'getValue'", | ||
| " Class descriptor : 'Lexample/Other;'", | ||
| " name : 'getValue'", | ||
| " type : '()I'", | ||
| }; | ||
|
|
||
| Assert.IsFalse (DexUtils.ContainsClassWithMethod ("Lexample/Peer;", "getValue", "()I", dexDump)); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
11 changes: 11 additions & 0 deletions
11
tests/MSBuildDeviceIntegration/Resources/ConcreteInterfaceMethodPeer.java
This file contains hidden or 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,11 @@ | ||
| package example; | ||
|
|
||
| public final class ConcreteInterfaceMethodPeer implements InterfaceMethods { | ||
| public ConcreteInterfaceMethodPeer() { | ||
| } | ||
|
|
||
| @Override | ||
| public int getDefaultValue() { | ||
| return InterfaceMethods.super.getDefaultValue() + 1; | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
tests/MSBuildDeviceIntegration/Resources/CovariantInterfaceMethods.java
This file contains hidden or 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 @@ | ||
| package example; | ||
|
|
||
| public interface CovariantInterfaceMethods { | ||
| interface Base { | ||
| Object getCovariantValue(); | ||
| } | ||
|
|
||
| interface Derived extends Base { | ||
| @Override | ||
| default String getCovariantValue() { | ||
| return "bridge"; | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
tests/MSBuildDeviceIntegration/Resources/InterfaceMethodBridgeInvoker.java
This file contains hidden or 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 @@ | ||
| package example; | ||
|
|
||
| public final class InterfaceMethodBridgeInvoker { | ||
| private InterfaceMethodBridgeInvoker() { | ||
| } | ||
|
|
||
| private static final class CovariantPeer implements CovariantInterfaceMethods.Derived { | ||
| } | ||
|
|
||
| public static String invokeCovariantBridge() { | ||
| CovariantInterfaceMethods.Base peer = new CovariantPeer(); | ||
| return (String) peer.getCovariantValue() + ":" + invokeStaticMethods(); | ||
| } | ||
|
|
||
| // Keep Java call sites so the R8 retention gap tracked by dotnet/android#11774 | ||
| // does not mask the JNI runtime behavior covered here. | ||
| public static int invokeStaticMethods() { | ||
| return InterfaceMethods.getStaticValue() | ||
| + InterfaceMethods.Nested.getNestedStaticValue(); | ||
| } | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
tests/MSBuildDeviceIntegration/Resources/InterfaceMethodPeer.java
This file contains hidden or 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,7 @@ | ||
| package example; | ||
|
|
||
| public final class InterfaceMethodPeer | ||
| implements InterfaceMethods, InterfaceMethods.Nested { | ||
| public InterfaceMethodPeer() { | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.