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

Side by Side Diff: pkg/front_end/test/src/incremental/mock_sdk.dart

Issue 2893423002: Beef up front-end mock SDK libraries, mostly dart:core. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:front_end/memory_file_system.dart'; 5 import 'package:front_end/memory_file_system.dart';
6 6
7 /// Create SDK libraries which are used by Fasta to perform kernel generation. 7 /// Create SDK libraries which are used by Fasta to perform kernel generation.
8 /// Return the mapping from the simple names of these library to the URIs 8 /// Return the mapping from the simple names of these library to the URIs
9 /// in the given [fileSystem]. The root of the SDK is `file:///sdk`. 9 /// in the given [fileSystem]. The root of the SDK is `file:///sdk`.
10 Map<String, Uri> createSdkFiles(MemoryFileSystem fileSystem) { 10 Map<String, Uri> createSdkFiles(MemoryFileSystem fileSystem) {
11 Map<String, Uri> dartLibraries = {}; 11 Map<String, Uri> dartLibraries = {};
12 12
13 void addSdkLibrary(String name, String contents) { 13 void addSdkLibrary(String name, String contents) {
14 String path = '$name/$name.dart'; 14 String path = '$name/$name.dart';
15 Uri uri = Uri.parse('file:///sdk/lib/$path'); 15 Uri uri = Uri.parse('file:///sdk/lib/$path');
16 fileSystem.entityForUri(uri).writeAsStringSync(contents); 16 fileSystem.entityForUri(uri).writeAsStringSync(contents);
17 dartLibraries[name] = uri; 17 dartLibraries[name] = uri;
18 } 18 }
19 19
20 addSdkLibrary( 20 addSdkLibrary(
21 'core', 21 'core',
22 r''' 22 r'''
23 library dart.core; 23 library dart.core;
24 import 'dart:_internal'; 24 import 'dart:_internal';
25 import 'dart:async'; 25 import 'dart:async';
26 26
27 class Object { 27 class Object {
28 const Object(); 28 const Object() {}
29 bool operator ==(other) => identical(this, other);
30 String toString() => 'a string';
31 int get hashCode => 0;
32 Type get runtimeType => null;
33 dynamic noSuchMethod(Invocation invocation) => null;
29 } 34 }
30 35
31 class Null {} 36 class Null {}
32 class Symbol {} 37
38 class Symbol {
39 const factory Symbol(String name) {
40 return null;
41 }
42 }
43
33 class Type {} 44 class Type {}
45
46 abstract class Comparable<T> {
47 int compareTo(T other);
48 }
49
50 abstract class Pattern {}
51
52 abstract class String implements Comparable<String>, Pattern {
53 external factory String.fromCharCodes(Iterable<int> charCodes,
54 [int start = 0, int end]);
55 String operator +(String other) => null;
56 bool get isEmpty => false;
57 bool get isNotEmpty => false;
58 int get length => 0;
59 String substring(int len) => null;
60 String toLowerCase();
61 String toUpperCase();
62 List<int> get codeUnits;
63 }
64
65 abstract class RegExp implements Pattern {
66 external factory RegExp(String source);
67 }
68
34 class Function {} 69 class Function {}
35 class Invocation {} 70 class Invocation {}
36 class StackTrace {} 71 class StackTrace {}
37 class bool {} 72
38 class String {} 73 class bool extends Object {
39 class num {} 74 external const factory bool.fromEnvironment(String name,
40 class int extends num {} 75 {bool defaultValue: false});
41 class double {} 76 }
42 class Iterable<T> {} 77
43 class Iterator<T> {} 78 abstract class num implements Comparable<num> {
44 class List<T> extends Iterable<T> {} 79 bool operator ==(Object other);
45 class Map<K, V> {} 80 bool operator <(num other);
81 bool operator <=(num other);
82 bool operator >(num other);
83 bool operator >=(num other);
84 num operator +(num other);
85 num operator -(num other);
86 num operator *(num other);
87 num operator /(num other);
88 int operator ^(int other);
89 int operator |(int other);
90 int operator <<(int other);
91 int operator >>(int other);
92 int operator ~/(num other);
93 num operator %(num other);
94 int operator ~();
95 num operator -();
96 int toInt();
97 double toDouble();
98 num abs();
99 int round();
100 }
101
102 abstract class int extends num {
103 external const factory int.fromEnvironment(String name, {int defaultValue});
104
105 bool get isNegative;
106 bool get isEven => false;
107
108 int operator &(int other);
109 int operator |(int other);
110 int operator ^(int other);
111 int operator ~();
112 int operator <<(int shiftAmount);
113 int operator >>(int shiftAmount);
114
115 int operator -();
116
117 external static int parse(String source,
118 { int radix,
119 int onError(String source) });
120 }
121
122 abstract class double extends num {
123 static const double NAN = 0.0 / 0.0;
124 static const double INFINITY = 1.0 / 0.0;
125 static const double NEGATIVE_INFINITY = -INFINITY;
126 static const double MIN_POSITIVE = 5e-324;
127 static const double MAX_FINITE = 1.7976931348623157e+308;
128
129 double remainder(num other);
130 double operator +(num other);
131 double operator -(num other);
132 double operator *(num other);
133 double operator %(num other);
134 double operator /(num other);
135 int operator ~/(num other);
136 double operator -();
137 double abs();
138 double get sign;
139 int round();
140 int floor();
141 int ceil();
142 int truncate();
143 double roundToDouble();
144 double floorToDouble();
145 double ceilToDouble();
146 double truncateToDouble();
147 external static double parse(String source,
148 [double onError(String source)]);
149 }
150
151 class Iterator<E> {
152 bool moveNext();
153 E get current;
154 }
155
156 abstract class Iterable<E> {
157 Iterator<E> get iterator;
158 bool get isEmpty;
159 E get first;
160
161 Iterable<R> map<R>(R f(E e));
162
163 R fold<R>(R initialValue, R combine(R previousValue, E element));
164
165 Iterable<T> expand<T>(Iterable<T> f(E element));
166
167 Iterable<E> where(bool test(E element));
168
169 void forEach(void f(E element));
170
171 List<E> toList();
172 }
173
174 class List<E> implements Iterable<E> {
175 List();
176 void add(E value) {}
177 void addAll(Iterable<E> iterable) {}
178 E operator [](int index) => null;
179 void operator []=(int index, E value) {}
180 Iterator<E> get iterator => null;
181 void clear() {}
182
183 bool get isEmpty => false;
184 E get first => null;
185 E get last => null;
186
187 R fold<R>(R initialValue, R combine(R previousValue, E element)) => null;
188 }
189
190 class Map<K, V> extends Object {
191 V operator [](K key) => null;
192 void operator []=(K key, V value) {}
193 Iterable<K> get keys => null;
194 int get length;
195 Iterable<V> get values;
196 }
197
198 class Duration implements Comparable<Duration> {}
199
200 external bool identical(Object a, Object b);
46 201
47 void print(Object o) {} 202 void print(Object o) {}
48 203
49 abstract class _SyncIterable implements Iterable {} 204 abstract class _SyncIterable implements Iterable {}
50 '''); 205 ''');
51 206
52 addSdkLibrary( 207 addSdkLibrary(
53 'async', 208 'async',
54 r''' 209 r'''
55 library dart.async; 210 library dart.async;
56 211
57 class Future<T> { 212 class Future<T> {
213 factory Future(computation()) => null;
214 factory Future.delayed(Duration duration, [T computation()]) => null;
58 factory Future.microtask(FutureOr<T> computation()) => null; 215 factory Future.microtask(FutureOr<T> computation()) => null;
216 factory Future.value([value]) => null;
217
218 static Future<List<T>> wait<T>(Iterable<Future<T>> futures) => null;
219 Future<R> then<R>(FutureOr<R> onValue(T value)) => null;
220
221 Future<T> whenComplete(action());
59 } 222 }
60 223
224
61 class FutureOr<T> {} 225 class FutureOr<T> {}
62 class Stream<T> {} 226 class Stream<T> {}
63 abstract class StreamIterator<T> {} 227 abstract class StreamIterator<T> {}
64 228
65 abstract class Completer<T> { 229 abstract class Completer<T> {
66 factory Completer() => null; 230 factory Completer() => null;
67 factory Completer.sync() => null; 231 factory Completer.sync() => null;
68 Future<T> get future; 232 Future<T> get future;
69 void complete([FutureOr<T> value]); 233 void complete([FutureOr<T> value]);
70 void completeError(Object error, [StackTrace stackTrace]); 234 void completeError(Object error, [StackTrace stackTrace]);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 class Symbol {} 268 class Symbol {}
105 class ExternalName { 269 class ExternalName {
106 final String name; 270 final String name;
107 const ExternalName(this.name); 271 const ExternalName(this.name);
108 } 272 }
109 '''); 273 ''');
110 addSdkLibrary('_vmservice', 'library dart._vmservice;'); 274 addSdkLibrary('_vmservice', 'library dart._vmservice;');
111 275
112 return dartLibraries; 276 return dartLibraries;
113 } 277 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698