Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
| 6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
| 7 library test.src.task.strong.strong_test_helper; | 7 library test.src.task.strong.strong_test_helper; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 | 363 |
| 364 bool get isInSystemLibrary => true; | 364 bool get isInSystemLibrary => true; |
| 365 | 365 |
| 366 Source resolveRelative(Uri relativeUri) => | 366 Source resolveRelative(Uri relativeUri) => |
| 367 throw new UnsupportedError('not expecting relative urls in dart: mocks'); | 367 throw new UnsupportedError('not expecting relative urls in dart: mocks'); |
| 368 | 368 |
| 369 Uri resolveRelativeUri(Uri relativeUri) => | 369 Uri resolveRelativeUri(Uri relativeUri) => |
| 370 throw new UnsupportedError('not expecting relative urls in dart: mocks'); | 370 throw new UnsupportedError('not expecting relative urls in dart: mocks'); |
| 371 } | 371 } |
| 372 | 372 |
| 373 // TODO(jmesserly): can we reuse the same mock SDK as Analyzer tests? | |
|
Brian Wilkerson
2015/11/19 00:10:17
I certainly hope so! We control both.
| |
| 373 /// Sample mock SDK sources. | 374 /// Sample mock SDK sources. |
| 374 final Map<String, String> mockSdkSources = { | 375 final Map<String, String> mockSdkSources = { |
| 375 // The list of types below is derived from: | 376 // The list of types below is derived from: |
| 376 // * types we use via our smoke queries, including HtmlElement and | 377 // * types we use via our smoke queries, including HtmlElement and |
| 377 // types from `_typeHandlers` (deserialize.dart) | 378 // types from `_typeHandlers` (deserialize.dart) |
| 378 // * types that are used internally by the resolver (see | 379 // * types that are used internally by the resolver (see |
| 379 // _initializeFrom in resolver.dart). | 380 // _initializeFrom in resolver.dart). |
| 380 'dart:core': ''' | 381 'dart:core': ''' |
| 381 library dart.core; | 382 library dart.core; |
| 382 | 383 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 412 final String expires; | 413 final String expires; |
| 413 const Deprecated(this.expires); | 414 const Deprecated(this.expires); |
| 414 } | 415 } |
| 415 const Object deprecated = const Deprecated("next release"); | 416 const Object deprecated = const Deprecated("next release"); |
| 416 class _Override { const _Override(); } | 417 class _Override { const _Override(); } |
| 417 const Object override = const _Override(); | 418 const Object override = const _Override(); |
| 418 class _Proxy { const _Proxy(); } | 419 class _Proxy { const _Proxy(); } |
| 419 const Object proxy = const _Proxy(); | 420 const Object proxy = const _Proxy(); |
| 420 | 421 |
| 421 class Iterable<E> { | 422 class Iterable<E> { |
| 422 fold(initialValue, combine(previousValue, E element)) {} | 423 Iterable/*<R>*/ map/*<R>*/(/*=R*/ f(E e)); |
| 423 Iterable map(f(E element)) {} | 424 |
| 425 /*=R*/ fold/*<R>*/(/*=R*/ initialValue, | |
| 426 /*=R*/ combine(/*=R*/ previousValue, E element)); | |
| 424 } | 427 } |
| 425 class List<E> implements Iterable<E> { | 428 class List<E> implements Iterable<E> { |
| 426 List([int length]); | 429 List([int length]); |
| 427 List.filled(int length, E fill); | 430 List.filled(int length, E fill); |
| 428 } | 431 } |
| 429 class Map<K, V> { | 432 class Map<K, V> { |
| 430 Iterable<K> get keys {} | 433 Iterable<K> get keys {} |
| 431 } | 434 } |
| 432 ''', | 435 ''', |
| 433 'dart:async': ''' | 436 'dart:async': ''' |
| 434 class Future<T> { | 437 class Future<T> { |
| 435 Future(computation()) {} | 438 Future(computation()) {} |
| 436 Future.value(T t) {} | 439 Future.value(T t) {} |
| 437 Future then(onValue(T value)) {} | 440 static Future<List/*<T>*/> wait/*<T>*/( |
| 438 static Future<List> wait(Iterable<Future> futures) {} | 441 Iterable<Future/*<T>*/> futures) => null; |
| 442 Future/*<R>*/ then/*<R>*/(/*=R*/ onValue(T value)) => null; | |
| 439 } | 443 } |
| 440 class Stream<T> {} | 444 class Stream<T> {} |
| 441 ''', | 445 ''', |
| 442 'dart:html': ''' | 446 'dart:html': ''' |
| 443 library dart.html; | 447 library dart.html; |
| 444 class HtmlElement {} | 448 class HtmlElement {} |
| 445 ''', | 449 ''', |
| 446 'dart:math': ''' | 450 'dart:math': ''' |
| 447 library dart.math; | 451 library dart.math; |
| 448 class Random { | 452 class Random { |
| 449 bool nextBool() {} | 453 bool nextBool() {} |
| 450 } | 454 } |
| 451 num min(num x, num y) {} | 455 num/*=T*/ min/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) => null; |
| 452 num max(num x, num y) {} | 456 num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) => null; |
| 453 ''', | 457 ''', |
| 454 }; | 458 }; |
| 455 | 459 |
| 456 /// Returns all libraries transitively imported or exported from [start]. | 460 /// Returns all libraries transitively imported or exported from [start]. |
| 457 List<LibraryElement> reachableLibraries(LibraryElement start) { | 461 List<LibraryElement> reachableLibraries(LibraryElement start) { |
| 458 var results = <LibraryElement>[]; | 462 var results = <LibraryElement>[]; |
| 459 var seen = new Set(); | 463 var seen = new Set(); |
| 460 void find(LibraryElement lib) { | 464 void find(LibraryElement lib) { |
| 461 if (seen.contains(lib)) return; | 465 if (seen.contains(lib)) return; |
| 462 seen.add(lib); | 466 seen.add(lib); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 491 if (levelName == 'warning') return _MAGENTA_COLOR; | 495 if (levelName == 'warning') return _MAGENTA_COLOR; |
| 492 if (levelName == 'info') return _CYAN_COLOR; | 496 if (levelName == 'info') return _CYAN_COLOR; |
| 493 return null; | 497 return null; |
| 494 } | 498 } |
| 495 | 499 |
| 496 const String _RED_COLOR = '\u001b[31m'; | 500 const String _RED_COLOR = '\u001b[31m'; |
| 497 const String _MAGENTA_COLOR = '\u001b[35m'; | 501 const String _MAGENTA_COLOR = '\u001b[35m'; |
| 498 const String _CYAN_COLOR = '\u001b[36m'; | 502 const String _CYAN_COLOR = '\u001b[36m'; |
| 499 const String GREEN_COLOR = '\u001b[32m'; | 503 const String GREEN_COLOR = '\u001b[32m'; |
| 500 const String NO_COLOR = '\u001b[0m'; | 504 const String NO_COLOR = '\u001b[0m'; |
| OLD | NEW |