| 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 test.src.mock_sdk; | 5 library test.src.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/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/context/context.dart'; | 10 import 'package:analyzer/src/context/context.dart'; |
| 11 import 'package:analyzer/src/generated/engine.dart' | 11 import 'package:analyzer/src/generated/engine.dart' |
| 12 show AnalysisEngine, ChangeSet; | 12 show AnalysisEngine, ChangeSet; |
| 13 import 'package:analyzer/src/generated/sdk.dart'; | 13 import 'package:analyzer/src/generated/sdk.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
| 15 | 15 |
| 16 class MockSdk implements DartSdk { | 16 class MockSdk implements DartSdk { |
| 17 static const _MockSdkLibrary LIB_CORE = const _MockSdkLibrary('dart:core', | 17 static const _MockSdkLibrary LIB_CORE = const _MockSdkLibrary( |
| 18 '/lib/core/core.dart', ''' | 18 'dart:core', |
| 19 '/lib/core/core.dart', |
| 20 ''' |
| 19 library dart.core; | 21 library dart.core; |
| 20 | 22 |
| 21 import 'dart:async'; | 23 import 'dart:async'; |
| 22 | 24 |
| 23 class Object { | 25 class Object { |
| 24 bool operator ==(other) => identical(this, other); | 26 bool operator ==(other) => identical(this, other); |
| 25 String toString() => 'a string'; | 27 String toString() => 'a string'; |
| 26 int get hashCode => 0; | 28 int get hashCode => 0; |
| 27 } | 29 } |
| 28 | 30 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 external bool identical(Object a, Object b); | 103 external bool identical(Object a, Object b); |
| 102 | 104 |
| 103 void print(Object object) {} | 105 void print(Object object) {} |
| 104 | 106 |
| 105 class _Override { | 107 class _Override { |
| 106 const _Override(); | 108 const _Override(); |
| 107 } | 109 } |
| 108 const Object override = const _Override(); | 110 const Object override = const _Override(); |
| 109 '''); | 111 '''); |
| 110 | 112 |
| 111 static const _MockSdkLibrary LIB_ASYNC = const _MockSdkLibrary('dart:async', | 113 static const _MockSdkLibrary LIB_ASYNC = const _MockSdkLibrary( |
| 112 '/lib/async/async.dart', ''' | 114 'dart:async', |
| 115 '/lib/async/async.dart', |
| 116 ''' |
| 113 library dart.async; | 117 library dart.async; |
| 114 | 118 |
| 115 import 'dart:math'; | 119 import 'dart:math'; |
| 116 | 120 |
| 117 class Future<T> { | 121 class Future<T> { |
| 118 factory Future.delayed(Duration duration, [T computation()]) => null; | 122 factory Future.delayed(Duration duration, [T computation()]) => null; |
| 119 factory Future.value([value]) => null; | 123 factory Future.value([value]) => null; |
| 120 static Future wait(List<Future> futures) => null; | 124 static Future wait(List<Future> futures) => null; |
| 121 } | 125 } |
| 122 | 126 |
| 123 class Stream<T> {} | 127 class Stream<T> {} |
| 124 abstract class StreamTransformer<S, T> {} | 128 abstract class StreamTransformer<S, T> {} |
| 125 '''); | 129 '''); |
| 126 | 130 |
| 127 static const _MockSdkLibrary LIB_COLLECTION = const _MockSdkLibrary( | 131 static const _MockSdkLibrary LIB_COLLECTION = const _MockSdkLibrary( |
| 128 'dart:collection', '/lib/collection/collection.dart', ''' | 132 'dart:collection', |
| 133 '/lib/collection/collection.dart', |
| 134 ''' |
| 129 library dart.collection; | 135 library dart.collection; |
| 130 | 136 |
| 131 abstract class HashMap<K, V> implements Map<K, V> {} | 137 abstract class HashMap<K, V> implements Map<K, V> {} |
| 132 '''); | 138 '''); |
| 133 | 139 |
| 134 static const _MockSdkLibrary LIB_CONVERT = const _MockSdkLibrary( | 140 static const _MockSdkLibrary LIB_CONVERT = const _MockSdkLibrary( |
| 135 'dart:convert', '/lib/convert/convert.dart', ''' | 141 'dart:convert', |
| 142 '/lib/convert/convert.dart', |
| 143 ''' |
| 136 library dart.convert; | 144 library dart.convert; |
| 137 | 145 |
| 138 import 'dart:async'; | 146 import 'dart:async'; |
| 139 | 147 |
| 140 abstract class Converter<S, T> implements StreamTransformer {} | 148 abstract class Converter<S, T> implements StreamTransformer {} |
| 141 class JsonDecoder extends Converter<String, Object> {} | 149 class JsonDecoder extends Converter<String, Object> {} |
| 142 '''); | 150 '''); |
| 143 | 151 |
| 144 static const _MockSdkLibrary LIB_MATH = const _MockSdkLibrary('dart:math', | 152 static const _MockSdkLibrary LIB_MATH = const _MockSdkLibrary( |
| 145 '/lib/math/math.dart', ''' | 153 'dart:math', |
| 154 '/lib/math/math.dart', |
| 155 ''' |
| 146 library dart.math; | 156 library dart.math; |
| 147 const double E = 2.718281828459045; | 157 const double E = 2.718281828459045; |
| 148 const double PI = 3.1415926535897932; | 158 const double PI = 3.1415926535897932; |
| 149 const double LN10 = 2.302585092994046; | 159 const double LN10 = 2.302585092994046; |
| 150 num min(num a, num b) => 0; | 160 num min(num a, num b) => 0; |
| 151 num max(num a, num b) => 0; | 161 num max(num a, num b) => 0; |
| 152 external double cos(num x); | 162 external double cos(num x); |
| 153 external double sin(num x); | 163 external double sin(num x); |
| 154 external double sqrt(num x); | 164 external double sqrt(num x); |
| 155 class Random { | 165 class Random { |
| 156 bool nextBool() => true; | 166 bool nextBool() => true; |
| 157 double nextDouble() => 2.0; | 167 double nextDouble() => 2.0; |
| 158 int nextInt() => 1; | 168 int nextInt() => 1; |
| 159 } | 169 } |
| 160 '''); | 170 '''); |
| 161 | 171 |
| 162 static const _MockSdkLibrary LIB_HTML = const _MockSdkLibrary('dart:html', | 172 static const _MockSdkLibrary LIB_HTML = const _MockSdkLibrary( |
| 163 '/lib/html/dartium/html_dartium.dart', ''' | 173 'dart:html', |
| 174 '/lib/html/dartium/html_dartium.dart', |
| 175 ''' |
| 164 library dart.html; | 176 library dart.html; |
| 165 class HtmlElement {} | 177 class HtmlElement {} |
| 166 '''); | 178 '''); |
| 167 | 179 |
| 168 static const List<SdkLibrary> LIBRARIES = const [ | 180 static const List<SdkLibrary> LIBRARIES = const [ |
| 169 LIB_CORE, | 181 LIB_CORE, |
| 170 LIB_ASYNC, | 182 LIB_ASYNC, |
| 171 LIB_COLLECTION, | 183 LIB_COLLECTION, |
| 172 LIB_CONVERT, | 184 LIB_CONVERT, |
| 173 LIB_MATH, | 185 LIB_MATH, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 @override | 340 @override |
| 329 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 341 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
| 330 if (factory == null) { | 342 if (factory == null) { |
| 331 return super.createCacheFromSourceFactory(factory); | 343 return super.createCacheFromSourceFactory(factory); |
| 332 } | 344 } |
| 333 return new AnalysisCache(<CachePartition>[ | 345 return new AnalysisCache(<CachePartition>[ |
| 334 AnalysisEngine.instance.partitionManager_new.forSdk(sdk) | 346 AnalysisEngine.instance.partitionManager_new.forSdk(sdk) |
| 335 ]); | 347 ]); |
| 336 } | 348 } |
| 337 } | 349 } |
| OLD | NEW |