OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package com.google.javascript.jscomp; | 5 package com.google.javascript.jscomp; |
6 | 6 |
7 /** | 7 /** |
8 * Tests {@link ChromePass}. | 8 * Tests {@link ChromePass}. |
9 */ | 9 */ |
10 public class ChromePassTest extends CompilerTestCase { | 10 public class ChromePassTest extends CompilerTestCase { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 " /** I'm function's JSDoc */\n" + | 69 " /** I'm function's JSDoc */\n" + |
70 " namespace.externalStaticMethod = function internalStaticMethod() {\n" + | 70 " namespace.externalStaticMethod = function internalStaticMethod() {\n" + |
71 " alert(42);\n" + | 71 " alert(42);\n" + |
72 " }\n" + | 72 " }\n" + |
73 " return {\n" + | 73 " return {\n" + |
74 " externalStaticMethod: namespace.externalStaticMethod\n" + | 74 " externalStaticMethod: namespace.externalStaticMethod\n" + |
75 " };\n" + | 75 " };\n" + |
76 "});"); | 76 "});"); |
77 } | 77 } |
78 | 78 |
79 public void testCrDefineReassignsExportedFunctionByQualifiedName() throws Ex ception { | 79 public void testCrDefineReassignsExportedVarByQualifiedName() throws Excepti on { |
80 test( | 80 test( |
81 "cr.define('namespace', function() {\n" + | 81 "cr.define('namespace', function() {\n" + |
82 " var internalStaticMethod = function() {\n" + | 82 " var internalStaticMethod = function() {\n" + |
83 " alert(42);\n" + | 83 " alert(42);\n" + |
84 " }\n" + | 84 " }\n" + |
85 " return {\n" + | 85 " return {\n" + |
86 " externalStaticMethod: internalStaticMethod\n" + | 86 " externalStaticMethod: internalStaticMethod\n" + |
87 " };\n" + | 87 " };\n" + |
88 "});", | 88 "});", |
89 "var namespace = namespace || {};\n" + | 89 "var namespace = namespace || {};\n" + |
90 "cr.define('namespace', function() {\n" + | 90 "cr.define('namespace', function() {\n" + |
91 " namespace.externalStaticMethod = function() {\n" + | 91 " namespace.externalStaticMethod = function() {\n" + |
92 " alert(42);\n" + | 92 " alert(42);\n" + |
93 " }\n" + | 93 " }\n" + |
94 " return {\n" + | 94 " return {\n" + |
95 " externalStaticMethod: namespace.externalStaticMethod\n" + | 95 " externalStaticMethod: namespace.externalStaticMethod\n" + |
96 " };\n" + | 96 " };\n" + |
97 "});"); | 97 "});"); |
98 } | 98 } |
99 | 99 |
100 public void testCrDefineExportsVarsWithoutAssignment() throws Exception { | |
101 test( | |
102 "cr.define('namespace', function() {\n" + | |
103 " var a;" + | |
104 " return {\n" + | |
105 " a: a\n" + | |
106 " };\n" + | |
107 "});\n", | |
Tyler Breisacher (Chromium)
2014/08/18 16:51:00
You're already using Guava elsewhere so you should
Dan Beam
2014/08/19 21:14:19
where are we using Guava? could we avoid adding n
Tyler Breisacher (Chromium)
2014/08/19 21:19:47
https://code.google.com/p/chromium/codesearch#chro
Dan Beam
2014/08/19 21:42:09
i assume that works because of:
https://code.googl
| |
108 "var namespace = namespace || {};\n" + | |
109 "cr.define('namespace', function() {\n" + | |
110 " namespace.a;\n" + | |
111 " return {\n" + | |
112 " a: namespace.a\n" + | |
113 " };\n" + | |
114 "});\n"); | |
115 } | |
116 | |
117 public void testCrDefineExportsVarsWithoutAssignmentWithJSDoc() throws Excep tion { | |
118 test( | |
119 "cr.define('namespace', function() {\n" + | |
120 " /** @type {number} */\n" + | |
121 " var a;" + | |
Dan Beam
2014/08/18 18:36:46
so is this only change from a => namespace.a in th
Dan Beam
2014/08/18 18:57:45
said in another way
cr.define('ui', function()
| |
122 " return {\n" + | |
123 " a: a\n" + | |
124 " };\n" + | |
125 "});\n", | |
126 "var namespace = namespace || {};\n" + | |
127 "cr.define('namespace', function() {\n" + | |
128 " /** @type {number} */\n" + | |
129 " namespace.a;\n" + | |
130 " return {\n" + | |
131 " a: namespace.a\n" + | |
132 " };\n" + | |
133 "});\n"); | |
134 } | |
135 | |
100 public void testCrDefineCopiesJSDocForExportedVariable() throws Exception { | 136 public void testCrDefineCopiesJSDocForExportedVariable() throws Exception { |
101 test( | 137 test( |
102 "cr.define('namespace', function() {\n" + | 138 "cr.define('namespace', function() {\n" + |
103 " /** I'm function's JSDoc */\n" + | 139 " /** I'm function's JSDoc */\n" + |
104 " var internalStaticMethod = function() {\n" + | 140 " var internalStaticMethod = function() {\n" + |
105 " alert(42);\n" + | 141 " alert(42);\n" + |
106 " }\n" + | 142 " }\n" + |
107 " return {\n" + | 143 " return {\n" + |
108 " externalStaticMethod: internalStaticMethod\n" + | 144 " externalStaticMethod: internalStaticMethod\n" + |
109 " };\n" + | 145 " };\n" + |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 "cr.define('cr.ui', function() {\n" + | 338 "cr.define('cr.ui', function() {\n" + |
303 " return {};\n" + | 339 " return {};\n" + |
304 "});"); | 340 "});"); |
305 } | 341 } |
306 | 342 |
307 public void testCrExportPathInvalidNumberOfArguments() throws Exception { | 343 public void testCrExportPathInvalidNumberOfArguments() throws Exception { |
308 test("cr.exportPath();", null, ChromePass.CR_EXPORT_PATH_WRONG_NUMBER_OF _ARGUMENTS); | 344 test("cr.exportPath();", null, ChromePass.CR_EXPORT_PATH_WRONG_NUMBER_OF _ARGUMENTS); |
309 } | 345 } |
310 | 346 |
311 } | 347 } |
OLD | NEW |