Ejemplo n.º 1
0
 def ShouldFailIncludeCheck(self, line):
   """Checks that the '</include>' checker flags |line| as a style error."""
   error = self.checker.IncludeCheck(1, line)
   self.assertNotEqual('', error,
       'Should be flagged as style error: ' + line)
   highlight = test_util.GetHighlight(line, error).strip()
   self.assertTrue('include' in highlight and highlight[0] == '<')
Ejemplo n.º 2
0
 def ShouldFailCommentCheck(self, line):
     """Checks that uncommented "<if>" and "<include>" are a style error."""
     error = self.checker.CommentIfAndIncludeCheck(1, line)
     self.assertNotEqual("", error,
                         "Should be flagged as style error: " + line)
     highlight = test_util.GetHighlight(line, error).strip()
     self.assertTrue(highlight.startswith(("<if", "<include")))
Ejemplo n.º 3
0
 def ShouldFailPolymerLocalIdCheck(self, line):
     """Checks that element.$.localId check marks |line| as a style error."""
     error = self.checker.PolymerLocalIdCheck(1, line)
     self.assertNotEqual('',
                         error,
                         msg='Should be flagged as a style error: ' + line)
     self.assertTrue('.$' in test_util.GetHighlight(line, error))
Ejemplo n.º 4
0
 def ShouldFailVariableNameCheck(self, line):
   """Checks that var unix_hacker, $dollar are style errors."""
   error = self.checker.VariableNameCheck(1, line)
   self.assertNotEqual('', error,
       msg='Should be flagged as style error: ' + line)
   highlight = test_util.GetHighlight(line, error)
   self.assertFalse(any(dm in highlight for dm in _DECLARATION_METHODS))
Ejemplo n.º 5
0
 def ShouldFailCommentCheck(self, line):
     """Checks that uncommented '<if>' and '<include>' are a style error."""
     error = self.checker.CommentIfAndIncludeCheck(1, line)
     self.assertNotEqual('', error,
                         'Should be flagged as style error: ' + line)
     highlight = test_util.GetHighlight(line, error).strip()
     self.assertTrue(highlight.startswith(('<if', '<include')))
Ejemplo n.º 6
0
 def ShouldFailInheritDocCheck(self, line):
     """Checks that the '@inheritDoc' checker flags |line| as a style error."""
     error = self.checker.InheritDocCheck(1, line)
     self.assertNotEqual('',
                         error,
                         msg='Should be flagged as style error: ' + line)
     self.assertEqual(test_util.GetHighlight(line, error), '@inheritDoc')
Ejemplo n.º 7
0
 def ShouldFailVarNameCheck(self, line):
   """Checks that var unix_hacker, $dollar are style errors."""
   error = self.checker.VarNameCheck(1, line)
   self.assertNotEqual('', error,
       msg='Should be flagged as style error: ' + line)
   highlight = test_util.GetHighlight(line, error)
   self.assertFalse('var ' in highlight);
Ejemplo n.º 8
0
 def ShouldFailWrapperTypeCheck(self, line):
   """Checks that the use of wrapper types (i.e. new Number(), @type {Number})
      is a style error.
   """
   error = self.checker.WrapperTypeCheck(1, line)
   self.assertNotEqual('', error,
       msg='Should be flagged as style error: ' + line)
   highlight = test_util.GetHighlight(line, error)
   self.assertTrue(highlight in ('Boolean', 'Number', 'String'))
Ejemplo n.º 9
0
 def ShouldFailGetElementByIdCheck(self, line):
   """Checks that the 'getElementById' checker flags |line| as a style
      error.
   """
   error = self.checker.GetElementByIdCheck(1, line)
   self.assertNotEqual('', error,
       'Should be flagged as style error: ' + line)
   self.assertEqual(test_util.GetHighlight(line, error),
                    'document.getElementById')
Ejemplo n.º 10
0
 def ShouldFailInheritDocCheck(self, line):
   """Checks that the "@inheritDoc" checker flags |line| as a style error."""
   error = self.checker.InheritDocCheck(1, line)
   self.assertNotEqual("", error, "Should be flagged as style error: " + line)
   self.assertEqual(test_util.GetHighlight(line, error), "@inheritDoc")
Ejemplo n.º 11
0
 def ShouldFailCheck(self, line, checker):
   """Checks that the |checker| flags |line| as a style error."""
   error = checker(1, line)
   self.assertNotEqual('', error, 'Should be flagged as style error: ' + line)
   highlight = test_util.GetHighlight(line, error).strip()
Ejemplo n.º 12
0
 def ShouldFailChromeSendCheck(self, line):
   """Checks that the 'chrome.send' checker flags |line| as a style error."""
   error = self.checker.ChromeSendCheck(1, line)
   self.assertNotEqual('', error,
       'Should be flagged as style error: ' + line)
   self.assertEqual(test_util.GetHighlight(line, error), ', []')
Ejemplo n.º 13
0
 def ShouldFailExtraDotInGenericCheck(self, line):
   """Checks that Array.< or Object.< is flagged as a style nit."""
   error = self.checker.ExtraDotInGenericCheck(1, line)
   self.assertNotEqual('', error)
   self.assertTrue(test_util.GetHighlight(line, error).endswith(".<"))
Ejemplo n.º 14
0
 def ShouldFailEndJsDocCommentCheck(self, line):
   """Checks that the **/ checker flags |line| as a style error."""
   error = self.checker.EndJsDocCommentCheck(1, line)
   self.assertNotEqual('', error,
       'Should be flagged as style error: ' + line)
   self.assertEqual(test_util.GetHighlight(line, error), '**/')
Ejemplo n.º 15
0
 def ShouldFailChromeSendCheck(self, line):
   """Checks that the "chrome.send" checker flags |line| as a style error."""
   error = self.checker.ChromeSendCheck(1, line)
   self.assertNotEqual("", error, "Should be flagged as style error: " + line)
   self.assertEqual(test_util.GetHighlight(line, error), ", []")
Ejemplo n.º 16
0
 def ShouldFailBindThisCheck(self, line):
   error = self.checker.BindThisCheck(1, line)
   self.assertNotEqual("", error, "Should be flagged as style error: " + line)
   highlight = test_util.GetHighlight(line, error).strip()
   self.assertTrue(highlight.startswith(".bind(this"))
Ejemplo n.º 17
0
 def ShouldFailDeprecatedMojoBindingCheck(self, line):
     error = self.checker.DeprecatedMojoBindingsCheck(1, line)
     self.assertNotEqual('', error, 'Should be flagged as error: ' + line)
     self.assertEquals('mojo_bindings.js',
                       test_util.GetHighlight(line, error))
Ejemplo n.º 18
0
 def ShouldFailDisallowIncludeCheck(self, line):
     error = self.checker.DisallowIncludeCheck('msg', 1, line)
     self.assertNotEqual('', error, 'Should be flagged as error: ' + line)
     self.assertEquals('<include', test_util.GetHighlight(line, error))