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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 " };\n" + | 200 " };\n" + |
201 "});\n", | 201 "});\n", |
202 "var namespace = namespace || {};\n" + | 202 "var namespace = namespace || {};\n" + |
203 "cr.define('namespace', function() {\n" + | 203 "cr.define('namespace', function() {\n" + |
204 " return {\n" + | 204 " return {\n" + |
205 " a: 42\n" + | 205 " a: 42\n" + |
206 " };\n" + | 206 " };\n" + |
207 "});\n"); | 207 "});\n"); |
208 } | 208 } |
209 | 209 |
210 public void testCrDefineDoesNothingWithExportedNotAName() throws Exception { | |
Dan Beam
2014/10/31 22:19:30
duplicated
| |
211 test( | |
212 "cr.define('namespace', function() {\n" + | |
213 " return {\n" + | |
214 " a: 42\n" + | |
215 " };\n" + | |
216 "});\n", | |
217 "var namespace = namespace || {};\n" + | |
218 "cr.define('namespace', function() {\n" + | |
219 " return {\n" + | |
220 " a: 42\n" + | |
221 " };\n" + | |
222 "});\n"); | |
223 } | |
224 | |
225 public void testCrDefineChangesReferenceToExportedFunction() throws Exceptio n { | 210 public void testCrDefineChangesReferenceToExportedFunction() throws Exceptio n { |
226 test( | 211 test( |
227 "cr.define('namespace', function() {\n" + | 212 "cr.define('namespace', function() {\n" + |
228 " function internalStaticMethod() {\n" + | 213 " function internalStaticMethod() {\n" + |
229 " alert(42);\n" + | 214 " alert(42);\n" + |
230 " }\n" + | 215 " }\n" + |
231 " function letsUseIt() {\n" + | 216 " function letsUseIt() {\n" + |
232 " internalStaticMethod();\n" + | 217 " internalStaticMethod();\n" + |
233 " }\n" + | 218 " }\n" + |
234 " return {\n" + | 219 " return {\n" + |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 ChromePass.CR_MAKE_PUBLIC_INVALID_SECOND_ARGUMENT); | 534 ChromePass.CR_MAKE_PUBLIC_INVALID_SECOND_ARGUMENT); |
550 } | 535 } |
551 | 536 |
552 public void testCrMakePublicReportsInvalidSecondArgumentArrayWithNotAString( ) throws Exception { | 537 public void testCrMakePublicReportsInvalidSecondArgumentArrayWithNotAString( ) throws Exception { |
553 test( | 538 test( |
554 "cr.makePublic(Class, [42]);", null, | 539 "cr.makePublic(Class, [42]);", null, |
555 ChromePass.CR_MAKE_PUBLIC_INVALID_SECOND_ARGUMENT); | 540 ChromePass.CR_MAKE_PUBLIC_INVALID_SECOND_ARGUMENT); |
556 } | 541 } |
557 | 542 |
558 } | 543 } |
OLD | NEW |