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

Side by Side Diff: third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java

Issue 453783006: Handle cr.exportPath() in compiler pass, declare every object only once (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@C_define_property
Patch Set: 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
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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 "a.b.c;"); 219 "a.b.c;");
220 } 220 }
221 221
222 public void testCrDefinePropertyInvalidPropertyKind() 222 public void testCrDefinePropertyInvalidPropertyKind()
223 throws Exception { 223 throws Exception {
224 test( 224 test(
225 "cr.defineProperty(a.b, 'c', cr.PropertyKind.INEXISTENT_KIND);", 225 "cr.defineProperty(a.b, 'c', cr.PropertyKind.INEXISTENT_KIND);",
226 null, ChromePass.CR_DEFINE_PROPERTY_INVALID_PROPERTY_KIND); 226 null, ChromePass.CR_DEFINE_PROPERTY_INVALID_PROPERTY_KIND);
227 } 227 }
228 228
229 public void testCrExportPath() throws Exception {
230 test(
231 "cr.exportPath('a.b.c');",
232 "var a = a || {};\n" +
233 "a.b = a.b || {};\n" +
234 "a.b.c = a.b.c || {};\n" +
235 "cr.exportPath('a.b.c');");
236 }
237
238 public void testCrDefineCreatesEveryObjectOnlyOnce() throws Exception {
239 test(
240 "cr.define('a.b.c.d', function() {\n" +
241 " return {};\n" +
242 "});" +
243 "cr.define('a.b.e.f', function() {\n" +
244 " return {};\n" +
245 "});",
246 "var a = a || {};\n" +
247 "a.b = a.b || {};\n" +
248 "a.b.c = a.b.c || {};\n" +
249 "a.b.c.d = a.b.c.d || {};\n" +
250 "cr.define('a.b.c.d', function() {\n" +
251 " return {};\n" +
252 "});" +
253 "a.b.e = a.b.e || {};\n" +
254 "a.b.e.f = a.b.e.f || {};\n" +
255 "cr.define('a.b.e.f', function() {\n" +
256 " return {};\n" +
257 "});");
258 }
259
260 public void testCrDefineAndCrExportPathCreateEveryObjectOnlyOnce() throws Ex ception {
Dan Beam 2014/08/14 02:23:02 Creates
Vitaly Pavlenko 2014/08/14 02:40:59 CrDefine and CrExportPath, so they Create.
261 test(
262 "cr.exportPath('a.b.c.d');\n" +
263 "cr.define('a.b.e.f', function() {\n" +
264 " return {};\n" +
265 "});",
266 "var a = a || {};\n" +
267 "a.b = a.b || {};\n" +
268 "a.b.c = a.b.c || {};\n" +
269 "a.b.c.d = a.b.c.d || {};\n" +
270 "cr.exportPath('a.b.c.d');\n" +
271 "a.b.e = a.b.e || {};\n" +
272 "a.b.e.f = a.b.e.f || {};\n" +
273 "cr.define('a.b.e.f', function() {\n" +
274 " return {};\n" +
275 "});");
276 }
277
278 public void testCrDefineDoesntRedefineCrVar() throws Exception {
279 test(
280 "cr.define('cr.ui', function() {\n" +
281 " return {};\n" +
282 "});",
283 "cr.ui = cr.ui || {};\n" +
284 "cr.define('cr.ui', function() {\n" +
285 " return {};\n" +
286 "});");
287 }
288
289 public void testCrExportPathInvalidNumberOfArguments() throws Exception {
290 test("cr.exportPath();", null, ChromePass.CR_EXPORT_PATH_WRONG_NUMBER_OF _ARGUMENTS);
291 }
292
229 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698