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

Side by Side Diff: third_party/closure_compiler/compiler_customization_test.py

Issue 1023253003: Revert of Python readability review for dbeam@. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 5 years, 9 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 | « third_party/closure_compiler/compile_js.gypi ('k') | third_party/closure_compiler/processor.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 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 import os 6 import os
7 import unittest 7 import unittest
8 8
9 from checker import Checker 9 from checker import Checker
10 from processor import FileCache, Processor 10 from processor import FileCache, Processor
(...skipping 18 matching lines...) Expand all
29 29
30 def setUp(self): 30 def setUp(self):
31 self._checker = Checker() 31 self._checker = Checker()
32 32
33 def _runChecker(self, source_code): 33 def _runChecker(self, source_code):
34 file_path = "/script.js" 34 file_path = "/script.js"
35 FileCache._cache[file_path] = source_code 35 FileCache._cache[file_path] = source_code
36 return self._checker.check(file_path) 36 return self._checker.check(file_path)
37 37
38 def _runCheckerTestExpectError(self, source_code, expected_error): 38 def _runCheckerTestExpectError(self, source_code, expected_error):
39 _, stderr = self._runChecker(source_code) 39 _, output = self._runChecker(source_code)
40 40
41 self.assertTrue(expected_error in stderr, 41 self.assertTrue(expected_error in output,
42 msg="Expected chunk: \n%s\n\nOutput:\n%s\n" % ( 42 msg="Expected chunk: \n%s\n\nOutput:\n%s\n" % (
43 expected_error, stderr)) 43 expected_error, output))
44 44
45 def _runCheckerTestExpectSuccess(self, source_code): 45 def _runCheckerTestExpectSuccess(self, source_code):
46 found_errors, stderr = self._runChecker(source_code) 46 return_code, output = self._runChecker(source_code)
47 47
48 self.assertFalse(found_errors, 48 self.assertTrue(return_code == 0,
49 msg="Expected success, but got failure\n\nOutput:\n%s\n" % stderr) 49 msg="Expected success, got return code %d\n\nOutput:\n%s\n" % (
50 return_code, output))
50 51
51 def testGetInstance(self): 52 def testGetInstance(self):
52 self._runCheckerTestExpectError(""" 53 self._runCheckerTestExpectError("""
53 var cr = { 54 var cr = {
54 /** @param {!Function} ctor */ 55 /** @param {!Function} ctor */
55 addSingletonGetter: function(ctor) { 56 addSingletonGetter: function(ctor) {
56 ctor.getInstance = function() { 57 ctor.getInstance = function() {
57 return ctor.instance_ || (ctor.instance_ = new ctor()); 58 return ctor.instance_ || (ctor.instance_ = new ctor());
58 }; 59 };
59 } 60 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 function f() { 233 function f() {
233 var a = document.createElement('div'); 234 var a = document.createElement('div');
234 cr.ui.decorate(a, Class); 235 cr.ui.decorate(a, Class);
235 return a; 236 return a;
236 } 237 }
237 """) 238 """)
238 239
239 240
240 if __name__ == "__main__": 241 if __name__ == "__main__":
241 unittest.main() 242 unittest.main()
OLDNEW
« no previous file with comments | « third_party/closure_compiler/compile_js.gypi ('k') | third_party/closure_compiler/processor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698