| 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/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/sdk.dart'; | 10 import 'package:analyzer/src/generated/sdk.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 | 12 |
| 13 | 13 |
| 14 class MockSdk implements DartSdk { | 14 class MockSdk implements DartSdk { |
| 15 final resource.MemoryResourceProvider provider = | 15 final resource.MemoryResourceProvider provider = |
| 16 new resource.MemoryResourceProvider(); | 16 new resource.MemoryResourceProvider(); |
| 17 | 17 |
| 18 MockSdk() { | 18 MockSdk() { |
| 19 // TODO(paulberry): Add to this as needed. | 19 // TODO(paulberry): Add to this as needed. |
| 20 const Map<String, String> pathToContent = const { | 20 const Map<String, String> pathToContent = const { |
| 21 "/lib/core/core.dart": ''' | 21 "/lib/core/core.dart": ''' |
| 22 library dart.core; | 22 library dart.core; |
| 23 class Object {} | 23 class Object {} |
| 24 class Function {} | 24 class Function {} |
| 25 class StackTrace {} | 25 class StackTrace {} |
| 26 class Symbol {} | 26 class Symbol {} |
| 27 class Type {} | 27 class Type {} |
| 28 | 28 |
| 29 class String extends Object {} | 29 abstract class Comparable<T> { |
| 30 int compareTo(T other); |
| 31 } |
| 32 |
| 33 class String implements Comparable<String> { |
| 34 } |
| 35 |
| 30 class bool extends Object {} | 36 class bool extends Object {} |
| 31 abstract class num extends Object { | 37 abstract class num implements Comparable<num> { |
| 32 num operator +(num other); | 38 num operator +(num other); |
| 33 num operator -(num other); | 39 num operator -(num other); |
| 34 num operator *(num other); | 40 num operator *(num other); |
| 35 num operator /(num other); | 41 num operator /(num other); |
| 36 int toInt(); | 42 int toInt(); |
| 37 } | 43 } |
| 38 abstract class int extends num { | 44 abstract class int extends num { |
| 39 int operator -(); | 45 int operator -(); |
| 40 } | 46 } |
| 41 class double extends num {} | 47 class double extends num {} |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 if (path != null) { | 136 if (path != null) { |
| 131 resource.File file = provider.getResource(path); | 137 resource.File file = provider.getResource(path); |
| 132 return file.createSource(UriKind.DART_URI); | 138 return file.createSource(UriKind.DART_URI); |
| 133 } | 139 } |
| 134 | 140 |
| 135 // If we reach here then we tried to use a dartUri that's not in the | 141 // If we reach here then we tried to use a dartUri that's not in the |
| 136 // table above. | 142 // table above. |
| 137 throw unimplemented; | 143 throw unimplemented; |
| 138 } | 144 } |
| 139 } | 145 } |
| OLD | NEW |