| 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 String content = 'int f() => 42 + bar();'; | 694 String content = 'int f() => 42 + bar();'; |
| 695 addTestFile(content, priority: true); | 695 addTestFile(content, priority: true); |
| 696 | 696 |
| 697 ErrorsResult result = await driver.getErrors(testFile); | 697 ErrorsResult result = await driver.getErrors(testFile); |
| 698 expect(result.path, testFile); | 698 expect(result.path, testFile); |
| 699 expect(result.uri.toString(), 'package:test/test.dart'); | 699 expect(result.uri.toString(), 'package:test/test.dart'); |
| 700 expect(result.contentHash, _md5(content)); | 700 expect(result.contentHash, _md5(content)); |
| 701 expect(result.errors, hasLength(1)); | 701 expect(result.errors, hasLength(1)); |
| 702 } | 702 } |
| 703 | 703 |
| 704 test_getFilesDefiningClassMemberName() async { |
| 705 var a = _p('/test/bin/a.dart'); |
| 706 var b = _p('/test/bin/b.dart'); |
| 707 var c = _p('/test/bin/c.dart'); |
| 708 var d = _p('/test/bin/d.dart'); |
| 709 |
| 710 provider.newFile(a, 'class A { m1() {} }'); |
| 711 provider.newFile(b, 'class B { m2() {} }'); |
| 712 provider.newFile(c, 'class C { m2() {} }'); |
| 713 provider.newFile(d, 'class D { m3() {} }'); |
| 714 |
| 715 driver.addFile(a); |
| 716 driver.addFile(b); |
| 717 driver.addFile(c); |
| 718 driver.addFile(d); |
| 719 |
| 720 expect(await driver.getFilesDefiningClassMemberName('m1'), |
| 721 unorderedEquals([a])); |
| 722 |
| 723 expect(await driver.getFilesDefiningClassMemberName('m2'), |
| 724 unorderedEquals([b, c])); |
| 725 |
| 726 expect(await driver.getFilesDefiningClassMemberName('m3'), |
| 727 unorderedEquals([d])); |
| 728 } |
| 729 |
| 704 test_getFilesReferencingName() async { | 730 test_getFilesReferencingName() async { |
| 705 var a = _p('/test/bin/a.dart'); | 731 var a = _p('/test/bin/a.dart'); |
| 706 var b = _p('/test/bin/b.dart'); | 732 var b = _p('/test/bin/b.dart'); |
| 707 var c = _p('/test/bin/c.dart'); | 733 var c = _p('/test/bin/c.dart'); |
| 708 var d = _p('/test/bin/d.dart'); | 734 var d = _p('/test/bin/d.dart'); |
| 709 var e = _p('/test/bin/e.dart'); | 735 var e = _p('/test/bin/e.dart'); |
| 710 | 736 |
| 711 provider.newFile(a, 'class A {}'); | 737 provider.newFile(a, 'class A {}'); |
| 712 provider.newFile(b, "import 'a.dart'; A a;"); | 738 provider.newFile(b, "import 'a.dart'; A a;"); |
| 713 provider.newFile(c, "import 'a.dart'; var a = new A();"); | 739 provider.newFile(c, "import 'a.dart'; var a = new A();"); |
| (...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 * Return the [provider] specific path for the given Posix [path]. | 2051 * Return the [provider] specific path for the given Posix [path]. |
| 2026 */ | 2052 */ |
| 2027 String _p(String path) => provider.convertPath(path); | 2053 String _p(String path) => provider.convertPath(path); |
| 2028 | 2054 |
| 2029 static String _md5(String content) { | 2055 static String _md5(String content) { |
| 2030 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 2056 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 2031 } | 2057 } |
| 2032 } | 2058 } |
| 2033 | 2059 |
| 2034 class _SourceMock extends TypedMock implements Source {} | 2060 class _SourceMock extends TypedMock implements Source {} |
| OLD | NEW |