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

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: rebase 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
« no previous file with comments | « third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 "a.prototype.c;"); 228 "a.prototype.c;");
229 } 229 }
230 230
231 public void testCrDefinePropertyInvalidPropertyKind() 231 public void testCrDefinePropertyInvalidPropertyKind()
232 throws Exception { 232 throws Exception {
233 test( 233 test(
234 "cr.defineProperty(a.b, 'c', cr.PropertyKind.INEXISTENT_KIND);", 234 "cr.defineProperty(a.b, 'c', cr.PropertyKind.INEXISTENT_KIND);",
235 null, ChromePass.CR_DEFINE_PROPERTY_INVALID_PROPERTY_KIND); 235 null, ChromePass.CR_DEFINE_PROPERTY_INVALID_PROPERTY_KIND);
236 } 236 }
237 237
238 public void testCrExportPath() throws Exception {
239 test(
240 "cr.exportPath('a.b.c');",
241 "var a = a || {};\n" +
242 "a.b = a.b || {};\n" +
243 "a.b.c = a.b.c || {};\n" +
244 "cr.exportPath('a.b.c');");
245 }
246
247 public void testCrDefineCreatesEveryObjectOnlyOnce() throws Exception {
248 test(
249 "cr.define('a.b.c.d', function() {\n" +
250 " return {};\n" +
251 "});" +
252 "cr.define('a.b.e.f', function() {\n" +
253 " return {};\n" +
254 "});",
255 "var a = a || {};\n" +
256 "a.b = a.b || {};\n" +
257 "a.b.c = a.b.c || {};\n" +
258 "a.b.c.d = a.b.c.d || {};\n" +
259 "cr.define('a.b.c.d', function() {\n" +
260 " return {};\n" +
261 "});" +
262 "a.b.e = a.b.e || {};\n" +
263 "a.b.e.f = a.b.e.f || {};\n" +
264 "cr.define('a.b.e.f', function() {\n" +
265 " return {};\n" +
266 "});");
267 }
268
269 public void testCrDefineAndCrExportPathCreateEveryObjectOnlyOnce() throws Ex ception {
270 test(
271 "cr.exportPath('a.b.c.d');\n" +
272 "cr.define('a.b.e.f', function() {\n" +
273 " return {};\n" +
274 "});",
275 "var a = a || {};\n" +
276 "a.b = a.b || {};\n" +
277 "a.b.c = a.b.c || {};\n" +
278 "a.b.c.d = a.b.c.d || {};\n" +
279 "cr.exportPath('a.b.c.d');\n" +
280 "a.b.e = a.b.e || {};\n" +
281 "a.b.e.f = a.b.e.f || {};\n" +
282 "cr.define('a.b.e.f', function() {\n" +
283 " return {};\n" +
284 "});");
285 }
286
287 public void testCrDefineDoesntRedefineCrVar() throws Exception {
288 test(
289 "cr.define('cr.ui', function() {\n" +
290 " return {};\n" +
291 "});",
292 "cr.ui = cr.ui || {};\n" +
293 "cr.define('cr.ui', function() {\n" +
294 " return {};\n" +
295 "});");
296 }
297
298 public void testCrExportPathInvalidNumberOfArguments() throws Exception {
299 test("cr.exportPath();", null, ChromePass.CR_EXPORT_PATH_WRONG_NUMBER_OF _ARGUMENTS);
300 }
301
238 } 302 }
OLDNEW
« no previous file with comments | « third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698