diff options
author | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 02:50:45 +0000 |
---|---|---|
committer | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 02:50:45 +0000 |
commit | c4991f239998abe4a577be06c4419666c85556cd (patch) | |
tree | 33cff918c80bc3333f095886a4d0ca0981cd9e94 /chrome/browser/resources/test_presubmit.py | |
parent | 3024571e695e2da3e3caaed51302806b93c8973d (diff) | |
download | chromium_src-c4991f239998abe4a577be06c4419666c85556cd.zip chromium_src-c4991f239998abe4a577be06c4419666c85556cd.tar.gz chromium_src-c4991f239998abe4a577be06c4419666c85556cd.tar.bz2 |
[web_dev_style] (Boolean|Number|String) -> (boolean|number|string) and add
presubmit check.
BUG=113202
TEST=chrome/browser/resources/test_presubmit.py
Review URL: https://codereview.chromium.org/11628003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/test_presubmit.py')
-rwxr-xr-x | chrome/browser/resources/test_presubmit.py | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/chrome/browser/resources/test_presubmit.py b/chrome/browser/resources/test_presubmit.py index 610c8751..10e4292d 100755 --- a/chrome/browser/resources/test_presubmit.py +++ b/chrome/browser/resources/test_presubmit.py @@ -173,7 +173,7 @@ class JsStyleGuideTest(SuperMoxTestBase): """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) + msg='Should be flagged as style error: ' + line) self.assertEqual(self.GetHighlight(line, error), '@inheritDoc') def ShouldPassInheritDocCheck(self, line): @@ -181,12 +181,12 @@ class JsStyleGuideTest(SuperMoxTestBase): error. """ self.assertEqual('', self.checker.InheritDocCheck(1, line), - 'Should not be flagged as style error: ' + line) + msg='Should not be flagged as style error: ' + line) def testInheritDocFails(self): lines = [ - "/** @inheritDoc */", - "* @inheritDoc", + " /** @inheritDoc */", + " * @inheritDoc", ] for line in lines: self.ShouldFailInheritDocCheck(line) @@ -194,13 +194,57 @@ class JsStyleGuideTest(SuperMoxTestBase): def testInheritDocPasses(self): lines = [ "And then I said, but I won't @inheritDoc! Hahaha!", - "If your dad's a doctor, do you inheritDoc?", - "What's up, inherit doc?", - "this.inheritDoc(someDoc)", + " If your dad's a doctor, do you inheritDoc?", + " What's up, inherit doc?", + " this.inheritDoc(someDoc)", ] for line in lines: self.ShouldPassInheritDocCheck(line) + 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 = self.GetHighlight(line, error) + self.assertTrue(highlight in ('Boolean', 'Number', 'String')) + + def ShouldPassWrapperTypeCheck(self, line): + """Checks that the wrapper type checker doesn't flag |line| as a style + error. + """ + self.assertEqual('', self.checker.WrapperTypeCheck(1, line), + msg='Should not be flagged as style error: ' + line) + + def testWrapperTypePasses(self): + lines = [ + "/** @param {!ComplexType} */", + " * @type {Object}", + " * @param {Function=} opt_callback", + " * @param {} num Number of things to add to {blah}.", + " * @return {!print_preview.PageNumberSet}", + " /* @returns {Number} */", # Should be /** @return {Number} */ + "* @param {!LocalStrings}" + " Your type of Boolean is false!", + " Then I parameterized her Number from her friend!", + " A String of Pearls", + " types.params.aBoolean.typeString(someNumber)", + ] + for line in lines: + self.ShouldPassWrapperTypeCheck(line) + + def testWrapperTypeFails(self): + lines = [ + " /**@type {String}*/(string)", + " * @param{Number=} opt_blah A number", + "/** @private @return {!Boolean} */", + " * @param {number|String}", + ] + for line in lines: + self.ShouldFailWrapperTypeCheck(line) + class CssStyleGuideTest(SuperMoxTestBase): def setUp(self): |