OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 analyzer.test.driver; | 5 library analyzer.test.driver; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 393 |
394 var f = result.unit.declarations[0] as FunctionDeclaration; | 394 var f = result.unit.declarations[0] as FunctionDeclaration; |
395 expect(f.name.staticType.toString(), '() → int'); | 395 expect(f.name.staticType.toString(), '() → int'); |
396 expect(f.returnType.type.toString(), 'int'); | 396 expect(f.returnType.type.toString(), 'int'); |
397 | 397 |
398 // The same result is also received through the stream. | 398 // The same result is also received through the stream. |
399 await _waitForIdle(); | 399 await _waitForIdle(); |
400 expect(allResults, [result]); | 400 expect(allResults, [result]); |
401 } | 401 } |
402 | 402 |
| 403 test_getFilesReferencingName() async { |
| 404 var a = _p('/test/bin/a.dart'); |
| 405 var b = _p('/test/bin/b.dart'); |
| 406 var c = _p('/test/bin/c.dart'); |
| 407 var d = _p('/test/bin/d.dart'); |
| 408 var e = _p('/test/bin/e.dart'); |
| 409 |
| 410 provider.newFile(a, 'class A {}'); |
| 411 provider.newFile(b, "import 'a.dart'; A a;"); |
| 412 provider.newFile(c, "import 'a.dart'; var a = new A();"); |
| 413 provider.newFile(d, "classs A{} A a;"); |
| 414 provider.newFile(e, "import 'a.dart'; main() {}"); |
| 415 |
| 416 driver.addFile(a); |
| 417 driver.addFile(b); |
| 418 driver.addFile(c); |
| 419 driver.addFile(d); |
| 420 driver.addFile(e); |
| 421 |
| 422 // 'b.dart' references an external 'A'. |
| 423 // 'c.dart' references an external 'A'. |
| 424 // 'd.dart' references the local 'A'. |
| 425 // 'e.dart' does not reference 'A' at all. |
| 426 List<String> files = await driver.getFilesReferencingName('A'); |
| 427 expect(files, unorderedEquals([b, c])); |
| 428 |
| 429 // We get the same results second time. |
| 430 List<String> files2 = await driver.getFilesReferencingName('A'); |
| 431 expect(files2, unorderedEquals([b, c])); |
| 432 } |
| 433 |
403 test_getResult_constants_defaultParameterValue_localFunction() async { | 434 test_getResult_constants_defaultParameterValue_localFunction() async { |
404 var a = _p('/test/bin/a.dart'); | 435 var a = _p('/test/bin/a.dart'); |
405 var b = _p('/test/bin/b.dart'); | 436 var b = _p('/test/bin/b.dart'); |
406 provider.newFile(a, 'const C = 42;'); | 437 provider.newFile(a, 'const C = 42;'); |
407 provider.newFile( | 438 provider.newFile( |
408 b, | 439 b, |
409 r''' | 440 r''' |
410 import 'a.dart'; | 441 import 'a.dart'; |
411 main() { | 442 main() { |
412 foo({int p: C}) {} | 443 foo({int p: C}) {} |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 String _p(String path) => provider.convertPath(path); | 1221 String _p(String path) => provider.convertPath(path); |
1191 | 1222 |
1192 Future<Null> _waitForIdle() async { | 1223 Future<Null> _waitForIdle() async { |
1193 await idleStatusMonitor.signal; | 1224 await idleStatusMonitor.signal; |
1194 } | 1225 } |
1195 | 1226 |
1196 static String _md5(String content) { | 1227 static String _md5(String content) { |
1197 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 1228 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
1198 } | 1229 } |
1199 } | 1230 } |
OLD | NEW |