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

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

Issue 469213009: Fix in compiler pass: cr.define() can export variable without assigned value (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@true_master
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
« 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 b8db07d9b2f19f9d739cb76339ca3cd6f1c3c900..267b509d86167789cb7ce35fc23451e572b94a35 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
@@ -76,7 +76,7 @@ public class ChromePassTest extends CompilerTestCase {
"});");
}
- public void testCrDefineReassignsExportedFunctionByQualifiedName() throws Exception {
+ public void testCrDefineReassignsExportedVarByQualifiedName() throws Exception {
test(
"cr.define('namespace', function() {\n" +
" var internalStaticMethod = function() {\n" +
@@ -97,6 +97,42 @@ public class ChromePassTest extends CompilerTestCase {
"});");
}
+ public void testCrDefineExportsVarsWithoutAssignment() throws Exception {
+ test(
+ "cr.define('namespace', function() {\n" +
+ " var a;" +
+ " return {\n" +
+ " a: a\n" +
+ " };\n" +
+ "});\n",
Tyler Breisacher (Chromium) 2014/08/18 16:51:00 You're already using Guava elsewhere so you should
Dan Beam 2014/08/19 21:14:19 where are we using Guava? could we avoid adding n
Tyler Breisacher (Chromium) 2014/08/19 21:19:47 https://code.google.com/p/chromium/codesearch#chro
Dan Beam 2014/08/19 21:42:09 i assume that works because of: https://code.googl
+ "var namespace = namespace || {};\n" +
+ "cr.define('namespace', function() {\n" +
+ " namespace.a;\n" +
+ " return {\n" +
+ " a: namespace.a\n" +
+ " };\n" +
+ "});\n");
+ }
+
+ public void testCrDefineExportsVarsWithoutAssignmentWithJSDoc() throws Exception {
+ test(
+ "cr.define('namespace', function() {\n" +
+ " /** @type {number} */\n" +
+ " var a;" +
Dan Beam 2014/08/18 18:36:46 so is this only change from a => namespace.a in th
Dan Beam 2014/08/18 18:57:45 said in another way cr.define('ui', function()
+ " return {\n" +
+ " a: a\n" +
+ " };\n" +
+ "});\n",
+ "var namespace = namespace || {};\n" +
+ "cr.define('namespace', function() {\n" +
+ " /** @type {number} */\n" +
+ " namespace.a;\n" +
+ " return {\n" +
+ " a: namespace.a\n" +
+ " };\n" +
+ "});\n");
+ }
+
public void testCrDefineCopiesJSDocForExportedVariable() throws Exception {
test(
"cr.define('namespace', function() {\n" +
« 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