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

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: final final final final 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 __init__(self, *args, **kwargs):
13 unittest.TestCase.__init__(self, *args, **kwargs)
Dan Beam 2014/07/30 00:40:53 ^ this __init__ method is the same as not having t
Vitaly Pavlenko 2014/07/30 17:01:41 Done.
14
15 def setUp(self):
16 self._checker = Checker(verbose=False)
17
18 def testGetInstance(self):
19 file_content = """
20 var cr = {
21 /** @param {!Function} ctor */
22 addSingletonGetter: function(ctor) {
23 ctor.getInstance = function() {
24 return ctor.instance_ || (ctor.instance_ = new ctor());
25 };
26 }
27 };
28
29 /** @constructor */
30 function Class() {
31 /** @param {number} num */
32 this.needsNumber = function(num) {};
33 }
34
35 cr.addSingletonGetter(Class);
36 Class.getInstance().needsNumber("wrong type");
37 """
38 expected_chunk = "WARNING - actual parameter 1 of Class.needsNumber does not match formal parameter"
39
40 file_path = "/script.js"
41 FileCache._cache[file_path] = file_content
42 _, output = self._checker.check(file_path)
43
44 self.assertTrue(expected_chunk in output,
45 msg="%s\n\nExpected chunk: \n%s\n\nOutput:\n%s\n" % (
46 "getInstance", expected_chunk, output))
47
48
49 if __name__ == "__main__":
50 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