Changeset 150
- Timestamp:
- 21-03-07 00:30:25 (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
moap/test/test_util_ctags.py (modified) (2 diffs)
-
moap/util/ctags.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r149 r150 1 2007-03-21 Thomas Vander Stichele <thomas at apestaart dot org> 2 3 * moap/test/test_util_ctags.py (TestTag.testRepr, TestTag.testParse, 4 TestCTags.testGetLastTwo, TestCTags.testGetLastTag, 5 TestCTagsFromString, TestCTagsFromString.testFromEmptyString, 6 TestCTagsFromString.testFromString, 7 TestCTagsFromString.testFromWrongString): 8 * moap/util/ctags.py (CTags.getTags): 9 Increase coverage to 100%. 10 Fix small bugs exposed by adding tests to increase coverage. 11 1 12 2007-03-21 Thomas Vander Stichele <thomas at apestaart dot org> 2 13 -
trunk/moap/test/test_util_ctags.py
r137 r150 11 11 def setUp(self): 12 12 self.tag = ctags.Tag() 13 14 def testRepr(self): 15 self.failUnless(repr(self.tag)) 13 16 14 17 def testParse(self): … … 56 59 self.assertEquals(tags[0].name, 'detect') 57 60 61 def testGetLastTwo(self): 62 # update starts on 106 63 tags = self.ctags.getTags('moap/vcs/cvs.py', 105, 1) 64 self.assertEquals(len(tags), 2) 65 self.assertEquals(tags[0].name, 'diff') 66 self.assertEquals(tags[1].name, 'update') 67 58 68 def testGetLastTag(self): 59 tags = self.ctags.getTags('moap/vcs/cvs.py', 10 7, 0)69 tags = self.ctags.getTags('moap/vcs/cvs.py', 106, 0) 60 70 self.assertEquals(len(tags), 1) 61 71 self.assertEquals(tags[0].name, 'update') 72 73 class TestCTagsFromString(unittest.TestCase): 74 def testFromEmptyString(self): 75 self.ctags = ctags.CTags() 76 self.ctags.addString('') 77 78 def testFromString(self): 79 self.ctags = ctags.CTags() 80 self.ctags.addString('!_TAG_') 81 82 def testFromWrongString(self): 83 self.ctags = ctags.CTags() 84 self.assertRaises(KeyError, self.ctags.addString, 'wrongtype') -
trunk/moap/util/ctags.py
r147 r150 87 87 starts.sort() 88 88 i = 0 89 # look for first tag beyond theline number90 while tags[starts[i]].line < line:89 # look for the tag right before the given line number 90 while tags[starts[i]].line <= line: 91 91 i += 1 92 92 if i == len(starts): 93 93 # line number is past the last tag, so we only return 94 94 # the last tag 95 self.debug('Returning only tag starting on %d' % starts[-1]) 95 96 return [tags[starts[-1]], ] 96 97 97 # go back one if we are not exactly on a tag start line98 if tags[starts[i]].line > line:99 i -= 198 # now i points to a tag on or beyond the given line number, so go back 99 # one 100 i -= 1 100 101 101 102 if i >= 0: 102 # there is in fact a tag started before the given line 103 # there is in fact a tag started before the given line, so append it 104 self.debug('appending tag starting on line %d' % starts[i]) 103 105 ret.append(tags[starts[i]]) 106 107 # now we go back to the first tag starting on or past the given line 108 # number 104 109 i += 1 105 110 106 111 # now find all tags in the given range and append 107 while tags[starts[i]].line < line + count: 112 # it is possible we are already past the end of starts 113 while count and tags[starts[i]].line <= line + count: 114 self.debug('appending tag starting on line %d' % starts[i]) 108 115 ret.append(tags[starts[i]]) 109 116 i += 1 … … 111 118 break 112 119 120 self.debug('returning %d tags' % len(ret)) 113 121 return ret
Note: See TracChangeset
for help on using the changeset viewer.
