Chromium Code Reviews| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 part, | 496 part, |
| 497 ''' | 497 ''' |
| 498 part of lib; | 498 part of lib; |
| 499 '''); | 499 '''); |
| 500 | 500 |
| 501 driver.addFile(lib); | 501 driver.addFile(lib); |
| 502 | 502 |
| 503 AnalysisResult libResult = await driver.getResult(lib); | 503 AnalysisResult libResult = await driver.getResult(lib); |
| 504 List<AnalysisError> errors = libResult.errors; | 504 List<AnalysisError> errors = libResult.errors; |
| 505 if (libResult.unit.element.context.analysisOptions.enableUriInPartOf) { | 505 if (libResult.unit.element.context.analysisOptions.enableUriInPartOf) { |
| 506 // TODO(28522): Should cause an error for wrong library name. | 506 expect(errors, hasLength(1)); |
| 507 expect(errors, hasLength(0)); | 507 expect(errors[0].errorCode, ResolverErrorCode.PART_OF_UNNAMED_LIBRARY); |
| 508 } else { | 508 } else { |
| 509 expect(errors, hasLength(1)); | 509 expect(errors, hasLength(1)); |
| 510 expect(errors[0].errorCode, | 510 expect(errors[0].errorCode, |
| 511 ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART); | 511 ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART); |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 | 514 |
| 515 test_analyze_resolveDirectives_error_partOfDifferentLibrary_byName() async { | 515 test_analyze_resolveDirectives_error_partOfDifferentLibrary_byName() async { |
| 516 var lib = _p('/test/lib.dart'); | 516 var lib = _p('/test/lib.dart'); |
| 517 var part = _p('/test/part.dart'); | 517 var part = _p('/test/part.dart'); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 '''); | 551 '''); |
| 552 | 552 |
| 553 driver.addFile(lib); | 553 driver.addFile(lib); |
| 554 | 554 |
| 555 AnalysisResult libResult = await driver.getResult(lib); | 555 AnalysisResult libResult = await driver.getResult(lib); |
| 556 List<AnalysisError> errors = libResult.errors; | 556 List<AnalysisError> errors = libResult.errors; |
| 557 expect(errors, hasLength(1)); | 557 expect(errors, hasLength(1)); |
| 558 expect(errors[0].errorCode, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY); | 558 expect(errors[0].errorCode, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY); |
| 559 } | 559 } |
| 560 | 560 |
| 561 test_analyze_resolveDirectives_error_partOfUnnamedLibrary_byName() async { | |
|
Brian Wilkerson
2017/06/08 19:54:23
I'm probably blind, but aside from the name of the
floitsch
2017/06/09 12:32:34
No. I just wrote this test first, and then had to
| |
| 562 var lib = _p('/test/lib.dart'); | |
| 563 var part = _p('/test/part.dart'); | |
| 564 provider.newFile( | |
| 565 lib, | |
| 566 ''' | |
| 567 part 'part.dart'; | |
| 568 '''); | |
| 569 provider.newFile( | |
| 570 part, | |
| 571 ''' | |
| 572 part of lib1; | |
| 573 '''); | |
| 574 | |
| 575 driver.addFile(lib); | |
| 576 | |
| 577 AnalysisResult libResult = await driver.getResult(lib); | |
| 578 List<AnalysisError> errors = libResult.errors; | |
| 579 expect(errors, hasLength(1)); | |
| 580 expect(errors[0].errorCode, ResolverErrorCode.PART_OF_UNNAMED_LIBRARY); | |
| 581 } | |
| 582 | |
| 561 test_analyze_resolveDirectives_error_partOfNonPart() async { | 583 test_analyze_resolveDirectives_error_partOfNonPart() async { |
| 562 var lib = _p('/test/lib.dart'); | 584 var lib = _p('/test/lib.dart'); |
| 563 var part = _p('/test/part.dart'); | 585 var part = _p('/test/part.dart'); |
| 564 provider.newFile( | 586 provider.newFile( |
| 565 lib, | 587 lib, |
| 566 ''' | 588 ''' |
| 567 library lib; | 589 library lib; |
| 568 part 'part.dart'; | 590 part 'part.dart'; |
| 569 '''); | 591 '''); |
| 570 provider.newFile( | 592 provider.newFile( |
| (...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2788 var path = _p('/test.dart'); | 2810 var path = _p('/test.dart'); |
| 2789 expect(() { | 2811 expect(() { |
| 2790 driver.removeFile(path); | 2812 driver.removeFile(path); |
| 2791 }, throwsStateError); | 2813 }, throwsStateError); |
| 2792 } | 2814 } |
| 2793 | 2815 |
| 2794 String _p(String path) => provider.convertPath(path); | 2816 String _p(String path) => provider.convertPath(path); |
| 2795 } | 2817 } |
| 2796 | 2818 |
| 2797 class _SourceMock extends TypedMock implements Source {} | 2819 class _SourceMock extends TypedMock implements Source {} |
| OLD | NEW |