Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: chrome/browser/resources/test_presubmit.py

Issue 251713002: web_dev_style: add check for ending jsdoc comments with **/ instead of */. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upstream => master Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/web_dev_style/js_checker.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for Web Development Style Guide checker.""" 6 """Unit tests for Web Development Style Guide checker."""
7 7
8 import os 8 import os
9 import re 9 import re
10 import sys 10 import sys
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 def testChromeSendPasses(self): 120 def testChromeSendPasses(self):
121 lines = [ 121 lines = [
122 "chrome.send('message', constructArgs('foo', []));", 122 "chrome.send('message', constructArgs('foo', []));",
123 " chrome.send('message', constructArgs('foo', []));", 123 " chrome.send('message', constructArgs('foo', []));",
124 "chrome.send('message', constructArgs([]));", 124 "chrome.send('message', constructArgs([]));",
125 " chrome.send('message', constructArgs([]));", 125 " chrome.send('message', constructArgs([]));",
126 ] 126 ]
127 for line in lines: 127 for line in lines:
128 self.ShouldPassChromeSendCheck(line) 128 self.ShouldPassChromeSendCheck(line)
129 129
130 def ShouldFailEndJsDocCommentCheck(self, line):
131 """Checks that the **/ checker flags |line| as a style error."""
132 error = self.checker.EndJsDocCommentCheck(1, line)
133 self.assertNotEqual('', error,
134 'Should be flagged as style error: ' + line)
135 self.assertEqual(self.GetHighlight(line, error), '**/')
136
137 def ShouldPassEndJsDocCommentCheck(self, line):
138 """Checks that the **/ checker doesn't flag |line| as a style error."""
139 self.assertEqual('', self.checker.EndJsDocCommentCheck(1, line),
140 'Should not be flagged as style error: ' + line)
141
142 def testEndJsDocCommentFails(self):
143 lines = [
144 "/** @override **/",
145 "/** @type {number} @const **/",
146 " **/",
147 "**/ ",
148 ]
149 for line in lines:
150 self.ShouldFailEndJsDocCommentCheck(line)
151
152 def testEndJsDocCommentPasses(self):
153 lines = [
154 "/***************/", # visual separators
155 " */", # valid JSDoc comment ends
156 "*/ ",
157 "/**/", # funky multi-line comment enders
158 "/** @override */", # legit JSDoc one-liners
159 ]
160 for line in lines:
161 self.ShouldPassEndJsDocCommentCheck(line)
162
130 def ShouldFailGetElementByIdCheck(self, line): 163 def ShouldFailGetElementByIdCheck(self, line):
131 """Checks that the 'getElementById' checker flags |line| as a style 164 """Checks that the 'getElementById' checker flags |line| as a style
132 error. 165 error.
133 """ 166 """
134 error = self.checker.GetElementByIdCheck(1, line) 167 error = self.checker.GetElementByIdCheck(1, line)
135 self.assertNotEqual('', error, 168 self.assertNotEqual('', error,
136 'Should be flagged as style error: ' + line) 169 'Should be flagged as style error: ' + line)
137 self.assertEqual(self.GetHighlight(line, error), 'document.getElementById') 170 self.assertEqual(self.GetHighlight(line, error), 'document.getElementById')
138 171
139 def ShouldPassGetElementByIdCheck(self, line): 172 def ShouldPassGetElementByIdCheck(self, line):
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 opacity: .0; 657 opacity: .0;
625 opacity: 0.0; 658 opacity: 0.0;
626 opacity: 0.; 659 opacity: 0.;
627 border-width: 0mm; 660 border-width: 0mm;
628 height: 0cm; 661 height: 0cm;
629 width: 0in; 662 width: 0in;
630 """) 663 """)
631 664
632 if __name__ == '__main__': 665 if __name__ == '__main__':
633 unittest.main() 666 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/web_dev_style/js_checker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698