|
From: <caw...@us...> - 2007-07-31 19:01:17
|
Revision: 2905
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=2905&view=rev
Author: cawilliams
Date: 2007-07-31 12:01:16 -0700 (Tue, 31 Jul 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyAutoIndentStrategy.java
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyAutoIndentStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyAutoIndentStrategy.java 2007-07-31 19:01:11 UTC (rev 2904)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyAutoIndentStrategy.java 2007-07-31 19:01:16 UTC (rev 2905)
@@ -9,6 +9,8 @@
public class TC_RubyAutoIndentStrategy extends TestCase {
+ private IDocument d;
+
public void testInsertsIndentAndEndAfterClassDefinitionLine() throws Exception {
DocumentCommand c = addNewline("class Chris");
assertEquals(15, c.caretOffset);
@@ -22,16 +24,62 @@
assertEquals(false, c.shiftsCaret);
assertEquals("\r\n \r\nend", c.text);
}
+
+ public void testHandlesReturnAfterEndOfClosedCaseWithProperIndents() throws Exception {
+ DocumentCommand c = addNewline("class Chris\r\n" +
+" case condition\r\n" +
+" when comparison1\r\n" +
+" comparison1_body\r\n" +
+" when comparison2\r\n" +
+" comparison2_body\r\n" +
+" end\r\n" +
+"end", 128);
+ assertEquals("\r\n ", c.text);
+ assertEquals("class Chris\r\n" +
+ " case condition\r\n" +
+ " when comparison1\r\n" +
+ " comparison1_body\r\n" +
+ " when comparison2\r\n" +
+ " comparison2_body\r\n" +
+ " end\r\n" +
+ " \r\n" +
+ "end", d.get());
+ }
+
+ public void testHandlesReturnAfterEndOfClosedCaseWithBadEndIndent() throws Exception {
+ DocumentCommand c = addNewline("class Chris\r\n" +
+" case condition\r\n" +
+" when comparison1\r\n" +
+" comparison1_body\r\n" +
+" when comparison2\r\n" +
+" comparison2_body\r\n" +
+" end\r\n" +
+"end", 132);
+ assertEquals("\r\n ", c.text);
+ assertEquals("class Chris\r\n" +
+ " case condition\r\n" +
+ " when comparison1\r\n" +
+ " comparison1_body\r\n" +
+ " when comparison2\r\n" +
+ " comparison2_body\r\n" +
+ " end\r\n" +
+ " \r\n" +
+ "end", d.get());
+ }
- private DocumentCommand addNewline(String source) {
+ private DocumentCommand addNewline(String source, int offset) {
RubyAutoIndentStrategy strategy = new RubyAutoIndentStrategy(null, null);
- DocumentCommand c = createDocumentCommand(source.length());
- IDocument d = new Document(source);
+ DocumentCommand c = createNewLineCommandAt(offset);
+ d = new Document(source);
strategy.customizeDocumentCommand(d, c);
return c;
}
- private DocumentCommand createDocumentCommand(int offset) {
+ private DocumentCommand addNewline(String source) {
+ return addNewline(source, source.length());
+ }
+
+ private DocumentCommand createNewLineCommandAt(int offset) {
DocumentCommand c = new TestDocumentCommand();
c.text = "\r\n";
c.length = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|