| OLD | NEW |
| 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 = |
| 18 'dart:core', | 18 const MockSdkLibrary('dart:core', '/lib/core/core.dart', ''' |
| 19 '/lib/core/core.dart', | |
| 20 ''' | |
| 21 library dart.core; | 19 library dart.core; |
| 22 | 20 |
| 23 import 'dart:async'; | 21 import 'dart:async'; |
| 24 import 'dart:_internal'; | 22 import 'dart:_internal'; |
| 25 | 23 |
| 26 class Object { | 24 class Object { |
| 27 const Object() {} | 25 const Object() {} |
| 28 bool operator ==(other) => identical(this, other); | 26 bool operator ==(other) => identical(this, other); |
| 29 String toString() => 'a string'; | 27 String toString() => 'a string'; |
| 30 int get hashCode => 0; | 28 int get hashCode => 0; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 class Uri { | 158 class Uri { |
| 161 static List<int> parseIPv6Address(String host, [int start = 0, int end]) { | 159 static List<int> parseIPv6Address(String host, [int start = 0, int end]) { |
| 162 int parseHex(int start, int end) { | 160 int parseHex(int start, int end) { |
| 163 return 0; | 161 return 0; |
| 164 } | 162 } |
| 165 return null; | 163 return null; |
| 166 } | 164 } |
| 167 } | 165 } |
| 168 '''); | 166 '''); |
| 169 | 167 |
| 170 static const MockSdkLibrary LIB_ASYNC = const MockSdkLibrary( | 168 static const MockSdkLibrary LIB_ASYNC = |
| 171 'dart:async', | 169 const MockSdkLibrary('dart:async', '/lib/async/async.dart', ''' |
| 172 '/lib/async/async.dart', | |
| 173 ''' | |
| 174 library dart.async; | 170 library dart.async; |
| 175 | 171 |
| 176 import 'dart:math'; | 172 import 'dart:math'; |
| 177 | 173 |
| 178 class Future<T> { | 174 class Future<T> { |
| 179 factory Future(computation()) => null; | 175 factory Future(computation()) => null; |
| 180 factory Future.delayed(Duration duration, [T computation()]) => null; | 176 factory Future.delayed(Duration duration, [T computation()]) => null; |
| 181 factory Future.value([value]) => null; | 177 factory Future.value([value]) => null; |
| 182 static Future wait(List<Future> futures) => null; | 178 static Future wait(List<Future> futures) => null; |
| 183 } | 179 } |
| 184 | 180 |
| 185 class FutureOr<T> {} | 181 class FutureOr<T> {} |
| 186 | 182 |
| 187 class Stream<T> {} | 183 class Stream<T> {} |
| 188 abstract class StreamTransformer<S, T> {} | 184 abstract class StreamTransformer<S, T> {} |
| 189 '''); | 185 '''); |
| 190 | 186 |
| 191 static const MockSdkLibrary LIB_COLLECTION = const MockSdkLibrary( | 187 static const MockSdkLibrary LIB_COLLECTION = const MockSdkLibrary( |
| 192 'dart:collection', | 188 'dart:collection', '/lib/collection/collection.dart', ''' |
| 193 '/lib/collection/collection.dart', | |
| 194 ''' | |
| 195 library dart.collection; | 189 library dart.collection; |
| 196 | 190 |
| 197 abstract class HashMap<K, V> implements Map<K, V> {} | 191 abstract class HashMap<K, V> implements Map<K, V> {} |
| 198 abstract class LinkedHashMap<K, V> implements Map<K, V> {} | 192 abstract class LinkedHashMap<K, V> implements Map<K, V> {} |
| 199 '''); | 193 '''); |
| 200 | 194 |
| 201 static const MockSdkLibrary LIB_CONVERT = const MockSdkLibrary( | 195 static const MockSdkLibrary LIB_CONVERT = |
| 202 'dart:convert', | 196 const MockSdkLibrary('dart:convert', '/lib/convert/convert.dart', ''' |
| 203 '/lib/convert/convert.dart', | |
| 204 ''' | |
| 205 library dart.convert; | 197 library dart.convert; |
| 206 | 198 |
| 207 import 'dart:async'; | 199 import 'dart:async'; |
| 208 | 200 |
| 209 abstract class Converter<S, T> implements StreamTransformer {} | 201 abstract class Converter<S, T> implements StreamTransformer {} |
| 210 class JsonDecoder extends Converter<String, Object> {} | 202 class JsonDecoder extends Converter<String, Object> {} |
| 211 '''); | 203 '''); |
| 212 | 204 |
| 213 static const MockSdkLibrary LIB_MATH = const MockSdkLibrary( | 205 static const MockSdkLibrary LIB_MATH = |
| 214 'dart:math', | 206 const MockSdkLibrary('dart:math', '/lib/math/math.dart', ''' |
| 215 '/lib/math/math.dart', | |
| 216 ''' | |
| 217 library dart.math; | 207 library dart.math; |
| 218 const double E = 2.718281828459045; | 208 const double E = 2.718281828459045; |
| 219 const double PI = 3.1415926535897932; | 209 const double PI = 3.1415926535897932; |
| 220 const double LN10 = 2.302585092994046; | 210 const double LN10 = 2.302585092994046; |
| 221 T min<T extends num>(T a, T b) => null; | 211 T min<T extends num>(T a, T b) => null; |
| 222 T max<T extends num>(T a, T b) => null; | 212 T max<T extends num>(T a, T b) => null; |
| 223 external double cos(num radians); | 213 external double cos(num radians); |
| 224 external num pow(num x, num exponent); | 214 external num pow(num x, num exponent); |
| 225 external double sin(num radians); | 215 external double sin(num radians); |
| 226 external double sqrt(num x); | 216 external double sqrt(num x); |
| 227 class Random { | 217 class Random { |
| 228 bool nextBool() => true; | 218 bool nextBool() => true; |
| 229 double nextDouble() => 2.0; | 219 double nextDouble() => 2.0; |
| 230 int nextInt() => 1; | 220 int nextInt() => 1; |
| 231 } | 221 } |
| 232 '''); | 222 '''); |
| 233 | 223 |
| 234 static const MockSdkLibrary LIB_HTML = const MockSdkLibrary( | 224 static const MockSdkLibrary LIB_HTML = const MockSdkLibrary( |
| 235 'dart:html', | 225 'dart:html', '/lib/html/dartium/html_dartium.dart', ''' |
| 236 '/lib/html/dartium/html_dartium.dart', | |
| 237 ''' | |
| 238 library dart.html; | 226 library dart.html; |
| 239 class HtmlElement {} | 227 class HtmlElement {} |
| 240 '''); | 228 '''); |
| 241 | 229 |
| 242 static const MockSdkLibrary LIB_INTERNAL = const MockSdkLibrary( | 230 static const MockSdkLibrary LIB_INTERNAL = |
| 243 'dart:_internal', | 231 const MockSdkLibrary('dart:_internal', '/lib/internal/internal.dart', ''' |
| 244 '/lib/internal/internal.dart', | |
| 245 ''' | |
| 246 library dart._internal; | 232 library dart._internal; |
| 247 external void printToConsole(String line); | 233 external void printToConsole(String line); |
| 248 '''); | 234 '''); |
| 249 | 235 |
| 250 static const List<SdkLibrary> LIBRARIES = const [ | 236 static const List<SdkLibrary> LIBRARIES = const [ |
| 251 LIB_CORE, | 237 LIB_CORE, |
| 252 LIB_ASYNC, | 238 LIB_ASYNC, |
| 253 LIB_COLLECTION, | 239 LIB_COLLECTION, |
| 254 LIB_CONVERT, | 240 LIB_CONVERT, |
| 255 LIB_MATH, | 241 LIB_MATH, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 bool get isInternal => shortName.startsWith('dart:_'); | 429 bool get isInternal => shortName.startsWith('dart:_'); |
| 444 | 430 |
| 445 @override | 431 @override |
| 446 bool get isShared => throw unimplemented; | 432 bool get isShared => throw unimplemented; |
| 447 | 433 |
| 448 @override | 434 @override |
| 449 bool get isVmLibrary => throw unimplemented; | 435 bool get isVmLibrary => throw unimplemented; |
| 450 | 436 |
| 451 UnimplementedError get unimplemented => new UnimplementedError(); | 437 UnimplementedError get unimplemented => new UnimplementedError(); |
| 452 } | 438 } |
| OLD | NEW |