### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java,v retrieving revision 1.5 diff -u -r1.5 JavaDocTestCase.java --- src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 29 Mar 2006 04:03:08 -0000 1.5 +++ src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 5 Jan 2007 15:58:21 -0000 @@ -20,6 +20,10 @@ import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine; public class JavaDocTestCase extends CommentTestCase { + + static { +// TESTS_NAMES = new String[] { "testNoExtraNewlineWithPre1" } ; + } protected static final String INFIX= MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX; @@ -90,7 +94,15 @@ String postfix= DELIMITER + INFIX + "" + DELIMITER + POSTFIX; //$NON-NLS-1$ String input= prefix + "while (i != 0) i--;" + postfix; //$NON-NLS-1$ String expected= prefix + "while (i != 0)" + DELIMITER + INFIX + "\ti--;" + postfix; //$NON-NLS-1$//$NON-NLS-2$ - assertEquals(expected, testFormat(input)); + String result= testFormat(input); + assertEquals(expected, result); + + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + + assertEquals(expected, result); } /** @@ -102,13 +114,29 @@ String postfix= DELIMITER + INFIX + "" + DELIMITER + POSTFIX; //$NON-NLS-1$ String input= prefix + "while (i != 0) { i--; }" + postfix; //$NON-NLS-1$ String expected= prefix + "while (i != 0) {" + DELIMITER + INFIX + "\ti--;" + DELIMITER + INFIX + "}" + postfix; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - assertEquals(expected, testFormat(input)); + String result= testFormat(input); + assertEquals(expected, result); + + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + + assertEquals(expected, result); } public void testMultiLineCommentCodeSnippet3() { String input= PREFIX + DELIMITER + "
" + DELIMITER + "while (i != 0)" + DELIMITER + "i--;" + DELIMITER + "
" + DELIMITER + POSTFIX; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ String expected= PREFIX + DELIMITER + INFIX + "
" + DELIMITER + INFIX + "while (i != 0)" + DELIMITER + INFIX + "\ti--;" + DELIMITER + INFIX + "
" + DELIMITER + POSTFIX; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - assertEquals(expected, testFormat(input)); + String result= testFormat(input); + assertEquals(expected, result); + + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + + assertEquals(expected, result); } public void testMultiLineCommentCodeSnippetHtmlEntities1() { @@ -116,7 +144,15 @@ String postfix= DELIMITER + INFIX + "" + DELIMITER + POSTFIX; //$NON-NLS-1$ String input= prefix + "System.out.println(\"test\");" + postfix; //$NON-NLS-1$ String expected= prefix + "System.out.println("test");" + postfix; //$NON-NLS-1$ - assertEquals(expected, testFormat(input)); + String result= testFormat(input); + assertEquals(expected, result); + + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + + assertEquals(expected, result); } public void testMultiLineCommentIndentTabs1() { @@ -453,9 +489,31 @@ result= testFormat(result); result= testFormat(result); - // XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=99738 - String WORKAROUND_BUG_99738= " "; //$NON-NLS-1$ - expected= PREFIX + DELIMITER + INFIX + "
" + DELIMITER + INFIX + WORKAROUND_BUG_99738 + "wrap here" + DELIMITER + INFIX + "
" + DELIMITER + POSTFIX; //$NON-NLS-1$; //$NON-NLS-2$; //$NON-NLS-3$; + expected= PREFIX + DELIMITER + INFIX + "
" + DELIMITER + INFIX + "wrap here" + DELIMITER + INFIX + "
" + DELIMITER + POSTFIX; //$NON-NLS-1$; //$NON-NLS-2$; //$NON-NLS-3$; + assertEquals(expected, result); + } + + /** + * [formatting] Javadoc formatting: extra newline with [pre] + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52921 + *

+ * This test only formats once. + *

+ */ + public void testNoExtraNewlineWithPre2() { + setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, DefaultCodeFormatterConstants.FALSE); + String input= PREFIX + DELIMITER + INFIX + "
wrap here
" + DELIMITER + POSTFIX; //$NON-NLS-1$ + String expected= PREFIX + DELIMITER + INFIX + "
wrap here
" + DELIMITER + POSTFIX; //$NON-NLS-1$ + String result= testFormat(input); + assertEquals(expected, result); + + // now re-format several times + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + result= testFormat(result); + + expected= PREFIX + DELIMITER + INFIX + "
wrap here
" + DELIMITER + POSTFIX; //$NON-NLS-1$ assertEquals(expected, result); }