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

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

Issue 10200005: Issue 2693. Don't add null imports (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks for review comments 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
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java
diff --git a/compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java b/compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java
index b6c2cd3a25bd91dba81c3ad55bbb4069eaaac19f..8b221e725d40f6c99e65ec3f2b427cda4e83d1b7 100644
--- a/compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java
+++ b/compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package com.google.dart.compiler.end2end.inc;
@@ -8,25 +8,32 @@ import com.google.dart.compiler.DartSource;
import com.google.dart.compiler.LibrarySource;
import com.google.dart.compiler.Source;
import com.google.dart.compiler.UrlDartSource;
-import com.google.dart.compiler.UrlLibrarySource;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.Map;
/**
* {@link LibrarySource} which provides content for all {@link Source}s from memory.
*/
public class MemoryLibrarySource implements LibrarySource {
+ public static final String IO_EXCEPTION_CONTENT = "simulate-IOException";
private final String libName;
- private final Map<String, String> sourceContentMap = Maps.newHashMap();
- private final Map<String, Long> sourceLastModifiedMap = Maps.newHashMap();
+ private final Map<String, String> sourceContentMap;
+ private final Map<String, Long> sourceLastModifiedMap;
- public MemoryLibrarySource(String libName) throws URISyntaxException {
+ public MemoryLibrarySource(String libName) {
this.libName = libName;
+ sourceContentMap = Maps.newHashMap();
+ sourceLastModifiedMap = Maps.newHashMap();
+ }
+
+ private MemoryLibrarySource(String libName, MemoryLibrarySource parent) {
+ this.libName = libName;
+ sourceContentMap = parent.sourceContentMap;
+ sourceLastModifiedMap = parent.sourceLastModifiedMap;
}
@Override
@@ -57,35 +64,15 @@ public class MemoryLibrarySource implements LibrarySource {
@Override
public Reader getSourceReader() throws IOException {
String content = sourceContentMap.get(libName);
+ if (IO_EXCEPTION_CONTENT.equals(content)) {
+ throw new IOException("simulated");
+ }
return new StringReader(content);
}
@Override
public LibrarySource getImportFor(final String relPath) throws IOException {
- final String content = sourceContentMap.get(relPath);
- final Long sourceLastModified = sourceLastModifiedMap.get(relPath);
- URI uri = URI.create(relPath);
- return new UrlLibrarySource(uri) {
- @Override
- public boolean exists() {
- return content != null;
- }
-
- @Override
- public long getLastModified() {
- return sourceLastModified.longValue();
- }
-
- @Override
- public Reader getSourceReader() throws IOException {
- return new StringReader(content);
- }
-
- @Override
- public DartSource getSourceFor(String relPath) {
- return MemoryLibrarySource.this.getSourceFor(relPath);
- }
- };
+ return new MemoryLibrarySource(relPath, this);
}
@Override
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698