Adding tests for lambdas and method references.
1.1 --- a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java Sun Feb 12 10:11:52 2017 +0100
1.2 +++ b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java Sun Feb 12 11:00:22 2017 +0100
1.3 @@ -643,6 +643,96 @@
1.4 }
1.5 }
1.6
1.7 + public void testLambda() throws Exception {
1.8 + doRunCompiler(null,
1.9 + equivalentValidator("${workdir}/src/test/Test.java:4: warning: [test] test\n" +
1.10 + " Runnable r = () -> {};\n" +
1.11 + " ^\n" +
1.12 + "${workdir}/src/test/Test.java:5: warning: [test] test\n" +
1.13 + " I1 i1 = (str1, str2) -> {};\n" +
1.14 + " ^\n" +
1.15 + "${workdir}/src/test/Test.java:6: warning: [test] test\n" +
1.16 + " I2 i2 = (str1, str2) -> str1;\n" +
1.17 + " ^\n" +
1.18 + "${workdir}/src/test/Test.java:7: warning: [test] test\n" +
1.19 + " I3 i3 = str -> { return str; };\n" +
1.20 + " ^\n"),
1.21 + equivalentValidator(""),
1.22 + "src/META-INF/upgrade/test.hint",
1.23 + "($args$) -> $expr" +
1.24 + ";;",
1.25 + "src/test/Test.java",
1.26 + "package test;\n" +
1.27 + "public class Test {\n" +
1.28 + " private void test() {\n" +
1.29 + " Runnable r = () -> {};\n" +
1.30 + " I1 i1 = (str1, str2) -> {};\n" +
1.31 + " I2 i2 = (str1, str2) -> str1;\n" +
1.32 + " I3 i3 = str -> { return str; };\n" +
1.33 + " }\n" +
1.34 + " interface I1 {\n" +
1.35 + " public void test(String str1, String str2);\n" +
1.36 + " }\n" +
1.37 + " interface I2 {\n" +
1.38 + " public String test(String str1, String str2);\n" +
1.39 + " }\n" +
1.40 + " interface I3 {\n" +
1.41 + " public String test(String str);\n" +
1.42 + " }\n" +
1.43 + "}\n",
1.44 + null,
1.45 + "-source", "8",
1.46 + "--sourcepath", "${workdir}/src");
1.47 + }
1.48 +
1.49 + public void testMethodRef() throws Exception {
1.50 + doRunCompiler(null,
1.51 + equivalentValidator("${workdir}/src/test/Test.java:8: warning: [test] test\n" +
1.52 + " I3 i3b = String::new;\n" +
1.53 + " ^\n" +
1.54 + "${workdir}/src/test/Test.java:4: warning: [test] test\n" +
1.55 + " Runnable r = Test::m1;\n" +
1.56 + " ^\n" +
1.57 + "${workdir}/src/test/Test.java:5: warning: [test] test\n" +
1.58 + " I1 i1 = this::m2;\n" +
1.59 + " ^\n" +
1.60 + "${workdir}/src/test/Test.java:6: warning: [test] test\n" +
1.61 + " I2 i2 = String::replace;\n" +
1.62 + " ^\n" +
1.63 + "${workdir}/src/test/Test.java:7: warning: [test] test\n" +
1.64 + " I3 i3a = String::toLowerCase;\n" +
1.65 + " ^\n"),
1.66 + equivalentValidator(""),
1.67 + "src/META-INF/upgrade/test.hint",
1.68 + "$clazz \\u003a\\u003a $member;;" +
1.69 + "$clazz \\u003a\\u003a new;;",
1.70 + "src/test/Test.java",
1.71 + "package test;\n" +
1.72 + "public class Test {\n" +
1.73 + " private void test() {\n" +
1.74 + " Runnable r = Test::m1;\n" +
1.75 + " I1 i1 = this::m2;\n" +
1.76 + " I2 i2 = String::replace;\n" +
1.77 + " I3 i3a = String::toLowerCase;\n" +
1.78 + " I3 i3b = String::new;\n" +
1.79 + " }\n" +
1.80 + " interface I1 {\n" +
1.81 + " public void test(String str1, String str2);\n" +
1.82 + " }\n" +
1.83 + " interface I2 {\n" +
1.84 + " public String test(String str1, String str2);\n" +
1.85 + " }\n" +
1.86 + " interface I3 {\n" +
1.87 + " public String test(String str);\n" +
1.88 + " }\n" +
1.89 + " private static void m1() { }\n" +
1.90 + " private void m2(String str1, String str2) { }\n" +
1.91 + "}\n",
1.92 + null,
1.93 + "-source", "8",
1.94 + "--sourcepath", "${workdir}/src");
1.95 + }
1.96 +
1.97 public void testGroupsParamEscape() throws Exception {
1.98 assertEquals(Arrays.asList("a b", "a\\b"),
1.99 Arrays.asList(Main.splitGroupArg("a\\ b a\\\\b")));