Thu, 29 Aug 2013 11:57:52 -0700
8023522: tools/javac/tree/TypeAnnotationsPretty.java test cases with @TA newline fail on windows only
Reviewed-by: darcy
test/tools/javac/tree/TypeAnnotationsPretty.java | file | annotate | diff | comparison | revisions |
1.1 --- a/test/tools/javac/tree/TypeAnnotationsPretty.java Thu Aug 29 11:41:20 2013 -0700 1.2 +++ b/test/tools/javac/tree/TypeAnnotationsPretty.java Thu Aug 29 11:57:52 2013 -0700 1.3 @@ -23,7 +23,7 @@ 1.4 1.5 /* 1.6 * @test 1.7 - * @bug 1234567 1.8 + * @bug 8023522 1.9 * @summary test Pretty print of type annotations 1.10 * @author wmdietl 1.11 */ 1.12 @@ -87,7 +87,7 @@ 1.13 } 1.14 if (!tap.mismatches.isEmpty()) { 1.15 for (String mm : tap.mismatches) 1.16 - System.err.println(mm + "\n"); 1.17 + System.err.println(mm + NL); 1.18 throw new RuntimeException("Tests failed!"); 1.19 } 1.20 } 1.21 @@ -107,6 +107,7 @@ 1.22 "@Target(ElementType.TYPE_USE)" + 1.23 "@interface TD {}"; 1.24 1.25 + private static final String NL = System.getProperty("line.separator"); 1.26 1.27 private void runField(String code) throws IOException { 1.28 String src = prefix + 1.29 @@ -116,17 +117,10 @@ 1.30 JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, 1.31 null, Arrays.asList(new MyFileObject(src))); 1.32 1.33 - 1.34 for (CompilationUnitTree cut : ct.parse()) { 1.35 JCTree.JCVariableDecl var = 1.36 (JCTree.JCVariableDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0); 1.37 - 1.38 - if (!code.equals(var.toString())) { 1.39 - mismatches.add("Expected: " + code + 1.40 - "\nObtained: " + var.toString()); 1.41 - } else { 1.42 - matches.add("Passed: " + code); 1.43 - } 1.44 + checkMatch(code, var); 1.45 } 1.46 } 1.47 1.48 @@ -140,15 +134,20 @@ 1.49 1.50 1.51 for (CompilationUnitTree cut : ct.parse()) { 1.52 - JCTree.JCMethodDecl var = 1.53 + JCTree.JCMethodDecl meth = 1.54 (JCTree.JCMethodDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0); 1.55 + checkMatch(code, meth); 1.56 + } 1.57 + } 1.58 1.59 - if (!code.equals(var.toString())) { 1.60 - mismatches.add("Expected: " + code + 1.61 - "\nObtained: " + var.toString()); 1.62 - } else { 1.63 - matches.add("Passed: " + code); 1.64 - } 1.65 + void checkMatch(String code, JCTree tree) { 1.66 + String expect = code.replace("\n", NL); 1.67 + String found = tree.toString(); 1.68 + if (!expect.equals(found)) { 1.69 + mismatches.add("Expected: " + expect + NL + 1.70 + "Obtained: " + found); 1.71 + } else { 1.72 + matches.add("Passed: " + expect); 1.73 } 1.74 } 1.75 }