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

Unified Diff: third_party/closure_linter/closure_linter/error_fixer_test.py

Issue 2328693002: Updated linter with upstream release (2.3.19) (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/closure_linter/closure_linter/error_fixer_test.py
diff --git a/third_party/closure_linter/closure_linter/error_fixer_test.py b/third_party/closure_linter/closure_linter/error_fixer_test.py
index 49f449de42f36f25579e894e35f9254aa95502ce..0deeb3bc2506444e866830ad6469bdb8810d8ebc 100644
--- a/third_party/closure_linter/closure_linter/error_fixer_test.py
+++ b/third_party/closure_linter/closure_linter/error_fixer_test.py
@@ -23,6 +23,7 @@
import unittest as googletest
from closure_linter import error_fixer
from closure_linter import testutil
+from closure_linter import tokenutil
class ErrorFixerTest(googletest.TestCase):
@@ -49,6 +50,25 @@ class ErrorFixerTest(googletest.TestCase):
self.assertEqual(fourth_token, self.error_fixer._file_token)
+ def DoTestFixJsDocPipeNull(self, expected, original):
+ _, comments = testutil.ParseFunctionsAndComments(
+ '/** @param {%s} */' % original)
+ jstype = comments[0].GetDocFlags()[0].jstype
+ self.error_fixer.HandleFile('unittest', None)
+ self.error_fixer._FixJsDocPipeNull(jstype)
+ self.assertEquals(expected, repr(jstype))
+ result = tokenutil.TokensToString(jstype.FirstToken()).strip('} */')
+ self.assertEquals(expected, result)
+
+ def testFixJsDocPipeNull(self):
+ self.DoTestFixJsDocPipeNull('?Object', 'Object|null')
+ self.DoTestFixJsDocPipeNull('function(?Object)', 'function(Object|null)')
+ self.DoTestFixJsDocPipeNull('function(?Object=)',
+ 'function(Object|null=)')
+ self.DoTestFixJsDocPipeNull(
+ 'function(?(Object)=,null=,?(Object)=):string',
+ 'function((Object|null)=,null=,(Object|null)=):string')
+
_TEST_SCRIPT = """\
var x = 3;
"""

Powered by Google App Engine
This is Rietveld 408576698