Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Unified Diff: pkg/analyzer/test/src/dart/analysis/driver_test.dart

Issue 2931893004: Report an error when a part-of refers to an unnamed library. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/dart/analysis/driver_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 8985c013873e4675cfc84b166d86a00cc40a8f39..3e5f818d31dbd255c801ad69784f5a0634766012 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -503,8 +503,8 @@ part of lib;
AnalysisResult libResult = await driver.getResult(lib);
List<AnalysisError> errors = libResult.errors;
if (libResult.unit.element.context.analysisOptions.enableUriInPartOf) {
- // TODO(28522): Should cause an error for wrong library name.
- expect(errors, hasLength(0));
+ expect(errors, hasLength(1));
+ expect(errors[0].errorCode, StaticWarningCode.PART_OF_UNNAMED_LIBRARY);
} else {
expect(errors, hasLength(1));
expect(errors[0].errorCode,
@@ -558,6 +558,28 @@ part of 'other_lib.dart';
expect(errors[0].errorCode, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY);
}
+ test_analyze_resolveDirectives_error_partOfUnnamedLibrary_byName() async {
+ var lib = _p('/test/lib.dart');
+ var part = _p('/test/part.dart');
+ provider.newFile(
+ lib,
+ '''
+part 'part.dart';
+''');
+ provider.newFile(
+ part,
+ '''
+part of lib1;
+''');
+
+ driver.addFile(lib);
+
+ AnalysisResult libResult = await driver.getResult(lib);
+ List<AnalysisError> errors = libResult.errors;
+ expect(errors, hasLength(1));
+ expect(errors[0].errorCode, StaticWarningCode.PART_OF_UNNAMED_LIBRARY);
+ }
+
test_analyze_resolveDirectives_error_partOfNonPart() async {
var lib = _p('/test/lib.dart');
var part = _p('/test/part.dart');

Powered by Google App Engine
This is Rietveld 408576698