Esempio n. 1
0
    def testCommentsInFile_SingleCommentInQuotes(self):
        """
        Comments in quotes are not returned.
        """
        contents =  """ a = "/* no Comment */" """

        comments = [ g for g in dtpp.comments_in_file(contents)]

        # should have 0 comments
        self.assertEqual(0, len(comments))
Esempio n. 2
0
    def testCommentsInFile_SingleCommentInAndOutOfQuotes(self):
        """
        Comments in quotes are not returned.
        """
        contents =  """ a = "/* not a Comment */" /** A Comment Indeed */ """

        comments = [ g for g in dtpp.comments_in_file(contents)]

        # should have 0 comments
        self.assertEqual(1, len(comments))
        self.assertEqual("/** A Comment Indeed */", comments[0][0])
Esempio n. 3
0
    def testCommentsInFile_SingleComment(self):
        contents = """ /** Comment 1 */ """
        comments = [ g for g in dtpp.comments_in_file(contents)]
        # should have 1 comment
        self.assertEqual(1, len(comments))

        comment_text, comment_span = comments[0]

        # beginning at offset 1
        self.assertEqual(1, comment_span[0])

        # and value "* Comment 1 "
        self.assertEquals("/** Comment 1 */", comment_text)
Esempio n. 4
0
    def testCommentsInFile_SingleMultiLineComment(self):
        contents =  \
        """
        /** 
         * First Line
         *
         * Another line here
         */
        """

        comments = [ g for g in dtpp.comments_in_file(contents)]
        # should have 1 comment
        self.assertEqual(1, len(comments))

        comment_text, comment_span = comments[0]

        # beginning at offset 9
        self.assertEqual(9, comment_span[0])

        # and value 
        self.assertEquals(contents.strip(), comment_text)
Esempio n. 5
0
 def testCommentsInFile_EmptyFile(self):
     contents = """ """
     comments = [ g for g in dtpp.comments_in_file(contents)]
     self.assertEqual(0, len(comments))