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

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

Issue 421253006: Add ChromeCodingConvention.java to Closure Compiler to preserve getInstance() type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@A_typechecking_about
Patch Set: rebase onto master Created 6 years, 4 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import unittest
7
8 from checker import Checker, FileCache
9
10
11 class CodingConventionTest(unittest.TestCase):
12 def setUp(self):
13 self._checker = Checker(verbose=False)
14
15 def testGetInstance(self):
16 file_content = """
17 var cr = {
18 /** @param {!Function} ctor */
19 addSingletonGetter: function(ctor) {
20 ctor.getInstance = function() {
21 return ctor.instance_ || (ctor.instance_ = new ctor());
22 };
23 }
24 };
25
26 /** @constructor */
27 function Class() {
28 /** @param {number} num */
29 this.needsNumber = function(num) {};
30 }
31
32 cr.addSingletonGetter(Class);
33 Class.getInstance().needsNumber("wrong type");
34 """
35 expected_chunk = "ERROR - actual parameter 1 of Class.needsNumber does not m atch formal parameter"
36
37 file_path = "/script.js"
38 FileCache._cache[file_path] = file_content
39 _, output = self._checker.check(file_path)
40
41 self.assertTrue(expected_chunk in output,
42 msg="%s\n\nExpected chunk: \n%s\n\nOutput:\n%s\n" % (
43 "getInstance", expected_chunk, output))
44
45
46 if __name__ == "__main__":
47 unittest.main()
OLDNEW
« no previous file with comments | « third_party/closure_compiler/checker.py ('k') | third_party/closure_compiler/compile_modules.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698