|
From: <caw...@us...> - 2007-07-31 17:29:54
|
Revision: 2903
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=2903&view=rev
Author: cawilliams
Date: 2007-07-31 10:29:22 -0700 (Tue, 31 Jul 2007)
Log Message:
-----------
add some basic tests for the auto indent strategy
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TestDocumentCommand.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyAutoIndentStrategy.java
Added: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TestDocumentCommand.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TestDocumentCommand.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TestDocumentCommand.java 2007-07-31 17:29:22 UTC (rev 2903)
@@ -0,0 +1,10 @@
+package org.rubypeople.rdt.internal.ui.text;
+
+import org.eclipse.jface.text.DocumentCommand;
+
+public class TestDocumentCommand extends DocumentCommand {
+
+ public TestDocumentCommand() {
+ super();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TestDocumentCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyAutoIndentStrategy.java 2007-07-31 17:29:22 UTC (rev 2903)
@@ -0,0 +1,45 @@
+package org.rubypeople.rdt.internal.ui.text.ruby;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IDocument;
+import org.rubypeople.rdt.internal.ui.text.TestDocumentCommand;
+
+public class TC_RubyAutoIndentStrategy extends TestCase {
+
+ public void testInsertsIndentAndEndAfterClassDefinitionLine() throws Exception {
+ DocumentCommand c = addNewline("class Chris");
+ assertEquals(15, c.caretOffset);
+ assertEquals(false, c.shiftsCaret);
+ assertEquals("\r\n \r\nend", c.text);
+ }
+
+ public void testInsertsIndentAndEndAfterMethodDefinitionLine() throws Exception {
+ DocumentCommand c = addNewline("def bob");
+ assertEquals(11, c.caretOffset);
+ assertEquals(false, c.shiftsCaret);
+ assertEquals("\r\n \r\nend", c.text);
+ }
+
+ private DocumentCommand addNewline(String source) {
+ RubyAutoIndentStrategy strategy = new RubyAutoIndentStrategy(null, null);
+ DocumentCommand c = createDocumentCommand(source.length());
+ IDocument d = new Document(source);
+ strategy.customizeDocumentCommand(d, c);
+ return c;
+ }
+
+ private DocumentCommand createDocumentCommand(int offset) {
+ DocumentCommand c = new TestDocumentCommand();
+ c.text = "\r\n";
+ c.length = 0;
+ c.doit = true;
+ c.caretOffset = -1;
+ c.offset = offset;
+ c.shiftsCaret = true;
+ return c;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyAutoIndentStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|