Changeset 214


Ignore:
Timestamp:
29-04-07 20:14:43 (6 years ago)
Author:
thomas
Message:
  • moap/util/ctags.py (CTags.getTags): Make count include the given line, which makes more sense compared to how a diff counts.
  • moap/test/test_util_ctags.py (TestCTags.testGetManyTags, TestCTags.testGetBeforeFirstTag, TestCTags.testGetWithFirstTag, TestCTags.testGetTagBeforeTagLine, TestCTags.testGetTagOnTagLine, TestCTags.testGetTagAfterTagLine, TestCTags.testGetLastTwo, TestCTags.testGetLastTag): Update tests for new getTags behaviour
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r213 r214  
     12007-04-29  Thomas Vander Stichele  <thomas at apestaart dot org> 
     2 
     3        * moap/util/ctags.py (CTags.getTags): 
     4          Make count include the given line, which makes more sense 
     5          compared to how a diff counts. 
     6        * moap/test/test_util_ctags.py (TestCTags.testGetManyTags, 
     7          TestCTags.testGetBeforeFirstTag, TestCTags.testGetWithFirstTag, 
     8          TestCTags.testGetTagBeforeTagLine, TestCTags.testGetTagOnTagLine, 
     9          TestCTags.testGetTagAfterTagLine, TestCTags.testGetLastTwo, 
     10          TestCTags.testGetLastTag): 
     11          Update tests for new getTags behaviour 
     12 
    1132007-04-29  Thomas Vander Stichele  <thomas at apestaart dot org> 
    214 
  • trunk/moap/test/test_util_ctags.py

    r150 r214  
    3030 
    3131    def testGetManyTags(self): 
    32         tags = self.ctags.getTags('moap/vcs/cvs.py', 93, 10) 
     32        tags = self.ctags.getTags('moap/vcs/cvs.py', 93, 11) 
    3333        self.assertEquals(tags[0].name, 'commit') 
    3434        self.assertEquals(tags[1].name, 'diff') 
     
    3636    def testGetBeforeFirstTag(self): 
    3737        # asking for tags before there are any should return no tags 
    38         tags = self.ctags.getTags('moap/vcs/cvs.py', 5, 5) 
     38        tags = self.ctags.getTags('moap/vcs/cvs.py', 5, 6) 
    3939        self.failIf(tags) 
    4040 
    4141    def testGetWithFirstTag(self): 
    4242        # asking for tags before and in first tag should give first tag 
    43         tags = self.ctags.getTags('moap/vcs/cvs.py', 15, 5) 
     43        tags = self.ctags.getTags('moap/vcs/cvs.py', 15, 6) 
    4444        self.assertEquals(len(tags), 1) 
    4545        self.assertEquals(tags[0].name, 'detect') 
    4646 
    4747    def testGetTagBeforeTagLine(self): 
    48         tags = self.ctags.getTags('moap/vcs/cvs.py', 15, 0) 
     48        tags = self.ctags.getTags('moap/vcs/cvs.py', 15) 
    4949        self.failIf(tags) 
    5050 
    5151    def testGetTagOnTagLine(self): 
    52         tags = self.ctags.getTags('moap/vcs/cvs.py', 16, 0) 
     52        tags = self.ctags.getTags('moap/vcs/cvs.py', 16) 
    5353        self.assertEquals(len(tags), 1) 
    5454        self.assertEquals(tags[0].name, 'detect') 
    5555 
    5656    def testGetTagAfterTagLine(self): 
    57         tags = self.ctags.getTags('moap/vcs/cvs.py', 17, 0) 
     57        tags = self.ctags.getTags('moap/vcs/cvs.py', 17) 
    5858        self.assertEquals(len(tags), 1) 
    5959        self.assertEquals(tags[0].name, 'detect') 
     
    6161    def testGetLastTwo(self): 
    6262        # update starts on 106 
    63         tags = self.ctags.getTags('moap/vcs/cvs.py', 105, 1) 
     63        tags = self.ctags.getTags('moap/vcs/cvs.py', 105, 2) 
    6464        self.assertEquals(len(tags), 2) 
    6565        self.assertEquals(tags[0].name, 'diff') 
     
    6767 
    6868    def testGetLastTag(self): 
    69         tags = self.ctags.getTags('moap/vcs/cvs.py', 106, 0) 
     69        tags = self.ctags.getTags('moap/vcs/cvs.py', 106) 
    7070        self.assertEquals(len(tags), 1) 
    7171        self.assertEquals(tags[0].name, 'update') 
  • trunk/moap/util/ctags.py

    r213 r214  
    8282            self._files[t.file][t.line] = t 
    8383 
    84     def getTags(self, file, line, count=0): 
     84    def getTags(self, file, line, count=1): 
    8585        """ 
    8686        Get all tags for the given file, starting at the given line number, 
    87         optionally counting count lines further. 
     87        covered by the given count of lines from that point. 
    8888 
    8989        @returns: list of L{Tag} 
    9090        """ 
    9191        ret = [] 
     92        if count < 1: 
     93            return ret 
     94 
    9295        tags = self._files[file] 
    9396        starts = tags.keys() 
     
    121124        # now find all tags in the given range and append 
    122125        # it is possible we are already past the end of starts 
    123         while count and tags[starts[i]].line <= line + count: 
     126        while count > 1 and tags[starts[i]].line < line + count: 
    124127            startLine = starts[i] 
    125128            t = tags[startLine] 
Note: See TracChangeset for help on using the changeset viewer.