1 33 34 package edu.rice.cs.drjava.model.definitions.indent; 35 36 import java.util.Vector ; 37 import javax.swing.text.BadLocationException ; 38 39 44 public final class IndentRuleWithTraceTest extends IndentRulesTestCase{ 45 46 public void testTrace() throws BadLocationException { 47 IndentRuleWithTrace.setRuleTraceEnabled(true); 48 IndentRule 49 rule4 = new ActionBracePlus(" "), 50 rule3 = new QuestionBraceIsCurly(rule4, rule4), 51 rule2 = new QuestionBraceIsParenOrBracket(rule3, rule3); 52 IndentRuleQuestion 53 rule1 = new QuestionInsideComment(rule2, rule2); 54 String text = 55 "public class foo {\n" + 56 "/**\n" + 57 " * This method does nothing\n" + 58 " */\n" + 59 "public void method1(){\n" + 60 "}\n" + 61 "}\n"; 62 63 _setDocText(text); 64 rule1.indentLine(_doc, 23, Indenter.OTHER); 65 rule1.indentLine(_doc, 75, Indenter.OTHER); 66 67 String [] expected = {"edu.rice.cs.drjava.model.definitions.indent.QuestionInsideComment No", 68 "edu.rice.cs.drjava.model.definitions.indent.QuestionBraceIsParenOrBracket No", 69 "edu.rice.cs.drjava.model.definitions.indent.QuestionBraceIsCurly Yes", 70 "edu.rice.cs.drjava.model.definitions.indent.ActionBracePlus "}; 71 72 Vector <String > actual = IndentRuleWithTrace.getTrace(); 73 assertEquals("steps in trace", 4, actual.size()); 74 for(int x = 0; x < actual.size(); x++) { 75 assertEquals("check trace step " + x, expected[x], actual.get(x)); 76 } 77 } 78 } 79 | Popular Tags |