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

Unified Diff: third_party/closure_compiler/compiler_test.py

Issue 1409843002: Make Closure Compiler understand assertNotReached (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | third_party/closure_compiler/runner/runner.jar » ('j') | ui/webui/resources/js/cr/ui/table.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/closure_compiler/compiler_test.py
diff --git a/third_party/closure_compiler/compiler_test.py b/third_party/closure_compiler/compiler_test.py
index 361d88c502cb0bccb1fff8741869cc904aa86d3e..36cf163b4b8b96103420923d9a582ebbf9f1b346 100755
--- a/third_party/closure_compiler/compiler_test.py
+++ b/third_party/closure_compiler/compiler_test.py
@@ -56,8 +56,9 @@ class CompilerTest(unittest.TestCase):
closure_args=args)
return found_errors, stderr, out_file, out_map
- def _runCheckerTestExpectError(self, source_code, expected_error):
- _, stderr, out_file, out_map = self._runChecker(source_code)
+ def _runCheckerTestExpectError(self, source_code, expected_error,
+ closure_args=None):
+ _, stderr, out_file, out_map = self._runChecker(source_code, closure_args)
self.assertTrue(expected_error in stderr,
msg="Expected chunk: \n%s\n\nOutput:\n%s\n" % (
@@ -342,6 +343,31 @@ testScript();
"cr.exportPath();",
"ERROR - cr.exportPath() should have at least 1 argument: path name")
+ def testMissingReturnAssertNotReached(self):
+ template = self._ASSERT_DEFINITION + """
+/** @enum {number} */
+var Enum = {FOO: 1, BAR: 2};
+
+/**
+ * @param {Enum} e
+ * @return {number}
+ */
+function enumToVal(e) {
+ switch (e) {
+ case Enum.FOO:
+ return 1;
+ case Enum.BAR:
+ return 2;
+ }
+ %s
+}
+"""
+ args = ['warning_level=VERBOSE']
+ self._runCheckerTestExpectError(template % '', 'Missing return',
+ closure_args=args)
+ self._runCheckerTestExpectSuccess(template % 'assertNotReached();',
+ closure_args=args)
+
if __name__ == "__main__":
unittest.main()
« no previous file with comments | « no previous file | third_party/closure_compiler/runner/runner.jar » ('j') | ui/webui/resources/js/cr/ui/table.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698