Mercurial > hg > Members > kono > jpf-core
diff src/tests/java8/LambdaTest.java @ 28:7be90179bb3b
Provided support for double colon operator used for lamabda expressions. Fixed a bug related to generating names for funcation object classes (by supporting double colon operator, a new stragety needed to generate unique names for function objects. To achive that the bootstrap ids are incorporated into names). Finally modified the method that retrieves the SAM from functional interfaces.
author | nastaran <nastaran.shafiei@gmail.com> |
---|---|
date | Thu, 25 Jun 2015 13:20:50 -0700 |
parents | 61d41facf527 |
children | 820b89dd6c97 |
line wrap: on
line diff
--- a/src/tests/java8/LambdaTest.java Mon May 11 12:17:18 2015 -0700 +++ b/src/tests/java8/LambdaTest.java Thu Jun 25 13:20:50 2015 -0700 @@ -167,4 +167,92 @@ } } } + + public static class C2 { + public static void throwException() { + throw new EnforcedException(); + } + } + + @Test + public void testDoubleCloneOperator() { + if (verifyUnhandledException(EnforcedException.class.getName())) { + FI1 fi = C2::throwException; + fi.sam(); + } + } + + static class A { + static { + if(true) { + throw new EnforcedException(); + } + } + } + + @Test + public void testInitDoubleCloneOperator() { + if (verifyUnhandledException(EnforcedException.class.getName())) { + new Thread(A::new).start(); + } + } + + static class D { + static final B b = new B(); + } + + static class B { + static final D a = new D(); + } + + @Test + public void testClinitDeadlock() { + if(verifyDeadlock()) { + new Thread(D::new).start(); + new B(); + } + } + + @Test + public void testLambdaTypeName() { + if(verifyNoPropertyViolation()) { + Runnable r1 = (A::new); + Runnable r2 = (B::new); + + assertFalse(r1.getClass().getName().equals(r2.getClass().getName())); + } + } + + public interface FI { + default boolean returnTrue() { + return true; + } + @Override + public String toString(); + public String toString(int i); + } + + @Test + public void testLambdaWithOverridenDefaultMethods() { + if(verifyNoPropertyViolation()) { + FI fi = (int i) -> {return "output:"+ i;}; + assertEquals(fi.toString(10),"output:10"); + } + } + + public interface FI4 { + } + + public interface FI5 extends FI { + @Override + public boolean equals(Object obj); + } + + @Test + public void testLambdaWithMultipleSuperInterfaces() { + if(verifyNoPropertyViolation()) { + FI5 fi = (int i) -> {return "output:"+ i;}; + assertEquals(fi.toString(10),"output:10"); + } + } }