mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 17:14:41 +02:00
8003280: Add lambda tests
Turn on lambda expression, method reference and default method support Reviewed-by: jjg
This commit is contained in:
parent
c39f1d99b4
commit
a494f0ab86
451 changed files with 15433 additions and 488 deletions
53
langtools/test/tools/javac/lambda/LambdaExpr19.java
Normal file
53
langtools/test/tools/javac/lambda/LambdaExpr19.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8003280
|
||||
* @summary Add lambda tests
|
||||
* check that inner scopes are left after a lambda check exception has been thrown
|
||||
* @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java
|
||||
*/
|
||||
class LambdaExpr19 {
|
||||
|
||||
interface SAM {
|
||||
String m();
|
||||
}
|
||||
|
||||
void m(SAM s) { }
|
||||
|
||||
void testTry() {
|
||||
m(() -> {
|
||||
try { return 1; }
|
||||
catch (Exception e) { }
|
||||
});
|
||||
}
|
||||
|
||||
void testTryWithResources() {
|
||||
m(() -> {
|
||||
try (AutoCloseable c = null) { return 1; }
|
||||
catch (Exception e) { }
|
||||
});
|
||||
}
|
||||
|
||||
void testSwitch() {
|
||||
m(() -> {
|
||||
switch (1) {
|
||||
default: return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void testFor() {
|
||||
m(() -> {
|
||||
for (;;) {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void testForeach() {
|
||||
m(() -> {
|
||||
for (Object o : new Object[] { null , null }) {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue