[Pydev-cvs] org.python.pydev/tests/org/python/pydev/editor/actions PyFormatStdTest.java, 1.11, 1.12
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-07-19 11:57:50
|
Update of /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13369/tests/org/python/pydev/editor/actions Modified Files: PyFormatStdTest.java Log Message: PyFormatStd changes: comments/ minor refactorings Index: PyFormatStdTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/actions/PyFormatStdTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PyFormatStdTest.java 26 Feb 2008 16:33:01 -0000 1.11 --- PyFormatStdTest.java 19 Jul 2008 11:57:58 -0000 1.12 *************** *** 8,11 **** --- 8,12 ---- import junit.framework.TestCase; + import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.editor.actions.PyFormatStd.FormatStd; *************** *** 21,25 **** PyFormatStdTest n = new PyFormatStdTest(); n.setUp(); ! n.testNoFormatCommaOnNewLine(); n.tearDown(); --- 22,26 ---- PyFormatStdTest n = new PyFormatStdTest(); n.setUp(); ! n.testFormatNotLinesOnlyWithParentesis(); n.tearDown(); *************** *** 52,56 **** " pass \n"; ! assertEquals(s1, PyFormatStd.formatStr(s, std)); std.spaceAfterComma = false; --- 53,57 ---- " pass \n"; ! checkFormatResults(s, s1); std.spaceAfterComma = false; *************** *** 60,64 **** " pass \n"; ! assertEquals(s2, PyFormatStd.formatStr(s, std)); } --- 61,65 ---- " pass \n"; ! checkFormatResults(s, s2); } *************** *** 78,82 **** " pass\n"; ! assertEquals(s1, PyFormatStd.formatStr(s, std)); } --- 79,83 ---- " pass\n"; ! checkFormatResults(s, s1); } *************** *** 88,96 **** "foo(bar(\"\\\"\"))"; ! assertEquals(s, PyFormatStd.formatStr(s, std)); s = ""+ "foo(bar('''\\''''))"; ! assertEquals(s, PyFormatStd.formatStr(s, std)); } --- 89,97 ---- "foo(bar(\"\\\"\"))"; ! checkFormatResults(s); s = ""+ "foo(bar('''\\''''))"; ! checkFormatResults(s); } *************** *** 108,112 **** " pass \n"; ! assertEquals(s1, PyFormatStd.formatStr(s, std)); } --- 109,113 ---- " pass \n"; ! checkFormatResults(s, s1); } *************** *** 124,128 **** " pass \n"; ! assertEquals(s1, PyFormatStd.formatStr(s, std)); std.spaceAfterComma = false; --- 125,129 ---- " pass \n"; ! checkFormatResults(s, s1); std.spaceAfterComma = false; *************** *** 132,136 **** " pass \n"; ! assertEquals(s2, PyFormatStd.formatStr(s, std)); } --- 133,137 ---- " pass \n"; ! checkFormatResults(s, s2); } *************** *** 149,153 **** " pass \n"; ! assertEquals(s1, PyFormatStd.formatStr(s, std)); std.spaceAfterComma = false; --- 150,154 ---- " pass \n"; ! checkFormatResults(s, s1); std.spaceAfterComma = false; *************** *** 157,161 **** " pass \n"; ! assertEquals(s2, PyFormatStd.formatStr(s, std)); } --- 158,162 ---- " pass \n"; ! checkFormatResults(s, s2); } *************** *** 172,176 **** " return ((a+b) + (a+b)) \n"; ! assertEquals(s1, PyFormatStd.formatStr(s, std)); --- 173,177 ---- " return ((a+b) + (a+b)) \n"; ! checkFormatResults(s, s1); *************** *** 180,184 **** " return ( ( a+b ) + ( a+b ) ) \n"; ! assertEquals(s2, PyFormatStd.formatStr(s, std)); } --- 181,185 ---- " return ( ( a+b ) + ( a+b ) ) \n"; ! checkFormatResults(s, s2); } *************** *** 195,199 **** " return ( callA() + callB( b+b ) ) \n"; ! assertEquals(s1, PyFormatStd.formatStr(s, std)); } --- 196,200 ---- " return ( callA() + callB( b+b ) ) \n"; ! checkFormatResults(s, s1); } *************** *** 208,212 **** "'''"; ! assertEquals(s, PyFormatStd.formatStr(s, std)); s = ""+ --- 209,213 ---- "'''"; ! checkFormatResults(s); s = ""+ *************** *** 215,219 **** ""; ! assertEquals(s, PyFormatStd.formatStr(s, std)); s = ""+ --- 216,220 ---- ""; ! checkFormatResults(s); s = ""+ *************** *** 222,226 **** ""; ! assertEquals(s, PyFormatStd.formatStr(s, std)); s = ""+ --- 223,227 ---- ""; ! checkFormatResults(s); s = ""+ *************** *** 229,233 **** ""; ! assertEquals(s, PyFormatStd.formatStr(s, std)); } --- 230,234 ---- ""; ! checkFormatResults(s); } *************** *** 242,246 **** "#'''"; ! assertEquals(s, PyFormatStd.formatStr(s, std)); } --- 243,247 ---- "#'''"; ! checkFormatResults(s); } *************** *** 261,265 **** "thisChanges( a+b + ( a+b ) )"; ! assertEquals(s2, PyFormatStd.formatStr(s, std)); //unfinished comment --- 262,266 ---- "thisChanges( a+b + ( a+b ) )"; ! checkFormatResults(s, s2); //unfinished comment *************** *** 270,274 **** "thisDoesNotChange()"; ! assertEquals(s, PyFormatStd.formatStr(s, std)); //unfinished comment at end of string --- 271,275 ---- "thisDoesNotChange()"; ! checkFormatResults(s); //unfinished comment at end of string *************** *** 278,282 **** "''"; ! assertEquals(s, PyFormatStd.formatStr(s, std)); } --- 279,283 ---- "''"; ! checkFormatResults(s); } *************** *** 287,291 **** String s = "methodname.split( '(' )"; ! assertEquals(s, PyFormatStd.formatStr(s, std)); } --- 288,292 ---- String s = "methodname.split( '(' )"; ! checkFormatResults(s); } *************** *** 297,302 **** " )"; ! String formatStr = PyFormatStd.formatStr(s, std); ! assertEquals(s, formatStr); } --- 298,302 ---- " )"; ! checkFormatResults(s); } *************** *** 308,313 **** ! String formatStr = PyFormatStd.formatStr(s, std); ! assertEquals(s, formatStr); } --- 308,312 ---- ! checkFormatResults(s); } *************** *** 322,327 **** ! String formatStr = PyFormatStd.formatStr(s, std); ! assertEquals(s, formatStr); } --- 321,375 ---- ! checkFormatResults(s); ! } ! ! ! public void testCommaOnParens(){ ! std.spaceAfterComma = true; ! std.parametersWithSpace = false; ! ! String s = "" + ! "methodCall(a,b,c))\n"; ! ! ! checkFormatResults(s, "methodCall(a, b, c))\n"); ! } ! ! ! /** ! * Checks the results with the default passed and then with '\r' and '\n' considering ! * that the result of formatting the input string will be the same as the input. ! * ! * @param s the string to be checked (and also the expected output) ! */ ! private void checkFormatResults(String s) { ! checkFormatResults(s, s); ! } ! ! ! /** ! * Checks the results with the default passed and then with '\r' and '\n' ! * @param s the string to be checked ! * @param expected the result of making the formatting in the string ! */ ! private void checkFormatResults(String s, String expected) { ! //default check (defined with \n) ! String formatStr = new PyFormatStd().formatStr(s, std); ! assertEquals(expected, formatStr); ! ! //second check (defined with \r) ! s = s.replace('\n', '\r'); ! expected = expected.replace('\n', '\r'); ! ! formatStr = new PyFormatStd().formatStr(s, std); ! assertEquals(expected, formatStr); ! ! //third check (defined with \r\n) ! s = StringUtils.replaceAll(s, "\r", "\r\n"); ! expected = StringUtils.replaceAll(expected, "\r", "\r\n"); ! ! formatStr = new PyFormatStd().formatStr(s, std); ! assertEquals(expected, formatStr); ! } |