def testSingleLineComment(self):
     code = '// single line comment'
     comments = js_parser.extract_comments(code)
     expected = [common.Comment(code[2:], 1, multiline=False)]
     self.assertEqual(comments, expected)
 def ExtractComments(self, text, mock_open):
     mock_file = StringIO(text)
     mock_open.return_value = mock_file
     return js_parser.extract_comments('filename')
 def testMultiLineCommentInSingleLiteral(self):
     code = "msg = '/* This is not a\\nmultiline comment */'"
     comments = js_parser.extract_comments(code)
     self.assertEqual(comments, [])
 def testMultiLineCommentInDoubleLiteral(self):
     code = 'msg = "/* This is not a\\nmultiline comment */"'
     comments = js_parser.extract_comments(code)
     self.assertEqual(comments, [])
 def testMultiLineCommentWithStars(self):
     code = "/***************/"
     comments = js_parser.extract_comments(code)
     expected = [common.Comment(code[2:-2], 1, multiline=True)]
     self.assertEqual(comments, expected)
 def testMultiLineComment(self):
     code = '/* multiline\ncomment */'
     comments = js_parser.extract_comments(code)
     expected = [common.Comment(code[2:-2], 1, multiline=True)]
     self.assertEqual(comments, expected)
 def testLineCommentInDoubleQuotedLiteral(self):
     code = 'msg = "// this is not a comment"'
     comments = js_parser.extract_comments(code)
     self.assertEqual(comments, [])
 def testLineCommentInSingleQuotedLiteral(self):
     code = "msg = '// this is not a comment'"
     comments = js_parser.extract_comments(code)
     self.assertEqual(comments, [])
Exemple #9
0
 def ExtractComments(self, text, mock_open):
     mock_file = StringIO(text)
     mock_open.return_value = mock_file
     return js_parser.extract_comments('filename')