More java8 debug tests
Adds new cases for lambda (using method reference) and default/static
method in interface.
Bug: 38218137
Bug: 37731140
Bug: 62290295
Change-Id: I5e387c6194cef313fbbd4b66e1d78db6ff5cbdf8
diff --git a/src/test/debugTestResourcesJava8/DebugLambda.java b/src/test/debugTestResourcesJava8/DebugLambda.java
index c3b8695..007cd0c 100644
--- a/src/test/debugTestResourcesJava8/DebugLambda.java
+++ b/src/test/debugTestResourcesJava8/DebugLambda.java
@@ -16,8 +16,52 @@
printInt(() -> i + j);
}
- public static void main(String[] args) {
- DebugLambda.testLambda(5, 10);
+ private static void printInt2(I i) {
+ System.out.println(i.getInt());
}
+ public static void testLambdaWithMethodReference() {
+ printInt2(DebugLambda::returnOne);
+ }
+
+ private static int returnOne() {
+ return 1;
+ }
+
+ private static void printInt3(BinaryOpInterface i, int a, int b) {
+ System.out.println(i.binaryOp(a, b));
+ }
+
+ public static void testLambdaWithArguments(int i, int j) {
+ printInt3((a, b) -> {
+ return a + b;
+ }, i, j);
+ }
+
+ interface ObjectProvider {
+ Object foo(String a, String b, String c);
+ }
+
+ private static void testLambdaWithMethodReferenceAndConversion(ObjectProvider objectProvider) {
+ System.out.println(objectProvider.foo("A", "B", "C"));
+ }
+
+ public static void main(String[] args) {
+ DebugLambda.testLambda(5, 10);
+ DebugLambda.testLambdaWithArguments(5, 10);
+ DebugLambda.testLambdaWithMethodReference();
+ DebugLambda.testLambdaWithMethodReferenceAndConversion(DebugLambda::concatObjects);
+ }
+
+ private static Object concatObjects(Object... objects) {
+ StringBuilder sb = new StringBuilder();
+ for (Object o : objects) {
+ sb.append(o.toString());
+ }
+ return sb.toString();
+ }
+
+ interface BinaryOpInterface {
+ int binaryOp(int a, int b);
+ }
}