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

Unified Diff: compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java

Issue 10139017: Support for same prefix for multiple imports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Detect top-level duplicates in libraries with same prefix Created 8 years, 8 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: compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java
diff --git a/compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java b/compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java
index e20a8d8653894375ebba6e5763069179baed3cac..1ed5b92975bb9bcbf64be139ca9725c8b7088fe0 100644
--- a/compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java
+++ b/compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java
@@ -559,6 +559,78 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
}
/**
+ * Test that same prefix can be used to import several libraries.
+ */
+ public void test_samePrefix_severalLibraries() throws Exception {
+ appSource.setContent(
+ APP,
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler filler",
+ "#library('application');",
+ "#import('A.dart', prefix: 'p');",
+ "#import('B.dart', prefix: 'p');",
+ "f() {",
+ " p.a = 1;",
+ " p.b = 2;",
+ "}",
+ ""));
+ appSource.setContent(
+ "A.dart",
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler filler",
+ "#library('A');",
+ "var a;",
+ ""));
+ appSource.setContent(
+ "B.dart",
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler filler",
+ "#library('B');",
+ "var b;",
+ ""));
+ // do compile, no errors expected
+ compile();
+ assertErrors(errors);
+ }
+
+ /**
+ * Test that when same prefix is used to import several libraries, we still report error for
+ * duplicate names.
+ */
+ public void test_samePrefix_severalLibraries_duplicateTopLevelNames() throws Exception {
+ appSource.setContent(
+ APP,
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler filler",
+ "#library('application');",
+ "#import('A.dart', prefix: 'p');",
+ "#import('B.dart', prefix: 'p');",
+// "#import('A.dart');",
+// "#import('B.dart');",
+ ""));
+ appSource.setContent(
+ "A.dart",
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler filler",
+ "#library('A');",
+ "var someVar;",
+ ""));
+ appSource.setContent(
+ "B.dart",
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler filler",
+ "#library('B');",
+ "var someVar;",
+ ""));
+ // do compile
+ compile();
+ assertErrors(
+ errors,
+ errEx("A.dart", ResolverErrorCode.DUPLICATE_TOP_LEVEL_DECLARATION, 3, 5, 7),
+ errEx("B.dart", ResolverErrorCode.DUPLICATE_TOP_LEVEL_DECLARATION, 3, 5, 7));
+ }
+
+ /**
* Test that invalid "#source" is reported as any other error between "unitAboutToCompile" and
* "unitCompiled".
*/

Powered by Google App Engine
This is Rietveld 408576698