The WhitespaceEater is in charge of counting and managing whitespace at the begining of lines. It handles: Consistency of types of whitespace (tabs vs spaces) Consistency of number of whitespaces (# of spaces being counted as an indent) The number of indents on each line The change in the number of idents from the last line Counts the number of indents open at a time
Exemplo n.º 1
0
 public int ItCountsDeltaIndentsDivibleByLearnedIndentsPerLine(string whitespaceTrainer,string previous, string line)
 {
     var sut = new WhitespaceEater();
     var lineCnt = 1;
     foreach(var trainer in whitespaceTrainer.Split(';'))
     {
         sut.Eat(trainer, lineCnt++);
     }
     sut.Eat(previous, lineCnt++);
     return sut.Eat(line, lineCnt++).DeltaIndents;
 }
Exemplo n.º 2
0
 public int ItCountsIndentsDivibleByLearnedIndentsPerLine(string previous, string line)
 {
     var sut = new WhitespaceEater();
     sut.Eat(previous, 1);
     return sut.Eat(line, 2).Indents;
 }
Exemplo n.º 3
0
 public int ItCountsIndents(string line)
 {
     var sut = new WhitespaceEater();
     return sut.Eat(line, 1).Indents;
 }
Exemplo n.º 4
0
 public void ItDoesNotAllowMoreThanOneTabbingLevelIncreaseAtATime()
 {
     var sut = new WhitespaceEater();
     sut.Eat("\t", 0);
     sut.Eat("a", 1);
     Assert.Catch<InconsistentWhitespaceException>(() => sut.Eat("\t\tb", 2));
 }
Exemplo n.º 5
0
 public int ItCountsOpenIndents(string whitespaceTrainer,string line)
 {
     var sut = new WhitespaceEater();
     sut.Eat(whitespaceTrainer, 0);
     sut.Eat(line, 1);
     return sut.OpenIndents;
 }