diff options
author | kmb <kmb@google.com> | 2018-03-01 16:26:21 -0800 |
---|---|---|
committer | Ivan Gavrilovic <gavra@google.com> | 2018-05-04 10:39:29 +0100 |
commit | 63cde3a65d10f7f94460547042566f940d5453f0 (patch) | |
tree | e054af989d552ec1f10d2a2f6bb068be42fd610b /test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java | |
parent | 6cd318887515e0e7ed0473ef0f8a7c89ee7aaa58 (diff) | |
download | desugar-63cde3a65d10f7f94460547042566f940d5453f0.tar.gz |
Android desugar config options to exclude methods from interface emulation
RELNOTES: None.
PiperOrigin-RevId: 187551970
GitOrigin-RevId: f090082d62c3ea779d2dd33eb0fd7355b0ee9456
Change-Id: Id9ff715440eace84432ae6c5b88f7daaa43f36db
Diffstat (limited to 'test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java')
-rw-r--r-- | test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java b/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java index 90350ce..e6f34ba 100644 --- a/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java +++ b/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java @@ -37,6 +37,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of("java/time/"), ImmutableList.of(), + ImmutableList.of(), ImmutableList.of()); assertThat(support.isRenamedCoreLibrary("java/time/X")).isTrue(); assertThat(support.isRenamedCoreLibrary("java/time/y/X")).isTrue(); @@ -55,6 +56,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of("java/time/"), ImmutableList.of(), + ImmutableList.of(), ImmutableList.of()); assertThat(support.isRenamedCoreLibrary("__/java/time/X")).isTrue(); assertThat(support.isRenamedCoreLibrary("__/java/time/y/X")).isTrue(); @@ -63,6 +65,7 @@ public class CoreLibrarySupportTest { assertThat(support.isRenamedCoreLibrary("__/java/io/X$$Lambda$17")).isTrue(); assertThat(support.isRenamedCoreLibrary("com/google/X")).isFalse(); } + @Test public void testRenameCoreLibrary() throws Exception { CoreLibrarySupport support = @@ -72,6 +75,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of(), ImmutableList.of(), + ImmutableList.of(), ImmutableList.of()); assertThat(support.renameCoreLibrary("java/time/X")).isEqualTo("j$/time/X"); assertThat(support.renameCoreLibrary("com/google/X")).isEqualTo("com/google/X"); @@ -86,6 +90,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of(), ImmutableList.of(), + ImmutableList.of(), ImmutableList.of()); assertThat(support.renameCoreLibrary("__/java/time/X")).isEqualTo("j$/time/X"); assertThat(support.renameCoreLibrary("com/google/X")).isEqualTo("com/google/X"); @@ -100,7 +105,8 @@ public class CoreLibrarySupportTest { null, ImmutableList.of("java/util/Helper"), ImmutableList.of(), - ImmutableList.of("java/util/Existing#match -> java/util/Helper")); + ImmutableList.of("java/util/Existing#match -> java/util/Helper"), + ImmutableList.of()); assertThat(support.getMoveTarget("__/java/util/Existing", "match")).isEqualTo("j$/util/Helper"); assertThat(support.getMoveTarget("java/util/Existing", "match")).isEqualTo("j$/util/Helper"); assertThat(support.getMoveTarget("__/java/util/Existing", "matchesnot")).isNull(); @@ -116,6 +122,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of("java/util/concurrent/"), ImmutableList.of("java/util/Map"), + ImmutableList.of(), ImmutableList.of()); assertThat(support.isEmulatedCoreClassOrInterface("java/util/Map")).isTrue(); assertThat(support.isEmulatedCoreClassOrInterface("java/util/Map$$Lambda$17")).isFalse(); @@ -135,6 +142,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of(), ImmutableList.of("java/util/Collection"), + ImmutableList.of(), ImmutableList.of()); assertThat( support.getCoreInterfaceRewritingTarget( @@ -171,6 +179,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of(), ImmutableList.of("java/util/Collection"), + ImmutableList.of(), ImmutableList.of()); assertThat( support.getCoreInterfaceRewritingTarget( @@ -199,6 +208,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of(), ImmutableList.of("java/util/Map"), + ImmutableList.of(), ImmutableList.of()); assertThat( support.getCoreInterfaceRewritingTarget( @@ -235,6 +245,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of(), ImmutableList.of("java/util/Comparator"), + ImmutableList.of(), ImmutableList.of()); assertThat( support.getCoreInterfaceRewritingTarget( @@ -259,6 +270,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of("java/util/"), ImmutableList.of(), + ImmutableList.of(), ImmutableList.of()); // regular invocations of default methods: ignored @@ -328,6 +340,7 @@ public class CoreLibrarySupportTest { null, ImmutableList.of("java/util/concurrent/"), // should return null for these ImmutableList.of("java/util/Map"), + ImmutableList.of(), ImmutableList.of()); assertThat( support.getCoreInterfaceRewritingTarget( @@ -346,4 +359,33 @@ public class CoreLibrarySupportTest { true)) .isNull(); } + + @Test + public void testGetCoreInterfaceRewritingTarget_excludedMethodIgnored() throws Exception { + CoreLibrarySupport support = + new CoreLibrarySupport( + new CoreLibraryRewriter(""), + Thread.currentThread().getContextClassLoader(), + null, + ImmutableList.of(), + ImmutableList.of("java/util/Collection"), + ImmutableList.of(), + ImmutableList.of("java/util/Collection#removeIf")); + assertThat( + support.getCoreInterfaceRewritingTarget( + Opcodes.INVOKEINTERFACE, + "java/util/List", + "removeIf", + "(Ljava/util/function/Predicate;)Z", + true)) + .isNull(); + assertThat( + support.getCoreInterfaceRewritingTarget( + Opcodes.INVOKEVIRTUAL, + "java/util/ArrayList", + "removeIf", + "(Ljava/util/function/Predicate;)Z", + false)) + .isNull(); + } } |