Пример #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] == '<')
Пример #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")))
Пример #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))
Пример #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))
Пример #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')))
Пример #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')
Пример #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);
Пример #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'))
Пример #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')
Пример #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")
Пример #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()
Пример #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), ', []')
Пример #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(".<"))
Пример #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), '**/')
Пример #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), ", []")
Пример #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"))
Пример #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))
Пример #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))