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

Unified Diff: pkg/analyzer/test/generated/declaration_resolver_test.dart

Issue 1647613002: Add tests, including test for issue (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « pkg/analyzer/test/generated/all_the_rest_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/declaration_resolver_test.dart
diff --git a/pkg/analyzer/test/generated/declaration_resolver_test.dart b/pkg/analyzer/test/generated/declaration_resolver_test.dart
index 6bd5076cbf328ff2bee8cfeccc5ea99137fa1b01..188cc2668062bd783bae7ddd9f8492712c42ed18 100644
--- a/pkg/analyzer/test/generated/declaration_resolver_test.dart
+++ b/pkg/analyzer/test/generated/declaration_resolver_test.dart
@@ -36,6 +36,27 @@ SimpleIdentifier _findSimpleIdentifier(
@reflectiveTest
class DeclarationResolverTest extends ResolverTestCase {
+ void fail_visitMethodDeclaration_setter_duplicate() {
+ // https://github.com/dart-lang/sdk/issues/25601
+ String code = r'''
+class C {
+ set zzz(x) {}
+ set zzz(y) {}
+}
+''';
+ CompilationUnit unit = resolveSource(code);
+ PropertyAccessorElement firstElement =
+ _findSimpleIdentifier(unit, code, 'zzz(x)').staticElement;
+ PropertyAccessorElement secondElement =
+ _findSimpleIdentifier(unit, code, 'zzz(y)').staticElement;
+ // re-resolve
+ CompilationUnit unit2 = _cloneResolveUnit(unit);
+ SimpleIdentifier firstName = _findSimpleIdentifier(unit2, code, 'zzz(x)');
+ SimpleIdentifier secondName = _findSimpleIdentifier(unit2, code, 'zzz(y)');
+ expect(firstName.staticElement, same(firstElement));
+ expect(secondName.staticElement, same(secondElement));
+ }
+
@override
void setUp() {
super.setUp();
@@ -98,6 +119,47 @@ main() {
SimpleIdentifier setterName = _findSimpleIdentifier(unit2, code, 'zzz(x)');
expect(setterName.staticElement, same(setterElement));
}
+
+ void test_visitMethodDeclaration_getter_duplicate() {
+ String code = r'''
+class C {
+ int get zzz => 1;
+ String get zzz => null;
+}
+''';
+ CompilationUnit unit = resolveSource(code);
+ PropertyAccessorElement firstElement =
+ _findSimpleIdentifier(unit, code, 'zzz => 1').staticElement;
+ PropertyAccessorElement secondElement =
+ _findSimpleIdentifier(unit, code, 'zzz => null').staticElement;
+ // re-resolve
+ CompilationUnit unit2 = _cloneResolveUnit(unit);
+ SimpleIdentifier firstName = _findSimpleIdentifier(unit2, code, 'zzz => 1');
+ SimpleIdentifier secondName =
+ _findSimpleIdentifier(unit2, code, 'zzz => null');
+ expect(firstName.staticElement, same(firstElement));
+ expect(secondName.staticElement, same(secondElement));
+ }
+
+ void test_visitMethodDeclaration_method_duplicate() {
+ String code = r'''
+class C {
+ void zzz(x) {}
+ void zzz(y) {}
+}
+''';
+ CompilationUnit unit = resolveSource(code);
+ MethodElement firstElement =
+ _findSimpleIdentifier(unit, code, 'zzz(x)').staticElement;
+ MethodElement secondElement =
+ _findSimpleIdentifier(unit, code, 'zzz(y)').staticElement;
+ // re-resolve
+ CompilationUnit unit2 = _cloneResolveUnit(unit);
+ SimpleIdentifier firstName = _findSimpleIdentifier(unit2, code, 'zzz(x)');
+ SimpleIdentifier secondName = _findSimpleIdentifier(unit2, code, 'zzz(y)');
+ expect(firstName.staticElement, same(firstElement));
+ expect(secondName.staticElement, same(secondElement));
+ }
}
/**
« no previous file with comments | « pkg/analyzer/test/generated/all_the_rest_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698