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

Unified Diff: pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart

Issue 2204263002: Issue 25666. Add test for shadowing of a superclass member from other library. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
diff --git a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
index cc09692c24c34b32ffe72e66de7b50c6693450df..d35c631f50bbdd5448d927f7bf2def10d728e0d7 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
@@ -6,6 +6,7 @@ library test.services.refactoring.rename_class_member;
import 'package:analysis_server/plugin/protocol/protocol.dart';
import 'package:analysis_server/src/services/correction/status.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'package:unittest/unittest.dart';
@@ -265,15 +266,15 @@ class A {
expectedContextSearch: 'test(); // marker');
}
- test_checkFinalConditions_shadowed_inSubClass() async {
+ test_checkFinalConditions_shadowedBySub_MethodElement() async {
indexTestUnit('''
class A {
- newName() {} // marker
+ test() {}
}
class B extends A {
- test() {}
+ newName() {} // marker
main() {
- newName();
+ test();
}
}
''');
@@ -282,11 +283,12 @@ class B extends A {
refactoring.newName = 'newName';
RefactoringStatus status = await refactoring.checkFinalConditions();
assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
- expectedMessage: "Renamed method will shadow method 'A.newName'.",
+ expectedMessage:
+ "Renamed method will be shadowed by method 'B.newName'.",
expectedContextSearch: 'newName() {} // marker');
}
- test_checkFinalConditions_shadowsSuper_inSubClass_FieldElement() async {
+ test_checkFinalConditions_shadowsSuper_FieldElement() async {
indexTestUnit('''
class A {
int newName; // marker
@@ -312,13 +314,10 @@ class C extends B {
test_checkFinalConditions_shadowsSuper_MethodElement() async {
indexTestUnit('''
class A {
- test() {}
+ newName() {} // marker
}
class B extends A {
- newName() {} // marker
- main() {
- test();
- }
+ test() {}
}
''');
createRenameRefactoringAtString('test() {}');
@@ -326,11 +325,33 @@ class B extends A {
refactoring.newName = 'newName';
RefactoringStatus status = await refactoring.checkFinalConditions();
assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
- expectedMessage:
- "Renamed method will be shadowed by method 'B.newName'.",
+ expectedMessage: "Renamed method will shadow method 'A.newName'.",
expectedContextSearch: 'newName() {} // marker');
}
+ test_checkFinalConditions_shadowsSuper_MethodElement_otherLib() async {
+ var libCode = r'''
+class A {
+ newName() {} // marker
+}
+''';
+ indexUnit('/lib.dart', libCode);
+ indexTestUnit('''
+import 'lib.dart';
+class B extends A {
+ test() {}
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ RefactoringStatus status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage: "Renamed method will shadow method 'A.newName'.",
+ expectedContextRange: new SourceRange(
+ libCode.indexOf('newName() {} // marker'), 'newName'.length));
+ }
+
test_checkInitialConditions_inSDK() async {
indexTestUnit('''
main() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698