Link Here
|
20 |
import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine; |
20 |
import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine; |
21 |
|
21 |
|
22 |
public class JavaDocTestCase extends CommentTestCase { |
22 |
public class JavaDocTestCase extends CommentTestCase { |
|
|
23 |
|
24 |
static { |
25 |
// TESTS_NAMES = new String[] { "testNoExtraNewlineWithPre1" } ; |
26 |
} |
23 |
|
27 |
|
24 |
protected static final String INFIX= MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX; |
28 |
protected static final String INFIX= MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX; |
25 |
|
29 |
|
Link Here
|
90 |
String postfix= DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
94 |
String postfix= DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
91 |
String input= prefix + "while (i != 0) i--;" + postfix; //$NON-NLS-1$ |
95 |
String input= prefix + "while (i != 0) i--;" + postfix; //$NON-NLS-1$ |
92 |
String expected= prefix + "while (i != 0)" + DELIMITER + INFIX + "\ti--;" + postfix; //$NON-NLS-1$//$NON-NLS-2$ |
96 |
String expected= prefix + "while (i != 0)" + DELIMITER + INFIX + "\ti--;" + postfix; //$NON-NLS-1$//$NON-NLS-2$ |
93 |
assertEquals(expected, testFormat(input)); |
97 |
String result= testFormat(input); |
|
|
98 |
assertEquals(expected, result); |
99 |
|
100 |
result= testFormat(result); |
101 |
result= testFormat(result); |
102 |
result= testFormat(result); |
103 |
result= testFormat(result); |
104 |
|
105 |
assertEquals(expected, result); |
94 |
} |
106 |
} |
95 |
|
107 |
|
96 |
/** |
108 |
/** |
Link Here
|
102 |
String postfix= DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
114 |
String postfix= DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
103 |
String input= prefix + "while (i != 0) { i--; }" + postfix; //$NON-NLS-1$ |
115 |
String input= prefix + "while (i != 0) { i--; }" + postfix; //$NON-NLS-1$ |
104 |
String expected= prefix + "while (i != 0) {" + DELIMITER + INFIX + "\ti--;" + DELIMITER + INFIX + "}" + postfix; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
116 |
String expected= prefix + "while (i != 0) {" + DELIMITER + INFIX + "\ti--;" + DELIMITER + INFIX + "}" + postfix; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
105 |
assertEquals(expected, testFormat(input)); |
117 |
String result= testFormat(input); |
|
|
118 |
assertEquals(expected, result); |
119 |
|
120 |
result= testFormat(result); |
121 |
result= testFormat(result); |
122 |
result= testFormat(result); |
123 |
result= testFormat(result); |
124 |
|
125 |
assertEquals(expected, result); |
106 |
} |
126 |
} |
107 |
|
127 |
|
108 |
public void testMultiLineCommentCodeSnippet3() { |
128 |
public void testMultiLineCommentCodeSnippet3() { |
109 |
String input= PREFIX + DELIMITER + "<pre>" + DELIMITER + "while (i != 0)" + DELIMITER + "i--;" + DELIMITER + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
129 |
String input= PREFIX + DELIMITER + "<pre>" + DELIMITER + "while (i != 0)" + DELIMITER + "i--;" + DELIMITER + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
110 |
String expected= PREFIX + DELIMITER + INFIX + "<pre>" + DELIMITER + INFIX + "while (i != 0)" + DELIMITER + INFIX + "\ti--;" + DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
130 |
String expected= PREFIX + DELIMITER + INFIX + "<pre>" + DELIMITER + INFIX + "while (i != 0)" + DELIMITER + INFIX + "\ti--;" + DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
111 |
assertEquals(expected, testFormat(input)); |
131 |
String result= testFormat(input); |
|
|
132 |
assertEquals(expected, result); |
133 |
|
134 |
result= testFormat(result); |
135 |
result= testFormat(result); |
136 |
result= testFormat(result); |
137 |
result= testFormat(result); |
138 |
|
139 |
assertEquals(expected, result); |
112 |
} |
140 |
} |
113 |
|
141 |
|
114 |
public void testMultiLineCommentCodeSnippetHtmlEntities1() { |
142 |
public void testMultiLineCommentCodeSnippetHtmlEntities1() { |
Link Here
|
116 |
String postfix= DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
144 |
String postfix= DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
117 |
String input= prefix + "System.out.println(\"test\");" + postfix; //$NON-NLS-1$ |
145 |
String input= prefix + "System.out.println(\"test\");" + postfix; //$NON-NLS-1$ |
118 |
String expected= prefix + "System.out.println("test");" + postfix; //$NON-NLS-1$ |
146 |
String expected= prefix + "System.out.println("test");" + postfix; //$NON-NLS-1$ |
119 |
assertEquals(expected, testFormat(input)); |
147 |
String result= testFormat(input); |
|
|
148 |
assertEquals(expected, result); |
149 |
|
150 |
result= testFormat(result); |
151 |
result= testFormat(result); |
152 |
result= testFormat(result); |
153 |
result= testFormat(result); |
154 |
|
155 |
assertEquals(expected, result); |
120 |
} |
156 |
} |
121 |
|
157 |
|
122 |
public void testMultiLineCommentIndentTabs1() { |
158 |
public void testMultiLineCommentIndentTabs1() { |
Link Here
|
453 |
result= testFormat(result); |
489 |
result= testFormat(result); |
454 |
result= testFormat(result); |
490 |
result= testFormat(result); |
455 |
|
491 |
|
456 |
// XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=99738 |
492 |
expected= PREFIX + DELIMITER + INFIX + "<pre>" + DELIMITER + INFIX + "wrap here" + DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$; //$NON-NLS-2$; //$NON-NLS-3$; |
457 |
String WORKAROUND_BUG_99738= " "; //$NON-NLS-1$ |
493 |
assertEquals(expected, result); |
458 |
expected= PREFIX + DELIMITER + INFIX + "<pre>" + DELIMITER + INFIX + WORKAROUND_BUG_99738 + "wrap here" + DELIMITER + INFIX + "</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$; //$NON-NLS-2$; //$NON-NLS-3$; |
494 |
} |
|
|
495 |
|
496 |
/** |
497 |
* [formatting] Javadoc formatting: extra newline with [pre] |
498 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52921 |
499 |
* <p> |
500 |
* This test only formats once. |
501 |
* </p> |
502 |
*/ |
503 |
public void testNoExtraNewlineWithPre2() { |
504 |
setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, DefaultCodeFormatterConstants.FALSE); |
505 |
String input= PREFIX + DELIMITER + INFIX + "<pre>wrap here</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
506 |
String expected= PREFIX + DELIMITER + INFIX + "<pre>wrap here</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
507 |
String result= testFormat(input); |
508 |
assertEquals(expected, result); |
509 |
|
510 |
// now re-format several times |
511 |
result= testFormat(result); |
512 |
result= testFormat(result); |
513 |
result= testFormat(result); |
514 |
result= testFormat(result); |
515 |
|
516 |
expected= PREFIX + DELIMITER + INFIX + "<pre>wrap here</pre>" + DELIMITER + POSTFIX; //$NON-NLS-1$ |
459 |
assertEquals(expected, result); |
517 |
assertEquals(expected, result); |
460 |
} |
518 |
} |
461 |
|
519 |
|