changeset 58359:64a9225f91bf records

fixing merge issues
author vromero
date Sun, 20 Oct 2019 11:14:03 -0400
parents 057cf61f4072
children eea7ef983baa
files test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java test/langtools/tools/javac/tree/JavacTreeScannerTest.java test/langtools/tools/javac/tree/SourceTreeScannerTest.java
diffstat 4 files changed, 30 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java	Fri Oct 18 20:28:34 2019 +0100
+++ b/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java	Sun Oct 20 11:14:03 2019 -0400
@@ -27,12 +27,13 @@
 import org.testng.ITestResult;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
+import tools.javac.combo.CompilationTestCase;
 import tools.javac.combo.JavacTemplateTestBase;
 
 import static java.util.stream.Collectors.toList;
 
 @Test
-public class ExpSwitchNestingTest extends JavacTemplateTestBase {
+public class ExpSwitchNestingTest extends CompilationTestCase {
     private static final String RUNNABLE = "Runnable r = () -> { # };";
     private static final String INT_FN = "java.util.function.IntSupplier r = () -> { # };";
     private static final String LABEL = "label: #";
@@ -68,61 +69,15 @@
     private static final List<String> CONTAINER_STATEMENTS
             = List.of(FOR, WHILE, DO, SSWITCH, IF, BLOCK);
 
-    @AfterMethod
-    public void dumpTemplateIfError(ITestResult result) {
-        // Make sure offending template ends up in log file on failure
-        if (!result.isSuccess()) {
-            System.err.printf("Diagnostics: %s%nTemplate: %s%n", diags.errorKeys(), sourceFiles.stream().map(p -> p.snd).collect(toList()));
-        }
-    }
-
+    // @@@ When expression switch becomes a permanent feature, we don't need these any more
     private static String[] PREVIEW_OPTIONS = {"--enable-preview", "-source",
                                                Integer.toString(Runtime.version().feature())};
-
-    private void program(String... constructs) {
-        String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
-        for (String c : constructs)
-            s = s.replace("#", c);
-        addSourceFile("C.java", new StringTemplate(s).toString());
-    }
-
-    private void assertOK(String... constructs) {
-        reset();
-        addCompileOptions(PREVIEW_OPTIONS);
-        program(constructs);
-        try {
-            compile();
-        }
-        catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        assertCompileSucceeded();
-    }
+    private static final String SHELL = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
 
-    private void assertOKWithWarning(String warning, String... constructs) {
-        reset();
-        addCompileOptions(PREVIEW_OPTIONS);
-        program(constructs);
-        try {
-            compile();
-        }
-        catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        assertCompileSucceededWithWarning(warning);
-    }
-
-    private void assertFail(String expectedDiag, String... constructs) {
-        reset();
-        addCompileOptions(PREVIEW_OPTIONS);
-        program(constructs);
-        try {
-            compile();
-        }
-        catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        assertCompileFailed(expectedDiag);
+    {
+        setDefaultFilename("C.java");
+        setCompileOptions(PREVIEW_OPTIONS);
+        setProgramShell(SHELL);
     }
 
     public void testReallySimpleCases() {
--- a/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java	Fri Oct 18 20:28:34 2019 +0100
+++ b/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java	Sun Oct 20 11:14:03 2019 -0400
@@ -111,11 +111,11 @@
         ClassModel cm = new Parser(spec).parseClassModel();
         for (int i = 0; i <= cm.maxIndex() ; i++) {
             if (debug) System.out.println(indexClass(i));
-            addSourceFile(String.format("C%d.java", i), new StringTemplate(indexClass(i)).toString());
+            addSourceFile(String.format("C%d.java", i), indexClass(i));
         }
         for (Map.Entry<String, ClassModel> e : classes(cm).entrySet()) {
             if (debug) System.out.println(e.getValue().toSource());
-            addSourceFile(e.getKey() + ".java", new StringTemplate(e.getValue().toSource()).toString());
+            addSourceFile(e.getKey() + ".java", e.getValue().toSource());
         }
         compileDirs.add(compile(true));
         resetSourceFiles();
@@ -133,11 +133,11 @@
         List<String> nameList = Arrays.asList(names);
         ClassModel cm = new Parser(spec).parseClassModel();
         for (int i = 0; i <= cm.maxIndex() ; i++) {
-            addSourceFile(String.format("C%d.java", i), new StringTemplate(indexClass(i)).toString());
+            addSourceFile(String.format("C%d.java", i), indexClass(i));
         }
         for (Map.Entry<String, ClassModel> e : classes(cm).entrySet())
             if (nameList.contains(e.getKey()))
-                addSourceFile(e.getKey() + ".java", new StringTemplate(e.getValue().toSource()).toString());
+                addSourceFile(e.getKey() + ".java", e.getValue().toSource());
         compileDirs.add(compile(Arrays.asList(classPaths()), true));
         resetSourceFiles();
         assertCompileSucceeded();
--- a/test/langtools/tools/javac/tree/JavacTreeScannerTest.java	Fri Oct 18 20:28:34 2019 +0100
+++ b/test/langtools/tools/javac/tree/JavacTreeScannerTest.java	Sun Oct 20 11:14:03 2019 -0400
@@ -102,8 +102,21 @@
 
             error(sourcefile, "differences found");
 
-            if (found.size() != expect.size())
+            if (found.size() != expect.size()) {
                 error("Size mismatch; found: " + found.size() + ", expected: " + expect.size());
+                Set<JCTree> notFound = new HashSet<>(expect);
+                notFound.removeAll(found);
+                if (!notFound.isEmpty()) {
+                    System.err.println("found by reflective access to the AST, but not found in the scanner API:");
+                    notFound.forEach(t -> System.err.println(trim(t, 64)));
+                }
+                Set<JCTree> notExpected = new HashSet<>(found);
+                notExpected.removeAll(expect);
+                if (!notExpected.isEmpty()) {
+                    System.err.println("found in the scanner API, but not found by reflective access to the AST:");
+                    notExpected.forEach(t -> System.err.println(trim(t, 64)));
+                }
+            }
 
             Set<JCTree> missing = new HashSet<JCTree>();
             missing.addAll(expect);
@@ -150,6 +163,8 @@
                 List<?> list = (List<?>) o;
                 for (Object item: list)
                     reflectiveScan(item);
+            } else if (o instanceof Pair) {
+                return;
             } else
                 error("unexpected item: " + o);
         }
--- a/test/langtools/tools/javac/tree/SourceTreeScannerTest.java	Fri Oct 18 20:28:34 2019 +0100
+++ b/test/langtools/tools/javac/tree/SourceTreeScannerTest.java	Sun Oct 20 11:14:03 2019 -0400
@@ -171,6 +171,8 @@
                 List<?> list = (List<?>) o;
                 for (Object item: list)
                     reflectiveScan(item);
+            } else if (o instanceof Pair) {
+                return;
             } else
                 error("unexpected item: " + o);
         }