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

Unified Diff: third_party/closure_linter/closure_linter/trailing_comma_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/trailing_comma_test.py
diff --git a/third_party/closure_linter/closure_linter/strict_test.py b/third_party/closure_linter/closure_linter/trailing_comma_test.py
similarity index 61%
copy from third_party/closure_linter/closure_linter/strict_test.py
copy to third_party/closure_linter/closure_linter/trailing_comma_test.py
index 75044e8a20bc33671fd529cae8a3b7b02695b66d..ddac3045d9eb4b2beb0b921f70f9e2871384c328 100644
--- a/third_party/closure_linter/closure_linter/strict_test.py
+++ b/third_party/closure_linter/closure_linter/trailing_comma_test.py
@@ -13,15 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Tests for gjslint --strict.
-
-Tests errors that can be thrown by gjslint when in strict mode.
"""
+Tests for trailing commas (ES3) errors
+"""
-import unittest
-
import gflags as flags
import unittest as googletest
@@ -29,29 +26,31 @@ from closure_linter import errors
from closure_linter import runner
from closure_linter.common import erroraccumulator
-flags.FLAGS.strict = True
+flags.FLAGS.check_trailing_comma = True
+class TrailingCommaTest(googletest.TestCase):
+ """Test case to for gjslint errorrules."""
+ def testGetTrailingCommaArray(self):
+ """ warning for trailing commas before closing array
+ """
+ original = ['q = [1,]', ]
-class StrictTest(unittest.TestCase):
- """Tests scenarios where strict generates warnings."""
+ # Expect line too long.
+ expected = errors.COMMA_AT_END_OF_LITERAL
- def testUnclosedString(self):
- """Tests warnings are reported when nothing is disabled.
+ self._AssertInError(original, expected)
- b/11450054.
+ def testGetTrailingCommaDict(self):
+ """ warning for trailing commas before closing array
"""
- original = [
- 'bug = function() {',
- ' (\'foo\'\');',
- '};',
- '',
- ]
-
- expected = [errors.FILE_DOES_NOT_PARSE, errors.MULTI_LINE_STRING,
- errors.FILE_IN_BLOCK]
- self._AssertErrors(original, expected)
-
- def _AssertErrors(self, original, expected_errors):
+ original = ['q = {1:1,}', ]
+
+ # Expect line too long.
+ expected = errors.COMMA_AT_END_OF_LITERAL
+
+ self._AssertInError(original, expected)
+
+ def _AssertInError(self, original, expected):
"""Asserts that the error fixer corrects original to expected."""
# Trap gjslint's output parse it to get messages added.
@@ -59,10 +58,7 @@ class StrictTest(unittest.TestCase):
runner.Run('testing.js', error_accumulator, source=original)
error_nums = [e.code for e in error_accumulator.GetErrors()]
- error_nums.sort()
- expected_errors.sort()
- self.assertListEqual(error_nums, expected_errors)
+ self.assertIn(expected, error_nums)
if __name__ == '__main__':
googletest.main()
-

Powered by Google App Engine
This is Rietveld 408576698