提交 711d6ef6 编写于 作者: J jjg

8023522: tools/javac/tree/TypeAnnotationsPretty.java test cases with @TA...

8023522: tools/javac/tree/TypeAnnotationsPretty.java test cases with @TA newline fail on windows only
Reviewed-by: darcy
上级 64cc9173
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 1234567 * @bug 8023522
* @summary test Pretty print of type annotations * @summary test Pretty print of type annotations
* @author wmdietl * @author wmdietl
*/ */
...@@ -87,7 +87,7 @@ public class TypeAnnotationsPretty { ...@@ -87,7 +87,7 @@ public class TypeAnnotationsPretty {
} }
if (!tap.mismatches.isEmpty()) { if (!tap.mismatches.isEmpty()) {
for (String mm : tap.mismatches) for (String mm : tap.mismatches)
System.err.println(mm + "\n"); System.err.println(mm + NL);
throw new RuntimeException("Tests failed!"); throw new RuntimeException("Tests failed!");
} }
} }
...@@ -107,6 +107,7 @@ public class TypeAnnotationsPretty { ...@@ -107,6 +107,7 @@ public class TypeAnnotationsPretty {
"@Target(ElementType.TYPE_USE)" + "@Target(ElementType.TYPE_USE)" +
"@interface TD {}"; "@interface TD {}";
private static final String NL = System.getProperty("line.separator");
private void runField(String code) throws IOException { private void runField(String code) throws IOException {
String src = prefix + String src = prefix +
...@@ -116,17 +117,10 @@ public class TypeAnnotationsPretty { ...@@ -116,17 +117,10 @@ public class TypeAnnotationsPretty {
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
null, Arrays.asList(new MyFileObject(src))); null, Arrays.asList(new MyFileObject(src)));
for (CompilationUnitTree cut : ct.parse()) { for (CompilationUnitTree cut : ct.parse()) {
JCTree.JCVariableDecl var = JCTree.JCVariableDecl var =
(JCTree.JCVariableDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0); (JCTree.JCVariableDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
checkMatch(code, var);
if (!code.equals(var.toString())) {
mismatches.add("Expected: " + code +
"\nObtained: " + var.toString());
} else {
matches.add("Passed: " + code);
}
} }
} }
...@@ -140,15 +134,20 @@ public class TypeAnnotationsPretty { ...@@ -140,15 +134,20 @@ public class TypeAnnotationsPretty {
for (CompilationUnitTree cut : ct.parse()) { for (CompilationUnitTree cut : ct.parse()) {
JCTree.JCMethodDecl var = JCTree.JCMethodDecl meth =
(JCTree.JCMethodDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0); (JCTree.JCMethodDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
checkMatch(code, meth);
}
}
if (!code.equals(var.toString())) { void checkMatch(String code, JCTree tree) {
mismatches.add("Expected: " + code + String expect = code.replace("\n", NL);
"\nObtained: " + var.toString()); String found = tree.toString();
} else { if (!expect.equals(found)) {
matches.add("Passed: " + code); mismatches.add("Expected: " + expect + NL +
} "Obtained: " + found);
} else {
matches.add("Passed: " + expect);
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册