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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
diff --git a/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java b/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
index 20665439617704f47a26184cf0418d5122f01902..eaeea1e751268bc587d8612450260ab3c0b02e55 100644
--- a/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
+++ b/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
@@ -226,4 +226,68 @@ public class ChromePassTest extends CompilerTestCase {
null, ChromePass.CR_DEFINE_PROPERTY_INVALID_PROPERTY_KIND);
}
+ public void testCrExportPath() throws Exception {
+ test(
+ "cr.exportPath('a.b.c');",
+ "var a = a || {};\n" +
+ "a.b = a.b || {};\n" +
+ "a.b.c = a.b.c || {};\n" +
+ "cr.exportPath('a.b.c');");
+ }
+
+ public void testCrDefineCreatesEveryObjectOnlyOnce() throws Exception {
+ test(
+ "cr.define('a.b.c.d', function() {\n" +
+ " return {};\n" +
+ "});" +
+ "cr.define('a.b.e.f', function() {\n" +
+ " return {};\n" +
+ "});",
+ "var a = a || {};\n" +
+ "a.b = a.b || {};\n" +
+ "a.b.c = a.b.c || {};\n" +
+ "a.b.c.d = a.b.c.d || {};\n" +
+ "cr.define('a.b.c.d', function() {\n" +
+ " return {};\n" +
+ "});" +
+ "a.b.e = a.b.e || {};\n" +
+ "a.b.e.f = a.b.e.f || {};\n" +
+ "cr.define('a.b.e.f', function() {\n" +
+ " return {};\n" +
+ "});");
+ }
+
+ public void testCrDefineAndCrExportPathCreateEveryObjectOnlyOnce() throws Exception {
Dan Beam 2014/08/14 02:23:02 Creates
Vitaly Pavlenko 2014/08/14 02:40:59 CrDefine and CrExportPath, so they Create.
+ test(
+ "cr.exportPath('a.b.c.d');\n" +
+ "cr.define('a.b.e.f', function() {\n" +
+ " return {};\n" +
+ "});",
+ "var a = a || {};\n" +
+ "a.b = a.b || {};\n" +
+ "a.b.c = a.b.c || {};\n" +
+ "a.b.c.d = a.b.c.d || {};\n" +
+ "cr.exportPath('a.b.c.d');\n" +
+ "a.b.e = a.b.e || {};\n" +
+ "a.b.e.f = a.b.e.f || {};\n" +
+ "cr.define('a.b.e.f', function() {\n" +
+ " return {};\n" +
+ "});");
+ }
+
+ public void testCrDefineDoesntRedefineCrVar() throws Exception {
+ test(
+ "cr.define('cr.ui', function() {\n" +
+ " return {};\n" +
+ "});",
+ "cr.ui = cr.ui || {};\n" +
+ "cr.define('cr.ui', function() {\n" +
+ " return {};\n" +
+ "});");
+ }
+
+ public void testCrExportPathInvalidNumberOfArguments() throws Exception {
+ test("cr.exportPath();", null, ChromePass.CR_EXPORT_PATH_WRONG_NUMBER_OF_ARGUMENTS);
+ }
+
}

Powered by Google App Engine
This is Rietveld 408576698