def comments(self):
     """Comments in the code (list of :class:`.Comment`)."""
     comments = []
     for token in self._tu.cursor.get_tokens():
         if token.kind == cindex.TokenKind.COMMENT:
             comments.append(Comment(token.spelling))
     return comments
Esempio n. 2
0
 def test_two_comments_with_same_text_are_equal(self):
     comment1 = Comment('// test')
     comment2 = Comment('// test')
     self.assertEqual(comment1, comment2)
Esempio n. 3
0
 def test_two_different_comments_are_not_equal(self):
     comment1 = Comment('// Hello Peter ')
     comment2 = Comment('// test')
     self.assertNotEqual(comment1, comment2)
Esempio n. 4
0
 def test_repr_returns_correct_value(self):
     comment = Comment('// test')
     self.assertEqual(repr(comment), "Comment('// test')")
Esempio n. 5
0
 def test_matches_checks_whole_comment(self):
     comment = Comment('// test')
     self.assertFalse(comment.matches(r'//'))
     self.assertFalse(comment.matches(r'// tes'))
     self.assertTrue(comment.matches(r'// test'))
Esempio n. 6
0
 def test_matches_returns_false_if_comment_does_not_match_regexp(self):
     comment = Comment('// test')
     self.assertFalse(comment.matches(r'// Hello'))
Esempio n. 7
0
 def test_matches_returns_true_if_comment_matches_compiled_regexp(self):
     comment = Comment('// test')
     self.assertTrue(comment.matches(re.compile(r'// test')))
Esempio n. 8
0
 def test_matches_returns_true_if_comment_matches_regexp_str(self):
     comment = Comment('// test')
     self.assertTrue(comment.matches(r'// test'))