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

Unified Diff: pkg/analysis_testing/lib/mock_sdk.dart

Issue 427473003: Uncomment and test fixes for importing libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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: pkg/analysis_testing/lib/mock_sdk.dart
diff --git a/pkg/analysis_testing/lib/mock_sdk.dart b/pkg/analysis_testing/lib/mock_sdk.dart
index 224d4384a90399c9ec9333af81c373b0c8b75238..1e299f5b44fcade1142de936e2dda019c789fb2a 100644
--- a/pkg/analysis_testing/lib/mock_sdk.dart
+++ b/pkg/analysis_testing/lib/mock_sdk.dart
@@ -15,76 +15,85 @@ class MockSdk implements DartSdk {
final resource.MemoryResourceProvider provider =
new resource.MemoryResourceProvider();
- MockSdk() {
- // TODO(paulberry): Add to this as needed.
- const Map<String, String> pathToContent = const {
- "/lib/core/core.dart": '''
- library dart.core;
- class Object {}
- class Function {}
- class StackTrace {}
- class Symbol {}
- class Type {}
-
- abstract class Comparable<T> {
- int compareTo(T other);
- }
-
- class String implements Comparable<String> {
- }
-
- class bool extends Object {}
- abstract class num implements Comparable<num> {
- num operator +(num other);
- num operator -(num other);
- num operator *(num other);
- num operator /(num other);
- int toInt();
- }
- abstract class int extends num {
- int operator -();
- }
- class double extends num {}
- class DateTime extends Object {}
- class Null extends Object {}
-
- class Deprecated extends Object {
- final String expires;
- const Deprecated(this.expires);
- }
- const Object deprecated = const Deprecated("next release");
-
- abstract class List<E> extends Object {
- void add(E value);
- E operator [](int index);
- void operator []=(int index, E value);
- }
- class Map<K, V> extends Object {}
-
- void print(Object object) {}
- ''',
-
- "/lib/html/dartium/html_dartium.dart": '''
- library dart.html;
- class HtmlElement {}
- ''',
-
- "/lib/async/async.dart": '''
- library dart.async;
- class Future {
- static Future wait(List<Future> futures) => null;
- }
- ''',
-
- "/lib/math/math.dart": '''
- library dart.math;
- const double E = 2.718281828459045;
- const double PI = 3.1415926535897932;
- '''
- };
+ static const _MockSdkLibrary LIB_CORE =
+ const _MockSdkLibrary('dart:core', '/lib/core/core.dart', '''
+library dart.core;
+class Object {}
+class Function {}
+class StackTrace {}
+class Symbol {}
+class Type {}
+
+abstract class Comparable<T> {
+ int compareTo(T other);
+}
+
+class String implements Comparable<String> {
+}
+
+class bool extends Object {}
+abstract class num implements Comparable<num> {
+ num operator +(num other);
+ num operator -(num other);
+ num operator *(num other);
+ num operator /(num other);
+ int toInt();
+}
+abstract class int extends num {
+ int operator -();
+}
+class double extends num {}
+class DateTime extends Object {}
+class Null extends Object {}
+
+class Deprecated extends Object {
+ final String expires;
+ const Deprecated(this.expires);
+}
+const Object deprecated = const Deprecated("next release");
- pathToContent.forEach((String path, String content) {
- provider.newFile(path, content);
+abstract class List<E> extends Object {
+ void add(E value);
+ E operator [](int index);
+ void operator []=(int index, E value);
+}
+class Map<K, V> extends Object {}
+
+void print(Object object) {}
+''');
+
+ static const _MockSdkLibrary LIB_ASYNC =
+ const _MockSdkLibrary('dart:async', '/lib/async/async.dart', '''
+library dart.async;
+class Future {
+ static Future wait(List<Future> futures) => null;
+}
+
+class Stream<T> {}
+''');
+
+ static const _MockSdkLibrary LIB_MATH =
+ const _MockSdkLibrary('dart:math', '/lib/math/math.dart', '''
+library dart.math;
+const double E = 2.718281828459045;
+const double PI = 3.1415926535897932;
+''');
+
+ static const _MockSdkLibrary LIB_HTML =
+ const _MockSdkLibrary('dart:html', '/lib/html/dartium/html_dartium.dart', '''
+library dart.html;
+class HtmlElement {}
+''');
+
+ static const List<SdkLibrary> LIBRARIES = const [
+ LIB_CORE,
+ LIB_ASYNC,
+ LIB_MATH,
+ LIB_HTML,];
+
+ MockSdk() {
+ LIBRARIES.forEach((_MockSdkLibrary library) {
+ provider.newFile(library.path, library.content);
});
}
@@ -93,7 +102,7 @@ class MockSdk implements DartSdk {
AnalysisContext get context => throw unimplemented;
@override
- List<SdkLibrary> get sdkLibraries => throw unimplemented;
+ List<SdkLibrary> get sdkLibraries => LIBRARIES;
@override
String get sdkVersion => throw unimplemented;
@@ -143,3 +152,35 @@ class MockSdk implements DartSdk {
throw unimplemented;
}
}
+
+
+class _MockSdkLibrary implements SdkLibrary {
+ final String shortName;
+ final String path;
+ final String content;
+
+ const _MockSdkLibrary(this.shortName, this.path, this.content);
+
+ @override
+ String get category => throw unimplemented;
+
+ @override
+ bool get isDart2JsLibrary => throw unimplemented;
+
+ @override
+ bool get isDocumented => throw unimplemented;
+
+ @override
+ bool get isImplementation => throw unimplemented;
+
+ @override
+ bool get isInternal => throw unimplemented;
+
+ @override
+ bool get isShared => throw unimplemented;
+
+ @override
+ bool get isVmLibrary => throw unimplemented;
+
+ UnimplementedError get unimplemented => new UnimplementedError();
+}

Powered by Google App Engine
This is Rietveld 408576698