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

Unified Diff: compiler/javatests/com/google/dart/compiler/DeltaAnalyzerTest.java

Issue 11273064: Issue 5887. Parts must start with 'part of'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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/DeltaAnalyzerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/DeltaAnalyzerTest.java b/compiler/javatests/com/google/dart/compiler/DeltaAnalyzerTest.java
index 9924cc802aeeafcbbfb81052d05a7cc9ac562812..e4deb244e0c255965f04ea2124ca13ae43c7f762 100644
--- a/compiler/javatests/com/google/dart/compiler/DeltaAnalyzerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/DeltaAnalyzerTest.java
@@ -4,8 +4,10 @@
package com.google.dart.compiler;
+import com.google.common.base.Joiner;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.LibraryUnit;
+import com.google.dart.compiler.end2end.inc.MemoryLibrarySource;
import com.google.dart.compiler.resolver.ClassElement;
import com.google.dart.compiler.resolver.Element;
import com.google.dart.compiler.resolver.LibraryElement;
@@ -13,7 +15,6 @@ import com.google.dart.compiler.resolver.MethodElement;
import com.google.dart.compiler.testing.TestCompilerConfiguration;
import com.google.dart.compiler.testing.TestCompilerContext;
import com.google.dart.compiler.testing.TestDartArtifactProvider;
-import com.google.dart.compiler.testing.TestLibrarySource;
import com.google.dart.compiler.util.DartSourceString;
import junit.framework.TestCase;
@@ -26,10 +27,13 @@ public class DeltaAnalyzerTest extends TestCase {
private final DartArtifactProvider provider = new TestDartArtifactProvider();
public void testNoChangeSingleFile() throws IOException {
- TestLibrarySource librarySource = new TestLibrarySource(getName());
- librarySource.addSource("before.dart",
+ MemoryLibrarySource librarySource = new MemoryLibrarySource("App.dart");
+ librarySource.setContent("App.dart", "library App; part 'before.dart';");
+ librarySource.setContent("before.dart",
+ Joiner.on("\n").join(new String[] {
+ "part of App;",
"class Foo {}",
- "m() {}");
+ "m() {}"}));
DartUnit change = analyzeNoChange(librarySource);
assertEquals(2, change.getTopLevelNodes().size());
ClassElement cls = (ClassElement) change.getTopLevelNodes().get(0).getElement();
@@ -45,12 +49,17 @@ public class DeltaAnalyzerTest extends TestCase {
}
public void testNoChangeTwoFiles() throws IOException {
- TestLibrarySource librarySource = new TestLibrarySource(getName());
- librarySource.addSource("before.dart",
+ MemoryLibrarySource librarySource = new MemoryLibrarySource("App.dart");
+ librarySource.setContent("App.dart", "library App; part 'before.dart'; part 'common.dart';");
+ librarySource.setContent("before.dart",
+ Joiner.on("\n").join(new String[] {
+ "part of App;",
"class Foo extends Bar {}",
- "m() {}");
- librarySource.addSource("common.dart",
- "class Bar {}");
+ "m() {}"}));
+ librarySource.setContent("common.dart",
+ Joiner.on("\n").join(new String[] {
+ "part of App;",
+ "class Bar {}"}));
DartUnit change = analyzeNoChange(librarySource);
assertEquals(2, change.getTopLevelNodes().size());
ClassElement cls = (ClassElement) change.getTopLevelNodes().get(0).getElement();
@@ -67,12 +76,14 @@ public class DeltaAnalyzerTest extends TestCase {
}
public void testChangeSingleFile() throws IOException {
- TestLibrarySource librarySource = new TestLibrarySource(getName());
- librarySource.addSource("before.dart",
- "class Foo {}",
- "m() {}");
+ MemoryLibrarySource librarySource = new MemoryLibrarySource("App.dart");
+ librarySource.setContent("App.dart", "library App;");
+ librarySource.setContent(
+ "before.dart",
+ Joiner.on("\n").join(new String[] {"part of App;", "class Foo {}", "m() {}"}));
DartSource sourceBefore = librarySource.getSourceFor("before.dart");
- DartSource sourceAfter = new DartSourceString("after.dart", "class Foo {}");
+ DartSource sourceAfter = new DartSourceString("after.dart", Joiner.on("\n").join(
+ new String[] {"part of App;", "class Foo {}", ""}));
DartUnit change = analyze(librarySource, sourceBefore, sourceAfter);
assertEquals(1, change.getTopLevelNodes().size());
Element element = change.getLibrary().getElement().lookupLocalElement("m");
@@ -85,14 +96,19 @@ public class DeltaAnalyzerTest extends TestCase {
}
public void testChangeTwoFiles() throws IOException {
- TestLibrarySource librarySource = new TestLibrarySource(getName());
- librarySource.addSource("before.dart",
+ MemoryLibrarySource librarySource = new MemoryLibrarySource("App.dart");
+ librarySource.setContent("App.dart", "library App; part 'before.dart'; part 'common.dart';");
+ librarySource.setContent("before.dart",
+ Joiner.on("\n").join(new String[] {
+ "part of App;",
"class Foo extends Bar {}",
- "m() {}");
- librarySource.addSource("common.dart",
- "class Bar {}");
+ "m() {}"}));
+ librarySource.setContent("common.dart",
+ Joiner.on("\n").join(new String[] {
+ "part of App;",
+ "class Bar {}"}));
DartSource sourceBefore = librarySource.getSourceFor("before.dart");
- DartSource sourceAfter = new DartSourceString("after.dart", "class Foo extends Bar {}");
+ DartSource sourceAfter = new DartSourceString("after.dart", "part of App; class Foo extends Bar {}");
DartUnit change = analyze(librarySource, sourceBefore, sourceAfter);
assertEquals(1, change.getTopLevelNodes().size());
assertNull(change.getLibrary().getElement().lookupLocalElement("m"));

Powered by Google App Engine
This is Rietveld 408576698