1 33 34 package edu.rice.cs.drjava.model.definitions.reducedmodel; 35 36 import junit.framework.*; 37 38 42 public final class MixedQuoteTest extends BraceReductionTestCase 43 implements ReducedModelStates 44 { 45 protected ReducedModelControl _model; 46 47 50 protected void setUp() throws Exception { 51 super.setUp(); 52 _model = new ReducedModelControl(); 53 } 54 55 59 public static Test suite() { 60 return new TestSuite(MixedQuoteTest.class); 61 } 62 63 68 protected void insertGap(BraceReduction model, int size) { 69 for (int i = 0; i < size; i++) { 70 model.insertChar(' '); 71 } 72 } 73 74 81 public void testSingleEclipsesDouble() { 82 _model.insertChar('\"'); 83 assertEquals("#0.0", INSIDE_DOUBLE_QUOTE, _model.getStateAtCurrent()); 84 _model.move(-1); 85 assertEquals("#0.1", FREE, stateOfCurrentToken(_model)); 86 _model.move(1); 87 _model.insertChar('A'); 88 _model.move(-1); 89 assertEquals("#1.0", INSIDE_DOUBLE_QUOTE, _model.getStateAtCurrent()); 90 assertEquals("#1.1", INSIDE_DOUBLE_QUOTE, stateOfCurrentToken(_model)); 91 assertTrue("#1.2", _model.currentToken().isGap()); 92 _model.move(-1); 93 _model.insertChar('\''); 94 assertEquals("#2.0", INSIDE_SINGLE_QUOTE, _model.getStateAtCurrent()); 95 assertEquals("#2.1", INSIDE_SINGLE_QUOTE, stateOfCurrentToken(_model)); 96 assertEquals("#2.2", "\"", _model.currentToken().getType()); 97 _model.move(1); 98 assertEquals("#3.0", INSIDE_SINGLE_QUOTE, _model.getStateAtCurrent()); 99 assertEquals("#3.1", INSIDE_SINGLE_QUOTE, stateOfCurrentToken(_model)); 100 assertTrue("#3.2", _model.currentToken().isGap()); 101 } 102 103 107 public void testDoubleEclipsesSingle() { 108 _model.insertChar('\''); 109 assertEquals("#0.0", INSIDE_SINGLE_QUOTE, _model.getStateAtCurrent()); 110 _model.move(-1); 111 assertEquals("#0.1", FREE, stateOfCurrentToken(_model)); 112 _model.move(1); 113 _model.insertChar('A'); 114 _model.move(-1); 115 assertEquals("#1.0", INSIDE_SINGLE_QUOTE, _model.getStateAtCurrent()); 116 assertEquals("#1.1", INSIDE_SINGLE_QUOTE, stateOfCurrentToken(_model)); 117 assertTrue("#1.2", _model.currentToken().isGap()); 118 _model.move(-1); 119 _model.insertChar('\"'); 120 assertEquals("#2.0", INSIDE_DOUBLE_QUOTE, _model.getStateAtCurrent()); 121 assertEquals("#2.1", INSIDE_DOUBLE_QUOTE, stateOfCurrentToken(_model)); 122 assertEquals("#2.2", "\'", _model.currentToken().getType()); 123 _model.move(1); 124 assertEquals("#3.0", INSIDE_DOUBLE_QUOTE, _model.getStateAtCurrent()); 125 assertEquals("#3.1", INSIDE_DOUBLE_QUOTE, stateOfCurrentToken(_model)); 126 assertTrue("#3.2", _model.currentToken().isGap()); 127 } 128 } 129 | Popular Tags |