Example #1
0
  public void testInconsistentIndent2() throws Exception {
    Document doc = new Document("" + "def m(b):\n" + "   pass\n" + "\n" + "");

    List<IMessage> messages =
        TabNanny.analyzeDoc(
            doc, this.prefs, "", new TestIndentPrefs(true, 4), new NullProgressMonitor());
    assertEquals(1, messages.size());
    IMessage m = messages.get(0);
    assertEquals("Bad Indentation (3 spaces)", m.getMessage());
    assertEquals(2, m.getStartLine(null));
    assertEquals(2, m.getEndLine(null));
    assertEquals(1, m.getStartCol(null));
    assertEquals(4, m.getEndCol(null));
  }
Example #2
0
  public void testTabErrors1() throws Exception {
    Document doc = new Document("" + "aaa\n" + "\t\n" + "    \n" + "    \t\n" + "ccc\n" + "");

    List<IMessage> messages =
        TabNanny.analyzeDoc(
            doc, this.prefs, "", new TestIndentPrefs(true, 4), new NullProgressMonitor());
    for (IMessage m : messages) {
      assertEquals("Mixed Indentation: Tab found", m.getMessage());
      int startLine = m.getStartLine(null);

      if (startLine == 2) {
        assertEquals(1, m.getStartCol(null));
        assertEquals(2, m.getEndCol(null));

      } else if (startLine == 4) {
        assertEquals(5, m.getStartCol(null));
        assertEquals(6, m.getEndCol(null));

      } else {
        throw new RuntimeException("Unexpected line:" + startLine);
      }
    }
    assertEquals(2, messages.size());
  }