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

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

Issue 2650803005: Make Analysis Server tests use MockSdk again. (Closed)
Patch Set: Created 3 years, 11 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
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/context/context.dart'; 9 import 'package:analyzer/src/context/context.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
11 import 'package:analyzer/src/generated/sdk.dart'; 11 import 'package:analyzer/src/generated/sdk.dart';
12 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
13 import 'package:analyzer/src/summary/idl.dart' show PackageBundle; 13 import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
14 import 'package:analyzer/src/summary/summary_file_builder.dart'; 14 import 'package:analyzer/src/summary/summary_file_builder.dart';
15 15
16 class MockSdk implements DartSdk { 16 class MockSdk implements DartSdk {
17 static const MockSdkLibrary LIB_CORE = const MockSdkLibrary( 17 static const MockSdkLibrary LIB_CORE = const MockSdkLibrary(
18 'dart:core', 18 'dart:core',
19 '/lib/core/core.dart', 19 '/lib/core/core.dart',
20 ''' 20 '''
21 library dart.core; 21 library dart.core;
22 22
23 import 'dart:async'; 23 import 'dart:async';
24 import 'dart:_internal'; 24 import 'dart:_internal';
25 25
26 class Object { 26 class Object {
27 const Object() {}
27 bool operator ==(other) => identical(this, other); 28 bool operator ==(other) => identical(this, other);
28 String toString() => 'a string'; 29 String toString() => 'a string';
29 int get hashCode => 0; 30 int get hashCode => 0;
31 Type get runtimeType => null;
32 dynamic noSuchMethod(Invocation invocation) => null;
30 } 33 }
31 34
32 class Function {} 35 class Function {}
33 class StackTrace {} 36 class StackTrace {}
34 class Symbol {} 37 class Symbol {}
35 class Type {} 38 class Type {}
36 39
37 abstract class Comparable<T> { 40 abstract class Comparable<T> {
38 int compareTo(T other); 41 int compareTo(T other);
39 } 42 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 bool moveNext(); 126 bool moveNext();
124 E get current; 127 E get current;
125 } 128 }
126 129
127 abstract class Iterable<E> { 130 abstract class Iterable<E> {
128 Iterator<E> get iterator; 131 Iterator<E> get iterator;
129 bool get isEmpty; 132 bool get isEmpty;
130 Iterable/*<R>*/ map/*<R>*/(/*=R*/ f(E e)); 133 Iterable/*<R>*/ map/*<R>*/(/*=R*/ f(E e));
131 } 134 }
132 135
133 abstract class List<E> implements Iterable<E> { 136 class List<E> implements Iterable<E> {
134 void add(E value); 137 List();
138 void add(E value) {}
135 void addAll(Iterable<E> iterable) {} 139 void addAll(Iterable<E> iterable) {}
136 E operator [](int index); 140 E operator [](int index) => null;
137 void operator []=(int index, E value); 141 void operator []=(int index, E value) {}
138 Iterator<E> get iterator => null; 142 Iterator<E> get iterator => null;
139 void clear(); 143 void clear() {}
144
145 bool get isEmpty => false;
146 E get first => null;
147 E get last => null;
148
149 Iterable/*<R>*/ map/*<R>*/(/*=R*/ f(E e)) => null;
150
151 /*=R*/ fold/*<R>*/(/*=R*/ initialValue,
152 /*=R*/ combine(/*=R*/ previousValue, E element)) => null;
153
140 } 154 }
141 155
142 abstract class Map<K, V> extends Object { 156 abstract class Map<K, V> extends Object {
143 bool containsKey(Object key); 157 bool containsKey(Object key);
144 Iterable<K> get keys; 158 Iterable<K> get keys;
145 } 159 }
146 160
147 external bool identical(Object a, Object b); 161 external bool identical(Object a, Object b);
148 162
149 void print(Object object) {} 163 void print(Object object) {}
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 '''); 215 ''');
202 216
203 static const MockSdkLibrary LIB_MATH = const MockSdkLibrary( 217 static const MockSdkLibrary LIB_MATH = const MockSdkLibrary(
204 'dart:math', 218 'dart:math',
205 '/lib/math/math.dart', 219 '/lib/math/math.dart',
206 ''' 220 '''
207 library dart.math; 221 library dart.math;
208 const double E = 2.718281828459045; 222 const double E = 2.718281828459045;
209 const double PI = 3.1415926535897932; 223 const double PI = 3.1415926535897932;
210 const double LN10 = 2.302585092994046; 224 const double LN10 = 2.302585092994046;
211 num min(num a, num b) => 0; 225 T min<T extends num>(T a, T b) => null;
212 num max(num a, num b) => 0; 226 T max<T extends num>(T a, T b) => null;
213 external double cos(num x); 227 external double cos(num x);
214 external num pow(num x, num exponent); 228 external num pow(num x, num exponent);
215 external double sin(num x); 229 external double sin(num x);
216 external double sqrt(num x); 230 external double sqrt(num x);
217 class Random { 231 class Random {
218 bool nextBool() => true; 232 bool nextBool() => true;
219 double nextDouble() => 2.0; 233 double nextDouble() => 2.0;
220 int nextInt() => 1; 234 int nextInt() => 1;
221 } 235 }
222 '''); 236 ''');
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 bool get isInternal => shortName.startsWith('dart:_'); 449 bool get isInternal => shortName.startsWith('dart:_');
436 450
437 @override 451 @override
438 bool get isShared => throw unimplemented; 452 bool get isShared => throw unimplemented;
439 453
440 @override 454 @override
441 bool get isVmLibrary => throw unimplemented; 455 bool get isVmLibrary => throw unimplemented;
442 456
443 UnimplementedError get unimplemented => new UnimplementedError(); 457 UnimplementedError get unimplemented => new UnimplementedError();
444 } 458 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/abstract_context.dart ('k') | pkg/analysis_server/test/services/completion/dart/optype_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698