| 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 for creating mock versions of platform and internal libraries. | 5 // Library for creating mock versions of platform and internal libraries. |
| 6 | 6 |
| 7 library mock_libraries; | 7 library mock_libraries; |
| 8 | 8 |
| 9 const DEFAULT_PLATFORM_CONFIG = """ | 9 const DEFAULT_PLATFORM_CONFIG = """ |
| 10 [libraries] | 10 [libraries] |
| 11 core:core/core.dart | 11 core:core/core.dart |
| 12 async:async/async.dart | 12 async:async/async.dart |
| 13 _js_helper:_internal/js_runtime/lib/js_helper.dart | 13 _js_helper:_internal/js_runtime/lib/js_helper.dart |
| 14 _interceptors:_internal/js_runtime/lib/interceptors.dart | 14 _interceptors:_internal/js_runtime/lib/interceptors.dart |
| 15 _isolate_helper:_internal/js_runtime/lib/isolate_helper.dart | 15 _isolate_helper:_internal/js_runtime/lib/isolate_helper.dart |
| 16 """; | 16 """; |
| 17 | 17 |
| 18 String buildLibrarySource( | 18 String buildLibrarySource(Map<String, String> elementMap, |
| 19 Map<String, String> elementMap, | |
| 20 [Map<String, String> additionalElementMap = const <String, String>{}]) { | 19 [Map<String, String> additionalElementMap = const <String, String>{}]) { |
| 21 Map<String, String> map = new Map<String, String>.from(elementMap); | 20 Map<String, String> map = new Map<String, String>.from(elementMap); |
| 22 if (additionalElementMap != null) { | 21 if (additionalElementMap != null) { |
| 23 map.addAll(additionalElementMap); | 22 map.addAll(additionalElementMap); |
| 24 } | 23 } |
| 25 StringBuffer sb = new StringBuffer(); | 24 StringBuffer sb = new StringBuffer(); |
| 26 map.values.forEach((String element) { | 25 map.values.forEach((String element) { |
| 27 sb.write('$element\n'); | 26 sb.write('$element\n'); |
| 28 }); | 27 }); |
| 29 return sb.toString(); | 28 return sb.toString(); |
| 30 } | 29 } |
| 31 | 30 |
| 32 const Map<String, String> DEFAULT_CORE_LIBRARY = const <String, String>{ | 31 const Map<String, String> DEFAULT_CORE_LIBRARY = const <String, String>{ |
| 33 'bool': 'class bool {}', | 32 'bool': 'class bool {}', |
| 34 'Comparator': 'abstract class Comparator<T> {}', | 33 'Comparator': 'abstract class Comparator<T> {}', |
| 35 'DateTime': r''' | 34 'DateTime': r''' |
| 36 class DateTime { | 35 class DateTime { |
| 37 DateTime(year); | 36 DateTime(year); |
| 38 DateTime.utc(year); | 37 DateTime.utc(year); |
| 39 }''', | 38 }''', |
| 40 'Deprecated': r''' | 39 'Deprecated': r''' |
| 41 class Deprecated extends Object { | 40 class Deprecated extends Object { |
| 42 final String expires; | 41 final String expires; |
| 43 const Deprecated(this.expires); | 42 const Deprecated(this.expires); |
| 44 }''', | 43 }''', |
| 45 'deprecated': 'const Object deprecated = const Deprecated("next release");', | 44 'deprecated': 'const Object deprecated = const Deprecated("next release");', |
| 46 'double': r''' | 45 'double': r''' |
| 47 abstract class double extends num { | 46 abstract class double extends num { |
| 48 static var NAN = 0; | 47 static var NAN = 0; |
| 49 static parse(s) {} | 48 static parse(s) {} |
| 50 }''', | 49 }''', |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 'boolConversionCheck': 'boolConversionCheck(x) {}', | 130 'boolConversionCheck': 'boolConversionCheck(x) {}', |
| 132 'boolTypeCast': 'boolTypeCast(value) {}', | 131 'boolTypeCast': 'boolTypeCast(value) {}', |
| 133 'boolTypeCheck': 'boolTypeCheck(value) {}', | 132 'boolTypeCheck': 'boolTypeCheck(value) {}', |
| 134 'checkSubtype': 'checkSubtype(object, isField, checks, asField) {}', | 133 'checkSubtype': 'checkSubtype(object, isField, checks, asField) {}', |
| 135 'checkSubtypeOfRuntimeType': 'checkSubtypeOfRuntimeType(o, t) {}', | 134 'checkSubtypeOfRuntimeType': 'checkSubtypeOfRuntimeType(o, t) {}', |
| 136 'BoundClosure': r'''abstract class BoundClosure extends Closure { | 135 'BoundClosure': r'''abstract class BoundClosure extends Closure { |
| 137 var self; | 136 var self; |
| 138 var target; | 137 var target; |
| 139 var receiver; | 138 var receiver; |
| 140 }''', | 139 }''', |
| 141 'buildFunctionType': | 140 'buildFunctionType': r'''buildFunctionType(returnType, parameterTypes, |
| 142 r'''buildFunctionType(returnType, parameterTypes, | |
| 143 optionalParameterTypes) { | 141 optionalParameterTypes) { |
| 144 return new RuntimeFunctionType(); | 142 return new RuntimeFunctionType(); |
| 145 }''', | 143 }''', |
| 146 'buildInterfaceType': '''buildInterfaceType(rti, typeArguments) { | 144 'buildInterfaceType': '''buildInterfaceType(rti, typeArguments) { |
| 147 if (rti == null) return new RuntimeTypePlain(); | 145 if (rti == null) return new RuntimeTypePlain(); |
| 148 return new RuntimeTypeGeneric(); | 146 return new RuntimeTypeGeneric(); |
| 149 }''', | 147 }''', |
| 150 'buildNamedFunctionType': | 148 'buildNamedFunctionType': |
| 151 r'''buildNamedFunctionType(returnType, parameterTypes, | 149 r'''buildNamedFunctionType(returnType, parameterTypes, |
| 152 namedParameters) { | 150 namedParameters) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 final Type owner; | 255 final Type owner; |
| 258 final String name; | 256 final String name; |
| 259 final int bound; | 257 final int bound; |
| 260 const TypeVariable(this.owner, this.name, this.bound); | 258 const TypeVariable(this.owner, this.name, this.bound); |
| 261 }''', | 259 }''', |
| 262 'unwrapException': 'unwrapException(e) {}', | 260 'unwrapException': 'unwrapException(e) {}', |
| 263 'voidTypeCheck': 'voidTypeCheck(value) {}', | 261 'voidTypeCheck': 'voidTypeCheck(value) {}', |
| 264 'wrapException': 'wrapException(x) { return x; }', | 262 'wrapException': 'wrapException(x) { return x; }', |
| 265 'badMain': 'badMain() { throw "bad main"; }', | 263 'badMain': 'badMain() { throw "bad main"; }', |
| 266 'missingMain': 'missingMain() { throw "missing main"; }', | 264 'missingMain': 'missingMain() { throw "missing main"; }', |
| 267 'mainHasTooManyParameters': | 265 'mainHasTooManyParameters': 'mainHasTooManyParameters() ' |
| 268 'mainHasTooManyParameters() ' | |
| 269 '{ throw "main has too many parameters"; }', | 266 '{ throw "main has too many parameters"; }', |
| 270 }; | 267 }; |
| 271 | 268 |
| 272 const Map<String, String> DEFAULT_FOREIGN_HELPER_LIBRARY | 269 const Map<String, String> DEFAULT_FOREIGN_HELPER_LIBRARY = |
| 273 = const <String, String>{ | 270 const <String, String>{ |
| 274 'JS': r''' | 271 'JS': r''' |
| 275 dynamic JS(String typeDescription, String codeTemplate, | 272 dynamic JS(String typeDescription, String codeTemplate, |
| 276 [var arg0, var arg1, var arg2, var arg3, var arg4, var arg5, var arg6, | 273 [var arg0, var arg1, var arg2, var arg3, var arg4, var arg5, var arg6, |
| 277 var arg7, var arg8, var arg9, var arg10, var arg11]) {}''', | 274 var arg7, var arg8, var arg9, var arg10, var arg11]) {}''', |
| 278 }; | 275 }; |
| 279 | 276 |
| 280 const Map<String, String> DEFAULT_INTERCEPTORS_LIBRARY = const <String, String>{ | 277 const Map<String, String> DEFAULT_INTERCEPTORS_LIBRARY = const <String, String>{ |
| 281 'findIndexForNativeSubclassType': | 278 'findIndexForNativeSubclassType': 'findIndexForNativeSubclassType(type) {}', |
| 282 'findIndexForNativeSubclassType(type) {}', | |
| 283 'getDispatchProperty': 'getDispatchProperty(o) {}', | 279 'getDispatchProperty': 'getDispatchProperty(o) {}', |
| 284 'getInterceptor': 'getInterceptor(x) {}', | 280 'getInterceptor': 'getInterceptor(x) {}', |
| 285 'getNativeInterceptor': 'getNativeInterceptor(x) {}', | 281 'getNativeInterceptor': 'getNativeInterceptor(x) {}', |
| 286 'initializeDispatchProperty': 'initializeDispatchProperty(f,p,i) {}', | 282 'initializeDispatchProperty': 'initializeDispatchProperty(f,p,i) {}', |
| 287 'initializeDispatchPropertyCSP': 'initializeDispatchPropertyCSP(f,p,i) {}', | 283 'initializeDispatchPropertyCSP': 'initializeDispatchPropertyCSP(f,p,i) {}', |
| 288 'Interceptor': r''' | 284 'Interceptor': r''' |
| 289 class Interceptor { | 285 class Interceptor { |
| 290 toString() {} | 286 toString() {} |
| 291 bool operator==(other) => identical(this, other); | 287 bool operator==(other) => identical(this, other); |
| 292 get hashCode => throw "Interceptor.hashCode not implemented."; | 288 get hashCode => throw "Interceptor.hashCode not implemented."; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 320 abstract class JSIndexable { | 316 abstract class JSIndexable { |
| 321 get length; | 317 get length; |
| 322 operator[](index); | 318 operator[](index); |
| 323 }''', | 319 }''', |
| 324 'JSInt': r''' | 320 'JSInt': r''' |
| 325 class JSInt extends JSNumber implements int { | 321 class JSInt extends JSNumber implements int { |
| 326 operator~() => this; | 322 operator~() => this; |
| 327 }''', | 323 }''', |
| 328 'JSMutableArray': | 324 'JSMutableArray': |
| 329 'class JSMutableArray extends JSArray implements JSMutableIndexable {}', | 325 'class JSMutableArray extends JSArray implements JSMutableIndexable {}', |
| 330 'JSUnmodifiableArray': | 326 'JSUnmodifiableArray': 'class JSUnmodifiableArray extends JSArray {}', |
| 331 'class JSUnmodifiableArray extends JSArray {}', | |
| 332 'JSMutableIndexable': | 327 'JSMutableIndexable': |
| 333 'abstract class JSMutableIndexable extends JSIndexable {}', | 328 'abstract class JSMutableIndexable extends JSIndexable {}', |
| 334 'JSPositiveInt': 'class JSPositiveInt extends JSInt {}', | 329 'JSPositiveInt': 'class JSPositiveInt extends JSInt {}', |
| 335 'JSNull': r''' | 330 'JSNull': r''' |
| 336 class JSNull extends Interceptor { | 331 class JSNull extends Interceptor { |
| 337 bool operator==(other) => identical(null, other); | 332 bool operator==(other) => identical(null, other); |
| 338 get hashCode => throw "JSNull.hashCode not implemented."; | 333 get hashCode => throw "JSNull.hashCode not implemented."; |
| 339 String toString() => 'Null'; | 334 String toString() => 'Null'; |
| 340 Type get runtimeType => null; | 335 Type get runtimeType => null; |
| 341 noSuchMethod(x) => super.noSuchMethod(x); | 336 noSuchMethod(x) => super.noSuchMethod(x); |
| 342 }''', | 337 }''', |
| 343 'JSNumber': r''' | 338 'JSNumber': r''' |
| 344 class JSNumber extends Interceptor implements num { | 339 class JSNumber extends Interceptor implements num { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 const Map<String, String> DEFAULT_ISOLATE_HELPER_LIBRARY = | 397 const Map<String, String> DEFAULT_ISOLATE_HELPER_LIBRARY = |
| 403 const <String, String>{ | 398 const <String, String>{ |
| 404 'startRootIsolate': 'void startRootIsolate(entry, args) {}', | 399 'startRootIsolate': 'void startRootIsolate(entry, args) {}', |
| 405 '_currentIsolate': 'var _currentIsolate;', | 400 '_currentIsolate': 'var _currentIsolate;', |
| 406 '_callInIsolate': 'var _callInIsolate;', | 401 '_callInIsolate': 'var _callInIsolate;', |
| 407 '_WorkerBase': 'class _WorkerBase {}', | 402 '_WorkerBase': 'class _WorkerBase {}', |
| 408 }; | 403 }; |
| 409 | 404 |
| 410 const Map<String, String> DEFAULT_ASYNC_LIBRARY = const <String, String>{ | 405 const Map<String, String> DEFAULT_ASYNC_LIBRARY = const <String, String>{ |
| 411 'DeferredLibrary': 'class DeferredLibrary {}', | 406 'DeferredLibrary': 'class DeferredLibrary {}', |
| 412 'Future': | 407 'Future': ''' |
| 413 ''' | |
| 414 class Future<T> { | 408 class Future<T> { |
| 415 Future.value([value]); | 409 Future.value([value]); |
| 416 } | 410 } |
| 417 ''', | 411 ''', |
| 418 'Stream': 'class Stream<T> {}', | 412 'Stream': 'class Stream<T> {}', |
| 419 'Completer': 'class Completer<T> {}', | 413 'Completer': 'class Completer<T> {}', |
| 420 'StreamIterator': 'class StreamIterator<T> {}', | 414 'StreamIterator': 'class StreamIterator<T> {}', |
| 421 }; | 415 }; |
| 422 | 416 |
| 423 /// These members are only needed when async/await is used. | 417 /// These members are only needed when async/await is used. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 453 |
| 460 const LookupMap(this._entries, [this._nestedMaps = const []]) | 454 const LookupMap(this._entries, [this._nestedMaps = const []]) |
| 461 : _key = null, _value = null; | 455 : _key = null, _value = null; |
| 462 | 456 |
| 463 const LookupMap.pair(this._key, this._value) | 457 const LookupMap.pair(this._key, this._value) |
| 464 : _entries = const [], _nestedMaps = const []; | 458 : _entries = const [], _nestedMaps = const []; |
| 465 V operator[](K k) => null; | 459 V operator[](K k) => null; |
| 466 }''', | 460 }''', |
| 467 '_version': 'const _version = "0.0.1+1";', | 461 '_version': 'const _version = "0.0.1+1";', |
| 468 }; | 462 }; |
| OLD | NEW |