X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/PHPFormatterTest.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/PHPFormatterTest.java index d8b9d32..c13f010 100644 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/PHPFormatterTest.java +++ b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/PHPFormatterTest.java @@ -19,85 +19,150 @@ import org.eclipse.jface.text.IDocument; * Testcase for the PHP CodeFormatter * * @author Stefan Langer - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ public class PHPFormatterTest extends TestCase { - private CodeFormatter fFormatter; + private CodeFormatter fFormatter; - private IDocument fDocument; + private IDocument fDocument; - private String fInitialIndentation; + private String fInitialIndentation; - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - Map options = JavaCore.getOptions(); - fFormatter = new CodeFormatter(options); - fDocument = new DummyDocument(); - } + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + Map options = JavaCore.getOptions(); + fFormatter = new CodeFormatter(options); + fDocument = new DummyDocument(); + } - public void testFormatter0() { - System.out.println("----- testFormatter0 -----"); - String text = ""; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, lineDelimiter); - String testResult = ""; - junit.framework.Assert.assertEquals(formatedString, testResult); - } + public void testFormatter0() { + System.out.println("----- testFormatter0 -----"); + String text = ""; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = ""; + junit.framework.Assert.assertEquals(formatedString, testResult); + } - public void testFormatter1() { - System.out.println("----- testFormatter1 -----"); - String text = ""; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, lineDelimiter); - String testResult = ""; - junit.framework.Assert.assertEquals(formatedString, testResult); - } + public void testFormatter1() { + System.out.println("----- testFormatter1 -----"); + String text = ""; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = ""; + junit.framework.Assert.assertEquals(formatedString, testResult); + } - public void testFormatter2() { - // bug 741752 - System.out.println("----- testFormatter2 -----"); - String text = ""; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, lineDelimiter); - String testResult = ""; - junit.framework.Assert.assertEquals(formatedString, testResult); - } + public void testFormatter2() { + // bug 741752 + System.out.println("----- testFormatter2 -----"); + String text = ""; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = ""; + junit.framework.Assert.assertEquals(formatedString, testResult); + } - public void testFormatter3() { - System.out.println("----- testFormatter1 -----"); - String text = ""; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, lineDelimiter); - String testResult = ""; - junit.framework.Assert.assertEquals(formatedString, testResult); - } + public void testFormatter3() { + System.out.println("----- testFormatter1 -----"); + String text = ""; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = ""; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + + public void testArrayFormatting() throws Exception { + System.out.println("-----testArrayFormatting-----"); + String text = " 'ok','snd' => 'right','3th' => 'super');\n" + + "?>"; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = " 'ok'," + lineDelimiter + + "\t'snd' => 'right'," + lineDelimiter + "\t'3th' => 'super'" + + lineDelimiter + ");" + lineDelimiter + "?>"; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + + public void testDoubleArrayFormatting() throws Exception { + System.out.println("-----testDoubleArrayFormatting-----"); + String text = " 'ok', 'snd' => array ('1' => '11','2' => '22'),'3th' => 'super');\n" + + "?>"; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = " 'ok'," + lineDelimiter + + "\t'snd' => array (" + lineDelimiter + + "\t\t'1' => '11'," + lineDelimiter + + "\t\t'2' => '22'" + lineDelimiter + + "\t)," + lineDelimiter + + "\t'3th' => 'super'" + lineDelimiter + + ");" + lineDelimiter + + "?>"; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + + } \ No newline at end of file