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

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: 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8cef6953e4507f0c1c04e02cda78225b5f90afcc..62624947774bc94aec35aea3032110261e659768 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
@@ -235,4 +235,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 {
+ 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);
+ }
+
}
« 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