| 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 expect(fooId, isNonNegative); | 591 expect(fooId, isNonNegative); |
| 592 } | 592 } |
| 593 | 593 |
| 594 test_getResult() async { | 594 test_getResult() async { |
| 595 String content = 'int f() => 42;'; | 595 String content = 'int f() => 42;'; |
| 596 addTestFile(content, priority: true); | 596 addTestFile(content, priority: true); |
| 597 | 597 |
| 598 AnalysisResult result = await driver.getResult(testFile); | 598 AnalysisResult result = await driver.getResult(testFile); |
| 599 expect(result.path, testFile); | 599 expect(result.path, testFile); |
| 600 expect(result.uri.toString(), 'package:test/test.dart'); | 600 expect(result.uri.toString(), 'package:test/test.dart'); |
| 601 expect(result.exists, isTrue); |
| 601 expect(result.content, content); | 602 expect(result.content, content); |
| 602 expect(result.contentHash, _md5(content)); | 603 expect(result.contentHash, _md5(content)); |
| 603 expect(result.unit, isNotNull); | 604 expect(result.unit, isNotNull); |
| 604 expect(result.errors, hasLength(0)); | 605 expect(result.errors, hasLength(0)); |
| 605 | 606 |
| 606 var f = result.unit.declarations[0] as FunctionDeclaration; | 607 var f = result.unit.declarations[0] as FunctionDeclaration; |
| 607 expect(f.name.staticType.toString(), '() → int'); | 608 expect(f.name.staticType.toString(), '() → int'); |
| 608 expect(f.returnType.type.toString(), 'int'); | 609 expect(f.returnType.type.toString(), 'int'); |
| 609 | 610 |
| 610 // The same result is also received through the stream. | 611 // The same result is also received through the stream. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 626 } | 627 } |
| 627 '''); | 628 '''); |
| 628 driver.addFile(a); | 629 driver.addFile(a); |
| 629 driver.addFile(b); | 630 driver.addFile(b); |
| 630 await _waitForIdle(); | 631 await _waitForIdle(); |
| 631 | 632 |
| 632 AnalysisResult result = await driver.getResult(b); | 633 AnalysisResult result = await driver.getResult(b); |
| 633 expect(result.errors, isEmpty); | 634 expect(result.errors, isEmpty); |
| 634 } | 635 } |
| 635 | 636 |
| 637 test_getResult_doesNotExist() async { |
| 638 var a = _p('/test/lib/a.dart'); |
| 639 |
| 640 AnalysisResult result = await driver.getResult(a); |
| 641 expect(result.path, a); |
| 642 expect(result.uri.toString(), 'package:test/a.dart'); |
| 643 expect(result.exists, isFalse); |
| 644 expect(result.content, ''); |
| 645 } |
| 646 |
| 636 test_getResult_errors() async { | 647 test_getResult_errors() async { |
| 637 String content = 'main() { int vv; }'; | 648 String content = 'main() { int vv; }'; |
| 638 addTestFile(content, priority: true); | 649 addTestFile(content, priority: true); |
| 639 | 650 |
| 640 AnalysisResult result = await driver.getResult(testFile); | 651 AnalysisResult result = await driver.getResult(testFile); |
| 641 expect(result.path, testFile); | 652 expect(result.path, testFile); |
| 642 expect(result.errors, hasLength(1)); | 653 expect(result.errors, hasLength(1)); |
| 643 { | 654 { |
| 644 AnalysisError error = result.errors[0]; | 655 AnalysisError error = result.errors[0]; |
| 645 expect(error.offset, 13); | 656 expect(error.offset, 13); |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 String _p(String path) => provider.convertPath(path); | 1690 String _p(String path) => provider.convertPath(path); |
| 1680 | 1691 |
| 1681 Future<Null> _waitForIdle() async { | 1692 Future<Null> _waitForIdle() async { |
| 1682 await idleStatusMonitor.signal; | 1693 await idleStatusMonitor.signal; |
| 1683 } | 1694 } |
| 1684 | 1695 |
| 1685 static String _md5(String content) { | 1696 static String _md5(String content) { |
| 1686 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 1697 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 1687 } | 1698 } |
| 1688 } | 1699 } |
| OLD | NEW |