Exemple #1
0
    def testCantRemoveSlashSlashInsideRegex(self):
        input = """
function a() {
    //a comment
    var x = /^\/\//;
}"""
        output = minifyme.remove_line_comments(input)
        self.assertEqual(4, output.count('/'))
        self.assertTrue(output.find('/^\/\//;') > 0)
Exemple #2
0
    def testRemovingSlashSlashComments(self):
        input = """
//my wonderful comment
function a() {
    //i'm inside my wonderful function
    var x = 1;
}"""
        output = minifyme.remove_line_comments(input)
        self.assertEqual(0, output.count('/'))
Exemple #3
0
    def testCantRemoveSlashSlashInsideStrings(self):
        input = """
function a() {
    //a comment
    var x = "//foo" //bar;
}"""
        output = minifyme.remove_line_comments(input)
        self.assertEqual(2, output.count('/'))
        self.assertTrue(output.find("//bar") < 0)
        self.assertTrue(output.find("//foo") > 0)
Exemple #4
0
    def test_removing_line_comments(self):
        input = r'''
        //first comment
        function a() {
            //second comment
            var x = 1;
        }'''
        output = minifyme.remove_line_comments(input)
        self.assertEqual(0, output.count('/'))
	self.assertTrue(output.find('first comment') < 0)
	self.assertTrue(output.find('second comment') < 0)
Exemple #5
0
 def test_cant_remove_multiline_comment_when_removing_line_comments(self):
     input = r'/* test*/'
     output = minifyme.remove_line_comments(input)
     self.assertTrue(output.find(r'/* test*/') >= 0)
Exemple #6
0
 def test_scapes_are_interpreted_inside_strings(self):
     input = r'var a = "bla\"test//!";'
     output = minifyme.remove_line_comments(input)
     self.assertTrue(output.find(r"a\"test//") > 0)
Exemple #7
0
 def test_cant_remove_double_slash_inside_regex(self):
     input = r'var x = /^\/\//;'
     output = minifyme.remove_line_comments(input)
     self.assertEqual(4, output.count(r'/'))
     self.assertTrue(output.find(r'/^\/\//;') > 0)
Exemple #8
0
 def test_cant_remove_double_slash_inside_strings(self):
     input = r'var x = "//foo" //bar;'
     output = minifyme.remove_line_comments(input)
     self.assertEqual(2, output.count(r'/'))
     self.assertTrue(output.find(r"//bar") < 0)
     self.assertTrue(output.find(r"//foo") > 0)