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/context.dart' as newContext; | 9 import 'package:analyzer/src/context/context.dart' as newContext; |
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 | 13 |
14 class MockSdk implements DartSdk { | 14 class MockSdk implements DartSdk { |
15 static const _MockSdkLibrary LIB_CORE = const _MockSdkLibrary('dart:core', | 15 static const _MockSdkLibrary LIB_CORE = const _MockSdkLibrary( |
16 '/lib/core/core.dart', ''' | 16 'dart:core', |
| 17 '/lib/core/core.dart', |
| 18 ''' |
17 library dart.core; | 19 library dart.core; |
18 | 20 |
19 import 'dart:async'; | 21 import 'dart:async'; |
20 | 22 |
21 class Object { | 23 class Object { |
22 bool operator ==(other) => identical(this, other); | 24 bool operator ==(other) => identical(this, other); |
23 String toString() => 'a string'; | 25 String toString() => 'a string'; |
24 int get hashCode => 0; | 26 int get hashCode => 0; |
25 } | 27 } |
26 | 28 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 external bool identical(Object a, Object b); | 101 external bool identical(Object a, Object b); |
100 | 102 |
101 void print(Object object) {} | 103 void print(Object object) {} |
102 | 104 |
103 class _Override { | 105 class _Override { |
104 const _Override(); | 106 const _Override(); |
105 } | 107 } |
106 const Object override = const _Override(); | 108 const Object override = const _Override(); |
107 '''); | 109 '''); |
108 | 110 |
109 static const _MockSdkLibrary LIB_ASYNC = const _MockSdkLibrary('dart:async', | 111 static const _MockSdkLibrary LIB_ASYNC = const _MockSdkLibrary( |
110 '/lib/async/async.dart', ''' | 112 'dart:async', |
| 113 '/lib/async/async.dart', |
| 114 ''' |
111 library dart.async; | 115 library dart.async; |
112 | 116 |
113 import 'dart:math'; | 117 import 'dart:math'; |
114 | 118 |
115 class Future<T> { | 119 class Future<T> { |
116 factory Future.delayed(Duration duration, [T computation()]) => null; | 120 factory Future.delayed(Duration duration, [T computation()]) => null; |
117 factory Future.value([value]) => null; | 121 factory Future.value([value]) => null; |
118 static Future wait(List<Future> futures) => null; | 122 static Future wait(List<Future> futures) => null; |
119 } | 123 } |
120 | 124 |
121 class Stream<T> {} | 125 class Stream<T> {} |
122 abstract class StreamTransformer<S, T> {} | 126 abstract class StreamTransformer<S, T> {} |
123 '''); | 127 '''); |
124 | 128 |
125 static const _MockSdkLibrary LIB_COLLECTION = const _MockSdkLibrary( | 129 static const _MockSdkLibrary LIB_COLLECTION = const _MockSdkLibrary( |
126 'dart:collection', '/lib/collection/collection.dart', ''' | 130 'dart:collection', |
| 131 '/lib/collection/collection.dart', |
| 132 ''' |
127 library dart.collection; | 133 library dart.collection; |
128 | 134 |
129 abstract class HashMap<K, V> implements Map<K, V> {} | 135 abstract class HashMap<K, V> implements Map<K, V> {} |
130 '''); | 136 '''); |
131 | 137 |
132 static const _MockSdkLibrary LIB_CONVERT = const _MockSdkLibrary( | 138 static const _MockSdkLibrary LIB_CONVERT = const _MockSdkLibrary( |
133 'dart:convert', '/lib/convert/convert.dart', ''' | 139 'dart:convert', |
| 140 '/lib/convert/convert.dart', |
| 141 ''' |
134 library dart.convert; | 142 library dart.convert; |
135 | 143 |
136 import 'dart:async'; | 144 import 'dart:async'; |
137 | 145 |
138 abstract class Converter<S, T> implements StreamTransformer {} | 146 abstract class Converter<S, T> implements StreamTransformer {} |
139 class JsonDecoder extends Converter<String, Object> {} | 147 class JsonDecoder extends Converter<String, Object> {} |
140 '''); | 148 '''); |
141 | 149 |
142 static const _MockSdkLibrary LIB_MATH = const _MockSdkLibrary('dart:math', | 150 static const _MockSdkLibrary LIB_MATH = const _MockSdkLibrary( |
143 '/lib/math/math.dart', ''' | 151 'dart:math', |
| 152 '/lib/math/math.dart', |
| 153 ''' |
144 library dart.math; | 154 library dart.math; |
145 const double E = 2.718281828459045; | 155 const double E = 2.718281828459045; |
146 const double PI = 3.1415926535897932; | 156 const double PI = 3.1415926535897932; |
147 const double LN10 = 2.302585092994046; | 157 const double LN10 = 2.302585092994046; |
148 num min(num a, num b) => 0; | 158 num min(num a, num b) => 0; |
149 num max(num a, num b) => 0; | 159 num max(num a, num b) => 0; |
150 external double cos(num x); | 160 external double cos(num x); |
151 external double sin(num x); | 161 external double sin(num x); |
152 external double sqrt(num x); | 162 external double sqrt(num x); |
153 class Random { | 163 class Random { |
154 bool nextBool() => true; | 164 bool nextBool() => true; |
155 double nextDouble() => 2.0; | 165 double nextDouble() => 2.0; |
156 int nextInt() => 1; | 166 int nextInt() => 1; |
157 } | 167 } |
158 '''); | 168 '''); |
159 | 169 |
160 static const _MockSdkLibrary LIB_HTML = const _MockSdkLibrary('dart:html', | 170 static const _MockSdkLibrary LIB_HTML = const _MockSdkLibrary( |
161 '/lib/html/dartium/html_dartium.dart', ''' | 171 'dart:html', |
| 172 '/lib/html/dartium/html_dartium.dart', |
| 173 ''' |
162 library dart.html; | 174 library dart.html; |
163 class HtmlElement {} | 175 class HtmlElement {} |
164 '''); | 176 '''); |
165 | 177 |
166 static const List<SdkLibrary> LIBRARIES = const [ | 178 static const List<SdkLibrary> LIBRARIES = const [ |
167 LIB_CORE, | 179 LIB_CORE, |
168 LIB_ASYNC, | 180 LIB_ASYNC, |
169 LIB_COLLECTION, | 181 LIB_COLLECTION, |
170 LIB_CONVERT, | 182 LIB_CONVERT, |
171 LIB_MATH, | 183 LIB_MATH, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 bool get isInternal => throw unimplemented; | 323 bool get isInternal => throw unimplemented; |
312 | 324 |
313 @override | 325 @override |
314 bool get isShared => throw unimplemented; | 326 bool get isShared => throw unimplemented; |
315 | 327 |
316 @override | 328 @override |
317 bool get isVmLibrary => throw unimplemented; | 329 bool get isVmLibrary => throw unimplemented; |
318 | 330 |
319 UnimplementedError get unimplemented => new UnimplementedError(); | 331 UnimplementedError get unimplemented => new UnimplementedError(); |
320 } | 332 } |
OLD | NEW |