| 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 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 | 1533 |
| 1534 test_getUnitElement() async { | 1534 test_getUnitElement() async { |
| 1535 String content = r''' | 1535 String content = r''' |
| 1536 foo(int p) {} | 1536 foo(int p) {} |
| 1537 main() { | 1537 main() { |
| 1538 foo(42); | 1538 foo(42); |
| 1539 } | 1539 } |
| 1540 '''; | 1540 '''; |
| 1541 addTestFile(content); | 1541 addTestFile(content); |
| 1542 | 1542 |
| 1543 CompilationUnitElement unitElement = await driver.getUnitElement(testFile); | 1543 UnitElementResult unitResult = await driver.getUnitElement(testFile); |
| 1544 expect(unitElement, isNotNull); | 1544 expect(unitResult, isNotNull); |
| 1545 CompilationUnitElement unitElement = unitResult.element; |
| 1545 expect(unitElement.source.fullName, testFile); | 1546 expect(unitElement.source.fullName, testFile); |
| 1546 expect(unitElement.functions.map((c) => c.name), | 1547 expect(unitElement.functions.map((c) => c.name), |
| 1547 unorderedEquals(['foo', 'main'])); | 1548 unorderedEquals(['foo', 'main'])); |
| 1548 } | 1549 } |
| 1549 | 1550 |
| 1550 test_getUnitElement_notDart() async { | 1551 test_getUnitElement_notDart() async { |
| 1551 var path = _p('/test.txt'); | 1552 var path = _p('/test.txt'); |
| 1552 provider.newFile(path, 'class A {}'); | 1553 provider.newFile(path, 'class A {}'); |
| 1553 CompilationUnitElement unit = await driver.getUnitElement(path); | 1554 UnitElementResult unitResult = await driver.getUnitElement(path); |
| 1554 expect(unit, isNotNull); | 1555 expect(unitResult, isNotNull); |
| 1555 expect(unit.types.map((e) => e.name), ['A']); | 1556 expect(unitResult.element.types.map((e) => e.name), ['A']); |
| 1556 } | 1557 } |
| 1557 | 1558 |
| 1558 test_hasFilesToAnalyze() async { | 1559 test_hasFilesToAnalyze() async { |
| 1559 // No files yet, nothing to analyze. | 1560 // No files yet, nothing to analyze. |
| 1560 expect(driver.hasFilesToAnalyze, isFalse); | 1561 expect(driver.hasFilesToAnalyze, isFalse); |
| 1561 | 1562 |
| 1562 // Add a new file, it should be analyzed. | 1563 // Add a new file, it should be analyzed. |
| 1563 addTestFile('main() {}', priority: false); | 1564 addTestFile('main() {}', priority: false); |
| 1564 expect(driver.hasFilesToAnalyze, isTrue); | 1565 expect(driver.hasFilesToAnalyze, isTrue); |
| 1565 | 1566 |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2335 * Return the [provider] specific path for the given Posix [path]. | 2336 * Return the [provider] specific path for the given Posix [path]. |
| 2336 */ | 2337 */ |
| 2337 String _p(String path) => provider.convertPath(path); | 2338 String _p(String path) => provider.convertPath(path); |
| 2338 | 2339 |
| 2339 static String _md5(String content) { | 2340 static String _md5(String content) { |
| 2340 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 2341 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 2341 } | 2342 } |
| 2342 } | 2343 } |
| 2343 | 2344 |
| 2344 class _SourceMock extends TypedMock implements Source {} | 2345 class _SourceMock extends TypedMock implements Source {} |
| OLD | NEW |