| 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 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 test_getUnitElement_notDart() async { | 1551 test_getUnitElement_notDart() async { |
| 1552 var path = _p('/test.txt'); | 1552 var path = _p('/test.txt'); |
| 1553 provider.newFile(path, 'class A {}'); | 1553 provider.newFile(path, 'class A {}'); |
| 1554 UnitElementResult unitResult = await driver.getUnitElement(path); | 1554 UnitElementResult unitResult = await driver.getUnitElement(path); |
| 1555 expect(unitResult, isNotNull); | 1555 expect(unitResult, isNotNull); |
| 1556 expect(unitResult.element.types.map((e) => e.name), ['A']); | 1556 expect(unitResult.element.types.map((e) => e.name), ['A']); |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 test_getUnitElementSignature() async { |
| 1560 var a = _p('/test/lib/a.dart'); |
| 1561 |
| 1562 provider.newFile(a, 'foo() {}'); |
| 1563 |
| 1564 String signature = await driver.getUnitElementSignature(a); |
| 1565 expect(signature, isNotNull); |
| 1566 |
| 1567 UnitElementResult unitResult = await driver.getUnitElement(a); |
| 1568 expect(unitResult.path, a); |
| 1569 expect(unitResult.signature, signature); |
| 1570 |
| 1571 provider.updateFile(a, 'bar() {}'); |
| 1572 driver.changeFile(a); |
| 1573 |
| 1574 String signature2 = await driver.getUnitElementSignature(a); |
| 1575 expect(signature2, isNotNull); |
| 1576 expect(signature2, isNot(signature)); |
| 1577 } |
| 1578 |
| 1559 test_hasFilesToAnalyze() async { | 1579 test_hasFilesToAnalyze() async { |
| 1560 // No files yet, nothing to analyze. | 1580 // No files yet, nothing to analyze. |
| 1561 expect(driver.hasFilesToAnalyze, isFalse); | 1581 expect(driver.hasFilesToAnalyze, isFalse); |
| 1562 | 1582 |
| 1563 // Add a new file, it should be analyzed. | 1583 // Add a new file, it should be analyzed. |
| 1564 addTestFile('main() {}', priority: false); | 1584 addTestFile('main() {}', priority: false); |
| 1565 expect(driver.hasFilesToAnalyze, isTrue); | 1585 expect(driver.hasFilesToAnalyze, isTrue); |
| 1566 | 1586 |
| 1567 // Wait for idle, nothing to do. | 1587 // Wait for idle, nothing to do. |
| 1568 await scheduler.waitForIdle(); | 1588 await scheduler.waitForIdle(); |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2336 * Return the [provider] specific path for the given Posix [path]. | 2356 * Return the [provider] specific path for the given Posix [path]. |
| 2337 */ | 2357 */ |
| 2338 String _p(String path) => provider.convertPath(path); | 2358 String _p(String path) => provider.convertPath(path); |
| 2339 | 2359 |
| 2340 static String _md5(String content) { | 2360 static String _md5(String content) { |
| 2341 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 2361 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 2342 } | 2362 } |
| 2343 } | 2363 } |
| 2344 | 2364 |
| 2345 class _SourceMock extends TypedMock implements Source {} | 2365 class _SourceMock extends TypedMock implements Source {} |
| OLD | NEW |