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

Side by Side Diff: pkg/analysis_server/test/mock_sdk.dart

Issue 810063002: Add methods to mock SDK that are referenced by completion tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/completion_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library testing.mock_sdk; 5 library testing.mock_sdk;
6 6
7 import 'package:analyzer/file_system/file_system.dart' as resource; 7 import 'package:analyzer/file_system/file_system.dart' as resource;
8 import 'package:analyzer/file_system/memory_file_system.dart' as resource; 8 import 'package:analyzer/file_system/memory_file_system.dart' as resource;
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/sdk.dart'; 10 import 'package:analyzer/src/generated/sdk.dart';
(...skipping 15 matching lines...) Expand all
26 26
27 class Function {} 27 class Function {}
28 class StackTrace {} 28 class StackTrace {}
29 class Symbol {} 29 class Symbol {}
30 class Type {} 30 class Type {}
31 31
32 abstract class Comparable<T> { 32 abstract class Comparable<T> {
33 int compareTo(T other); 33 int compareTo(T other);
34 } 34 }
35 35
36 class String implements Comparable<String> { 36 abstract class String implements Comparable<String> {
37 external factory String.fromCharCodes(Iterable<int> charCodes, 37 external factory String.fromCharCodes(Iterable<int> charCodes,
38 [int start = 0, int end]); 38 [int start = 0, int end]);
39 bool get isEmpty => false; 39 bool get isEmpty => false;
40 bool get isNotEmpty => false; 40 bool get isNotEmpty => false;
41 int get length => 0; 41 int get length => 0;
42 String toUpperCase();
43 List<int> get codeUnits;
42 } 44 }
43 45
44 class bool extends Object {} 46 class bool extends Object {}
45 abstract class num implements Comparable<num> { 47 abstract class num implements Comparable<num> {
46 bool operator <(num other); 48 bool operator <(num other);
47 bool operator <=(num other); 49 bool operator <=(num other);
48 bool operator >(num other); 50 bool operator >(num other);
49 bool operator >=(num other); 51 bool operator >=(num other);
50 num operator +(num other); 52 num operator +(num other);
51 num operator -(num other); 53 num operator -(num other);
52 num operator *(num other); 54 num operator *(num other);
53 num operator /(num other); 55 num operator /(num other);
54 int toInt(); 56 int toInt();
57 num abs();
58 int round();
55 } 59 }
56 abstract class int extends num { 60 abstract class int extends num {
57 bool get isEven => false; 61 bool get isEven => false;
58 int operator -(); 62 int operator -();
63 external static int parse(String source,
64 { int radix,
65 int onError(String source) });
59 } 66 }
60 class double extends num {} 67 class double extends num {}
61 class DateTime extends Object {} 68 class DateTime extends Object {}
62 class Null extends Object {} 69 class Null extends Object {}
63 70
64 class Deprecated extends Object { 71 class Deprecated extends Object {
65 final String expires; 72 final String expires;
66 const Deprecated(this.expires); 73 const Deprecated(this.expires);
67 } 74 }
68 const Object deprecated = const Deprecated("next release"); 75 const Object deprecated = const Deprecated("next release");
69 76
70 class Iterator<E> { 77 class Iterator<E> {
71 bool moveNext(); 78 bool moveNext();
72 E get current; 79 E get current;
73 } 80 }
74 81
75 abstract class Iterable<E> { 82 abstract class Iterable<E> {
76 Iterator<E> get iterator; 83 Iterator<E> get iterator;
84 bool get isEmpty;
77 } 85 }
78 86
79 abstract class List<E> implements Iterable<E> { 87 abstract class List<E> implements Iterable<E> {
80 void add(E value); 88 void add(E value);
81 E operator [](int index); 89 E operator [](int index);
82 void operator []=(int index, E value); 90 void operator []=(int index, E value);
83 Iterator<E> get iterator => null; 91 Iterator<E> get iterator => null;
92 void clear();
84 } 93 }
85 94
86 class Map<K, V> extends Object {} 95 abstract class Map<K, V> extends Object {
96 Iterable<K> get keys;
97 }
87 98
88 external bool identical(Object a, Object b); 99 external bool identical(Object a, Object b);
89 100
90 void print(Object object) {} 101 void print(Object object) {}
91 '''); 102 ''');
92 103
93 static const _MockSdkLibrary LIB_ASYNC = 104 static const _MockSdkLibrary LIB_ASYNC =
94 const _MockSdkLibrary('dart:async', '/lib/async/async.dart', ''' 105 const _MockSdkLibrary('dart:async', '/lib/async/async.dart', '''
95 library dart.async; 106 library dart.async;
96 107
97 import 'dart:math'; 108 import 'dart:math';
98 109
99 class Future<T> { 110 class Future<T> {
100 static Future wait(List<Future> futures) => null; 111 static Future wait(List<Future> futures) => null;
101 } 112 }
102 113
103 class Stream<T> {} 114 class Stream<T> {}
115 abstract class StreamTransformer<S, T> {}
116 ''');
117
118 static const _MockSdkLibrary LIB_COLLECTION =
119 const _MockSdkLibrary('dart:collection', '/lib/collection/collection.dart' , '''
120 library dart.collection;
121
122 abstract class HashMap<K, V> implements Map<K, V> {}
123 ''');
124
125 static const _MockSdkLibrary LIB_CONVERT =
126 const _MockSdkLibrary('dart:convert', '/lib/convert/convert.dart', '''
127 library dart.convert;
128
129 import 'dart:async';
130
131 abstract class Converter<S, T> implements StreamTransformer {}
132 class JsonDecoder extends Converter<String, Object> {}
104 '''); 133 ''');
105 134
106 static const _MockSdkLibrary LIB_MATH = 135 static const _MockSdkLibrary LIB_MATH =
107 const _MockSdkLibrary('dart:math', '/lib/math/math.dart', ''' 136 const _MockSdkLibrary('dart:math', '/lib/math/math.dart', '''
108 library dart.math; 137 library dart.math;
109 const double E = 2.718281828459045; 138 const double E = 2.718281828459045;
110 const double PI = 3.1415926535897932; 139 const double PI = 3.1415926535897932;
140 const double LN10 = 2.302585092994046;
111 num min(num a, num b) => 0; 141 num min(num a, num b) => 0;
112 num max(num a, num b) => 0; 142 num max(num a, num b) => 0;
143 external double cos(num x);
144 external double sin(num x);
145 external double sqrt(num x);
113 class Random {} 146 class Random {}
114 '''); 147 ''');
115 148
116 static const _MockSdkLibrary LIB_HTML = 149 static const _MockSdkLibrary LIB_HTML =
117 const _MockSdkLibrary('dart:html', '/lib/html/dartium/html_dartium.dart', ''' 150 const _MockSdkLibrary('dart:html', '/lib/html/dartium/html_dartium.dart', '''
118 library dart.html; 151 library dart.html;
119 class HtmlElement {} 152 class HtmlElement {}
120 '''); 153 ''');
121 154
122 static const List<SdkLibrary> LIBRARIES = const [ 155 static const List<SdkLibrary> LIBRARIES = const [
123 LIB_CORE, 156 LIB_CORE,
124 LIB_ASYNC, 157 LIB_ASYNC,
158 LIB_COLLECTION,
159 LIB_CONVERT,
125 LIB_MATH, 160 LIB_MATH,
126 LIB_HTML,]; 161 LIB_HTML,];
127 162
128 final resource.MemoryResourceProvider provider = 163 final resource.MemoryResourceProvider provider =
129 new resource.MemoryResourceProvider(); 164 new resource.MemoryResourceProvider();
130 165
131 /** 166 /**
132 * The [AnalysisContext] which is used for all of the sources. 167 * The [AnalysisContext] which is used for all of the sources.
133 */ 168 */
134 InternalAnalysisContext _analysisContext; 169 InternalAnalysisContext _analysisContext;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // return null. 248 // return null.
214 return null; 249 return null;
215 } 250 }
216 251
217 @override 252 @override
218 Source mapDartUri(String dartUri) { 253 Source mapDartUri(String dartUri) {
219 const Map<String, String> uriToPath = const { 254 const Map<String, String> uriToPath = const {
220 "dart:core": "/lib/core/core.dart", 255 "dart:core": "/lib/core/core.dart",
221 "dart:html": "/lib/html/dartium/html_dartium.dart", 256 "dart:html": "/lib/html/dartium/html_dartium.dart",
222 "dart:async": "/lib/async/async.dart", 257 "dart:async": "/lib/async/async.dart",
258 "dart:collection": "/lib/collection/collection.dart",
259 "dart:convert": "/lib/convert/convert.dart",
223 "dart:math": "/lib/math/math.dart" 260 "dart:math": "/lib/math/math.dart"
224 }; 261 };
225 262
226 String path = uriToPath[dartUri]; 263 String path = uriToPath[dartUri];
227 if (path != null) { 264 if (path != null) {
228 resource.File file = provider.getResource(path); 265 resource.File file = provider.getResource(path);
229 Uri uri = new Uri(scheme: 'dart', path: dartUri.substring(5)); 266 Uri uri = new Uri(scheme: 'dart', path: dartUri.substring(5));
230 return file.createSource(uri); 267 return file.createSource(uri);
231 } 268 }
232 269
(...skipping 27 matching lines...) Expand all
260 bool get isInternal => throw unimplemented; 297 bool get isInternal => throw unimplemented;
261 298
262 @override 299 @override
263 bool get isShared => throw unimplemented; 300 bool get isShared => throw unimplemented;
264 301
265 @override 302 @override
266 bool get isVmLibrary => throw unimplemented; 303 bool get isVmLibrary => throw unimplemented;
267 304
268 UnimplementedError get unimplemented => new UnimplementedError(); 305 UnimplementedError get unimplemented => new UnimplementedError();
269 } 306 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/completion_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698