aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar kmb <kmb@google.com>2018-03-02 14:41:23 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-02 14:43:19 -0800
commitbabbfdc6cb98a23fe0dadf02d7dc407504e9cac5 (patch)
treecdfb21000b6d902ccf760abe472f357e29e4a35a /src/test
parentbcd4536665f4bec34a0bb3efff4154fe52b1a4d7 (diff)
emulate dynamic dispatch of emulated default interface methods
RELNOTES: None. PiperOrigin-RevId: 187671513
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java36
-rw-r--r--src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java1
2 files changed, 23 insertions, 14 deletions
diff --git a/src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java b/src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java
index e6f34ba9d4..ec4e16d8dd 100644
--- a/src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java
+++ b/src/test/java/com/google/devtools/build/android/desugar/CoreLibrarySupportTest.java
@@ -34,7 +34,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
null,
- null,
ImmutableList.of("java/time/"),
ImmutableList.of(),
ImmutableList.of(),
@@ -53,7 +52,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter("__/"),
null,
- null,
ImmutableList.of("java/time/"),
ImmutableList.of(),
ImmutableList.of(),
@@ -72,7 +70,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
null,
- null,
ImmutableList.of(),
ImmutableList.of(),
ImmutableList.of(),
@@ -87,7 +84,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter("__/"),
null,
- null,
ImmutableList.of(),
ImmutableList.of(),
ImmutableList.of(),
@@ -102,7 +98,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter("__/"),
null,
- null,
ImmutableList.of("java/util/Helper"),
ImmutableList.of(),
ImmutableList.of("java/util/Existing#match -> java/util/Helper"),
@@ -119,7 +114,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
Thread.currentThread().getContextClassLoader(),
- null,
ImmutableList.of("java/util/concurrent/"),
ImmutableList.of("java/util/Map"),
ImmutableList.of(),
@@ -139,7 +133,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
Thread.currentThread().getContextClassLoader(),
- null,
ImmutableList.of(),
ImmutableList.of("java/util/Collection"),
ImmutableList.of(),
@@ -176,7 +169,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
Thread.currentThread().getContextClassLoader(),
- null,
ImmutableList.of(),
ImmutableList.of("java/util/Collection"),
ImmutableList.of(),
@@ -205,7 +197,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
Thread.currentThread().getContextClassLoader(),
- null,
ImmutableList.of(),
ImmutableList.of("java/util/Map"),
ImmutableList.of(),
@@ -242,7 +233,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
Thread.currentThread().getContextClassLoader(),
- null,
ImmutableList.of(),
ImmutableList.of("java/util/Comparator"),
ImmutableList.of(),
@@ -267,7 +257,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
Thread.currentThread().getContextClassLoader(),
- null,
ImmutableList.of("java/util/"),
ImmutableList.of(),
ImmutableList.of(),
@@ -337,7 +326,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
Thread.currentThread().getContextClassLoader(),
- null,
ImmutableList.of("java/util/concurrent/"), // should return null for these
ImmutableList.of("java/util/Map"),
ImmutableList.of(),
@@ -366,7 +354,6 @@ public class CoreLibrarySupportTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
Thread.currentThread().getContextClassLoader(),
- null,
ImmutableList.of(),
ImmutableList.of("java/util/Collection"),
ImmutableList.of(),
@@ -388,4 +375,27 @@ public class CoreLibrarySupportTest {
false))
.isNull();
}
+
+ @Test
+ public void testEmulatedMethod_nullExceptions() throws Exception {
+ CoreLibrarySupport.EmulatedMethod m =
+ CoreLibrarySupport.EmulatedMethod.create(1, Number.class, "a", "()V", null);
+ assertThat(m.access()).isEqualTo(1);
+ assertThat(m.owner()).isEqualTo(Number.class);
+ assertThat(m.name()).isEqualTo("a");
+ assertThat(m.descriptor()).isEqualTo("()V");
+ assertThat(m.exceptions()).isEmpty();
+ }
+
+ @Test
+ public void testEmulatedMethod_givenExceptions() throws Exception {
+ CoreLibrarySupport.EmulatedMethod m =
+ CoreLibrarySupport.EmulatedMethod.create(
+ 1, Number.class, "a", "()V", new String[] {"b", "c"});
+ assertThat(m.access()).isEqualTo(1);
+ assertThat(m.owner()).isEqualTo(Number.class);
+ assertThat(m.name()).isEqualTo("a");
+ assertThat(m.descriptor()).isEqualTo("()V");
+ assertThat(m.exceptions()).containsExactly("b", "c").inOrder();
+ }
}
diff --git a/src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java b/src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java
index 95d7b41105..2bdd58bd8d 100644
--- a/src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java
+++ b/src/test/java/com/google/devtools/build/android/desugar/CorePackageRenamerTest.java
@@ -35,7 +35,6 @@ public class CorePackageRenamerTest {
new CoreLibrarySupport(
new CoreLibraryRewriter(""),
null,
- null,
ImmutableList.of("java/time/"),
ImmutableList.of(),
ImmutableList.of("java/util/A#m->java/time/B"),