Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2020-08-31 14:56:24 -0400
committerManoj Palat2020-09-03 10:26:03 -0400
commitff6752786b17a8f5e248edd1260cc4e3f134d679 (patch)
tree766ff25404f60574a1a2b4de3cc6f2b339dd4ca0
parent1fc8eb207b22bcf0985d573bf20a60a2d712c535 (diff)
downloadeclipse.jdt.core-Y20200903-2210.tar.gz
eclipse.jdt.core-Y20200903-2210.tar.xz
eclipse.jdt.core-Y20200903-2210.zip
Bug 566518 - [Tests] Tests for 6.1 and 6.3 for Local Static InterfacesY20200903-2210
and Enum Classes Change-Id: I64795e96f68b8f13eec6543b9546e21e4458c4a7
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java180
1 files changed, 180 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java
index 3987d68b94..269614665b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java
@@ -138,6 +138,8 @@ public class LocalStaticsTest_15 extends AbstractRegressionTest {
},
"0");
}
+
+
public void testBug566284_002() {
runConformTest(
new String[] {
@@ -220,4 +222,182 @@ public class LocalStaticsTest_15 extends AbstractRegressionTest {
"----------\n"
);
}
+
+ public void testBug566518_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " int f = switch (5) {\n"+
+ " case 5: {\n"+
+ " public interface I{\n"+
+ " \n"+
+ " }\n"+
+ " class C implements I{\n"+
+ " public int j = 5;\n"+
+ " }\n"+
+ " \n"+
+ " yield new C().j;\n"+
+ " }\n"+
+ " default:\n"+
+ " throw new IllegalArgumentException(\"Unexpected value: \" );\n"+
+ " };\n"+
+ " System.out.println(f);\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}"
+ },
+ "5");
+ }
+
+ public void testBug566518_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " class F {\n"+
+ " int create(int lo) {\n"+
+ " I myI = s -> lo;\n"+
+ " return myI.bar(0);\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(new F().create(0));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "0");
+ }
+
+ public void testBug566518_003() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public interface X {\n"+
+ " static void foo() {\n"+
+ " class F {\n"+
+ " int create(int lo) {\n"+
+ " I myI = s -> lo;\n"+
+ " return myI.bar(0);\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(new F().create(0));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "0");
+ }
+
+ public void testBug566518_004() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public interface X {\n"+
+ " static void foo() {\n"+
+ " interface F {\n"+
+ " static int create(int lo) {\n"+
+ " I myI = s -> lo;\n"+
+ " return myI.bar(0);\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(F.create(0));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "0");
+ }
+
+ public void testBug566518_005() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " int f = switch (5) {\n"+
+ " case 5: {\n"+
+ " public interface I{\n"+
+ " \n"+
+ " }\n"+
+ " class C implements I{\n"+
+ " public int j = 5;\n"+
+ " }\n"+
+ " \n"+
+ " yield new C().j;\n"+
+ " }\n"+
+ " default:\n"+
+ " throw new IllegalArgumentException(\"Unexpected value: \" );\n"+
+ " };\n"+
+ " System.out.println(f);\n"+
+ " class C1 implements I{\n"+
+ " public int j = 5;\n"+
+ " }\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n"+
+ "1. ERROR in X.java (at line 18)\n"+
+ " class C1 implements I{\n"+
+ " ^\n" +
+ "I cannot be resolved to a type\n"+
+ "----------\n"
+ );
+ }
+
+ public void testBug566518_006() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public enum X {\n"+
+ " A, B, C;\n"+
+ " public void foo() {\n"+
+ " int f = switch (5) {\n"+
+ " case 5: {\n"+
+ " public interface I{\n"+
+ " \n"+
+ " }\n"+
+ " class C implements I{\n"+
+ " public int j = 5;\n"+
+ " }\n"+
+ " \n"+
+ " yield new C().j;\n"+
+ " }\n"+
+ " default:\n"+
+ " throw new IllegalArgumentException(\"Unexpected value: \" );\n"+
+ " };\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X x = X.A;\n"+
+ " System.out.println();\n"+
+ " }\n"+
+ "}"
+ },
+ "");
+ }
} \ No newline at end of file

Back to the top