Add tests to class_to_enum and class_to_mixin using class modifiers.

Bug: 51496
Change-Id: Ib37979b39b7c63daa89c0746ac5c231a2269ef46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286948
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
This commit is contained in:
Keerti Parthasarathy 2023-03-06 23:17:51 +00:00 committed by Commit Queue
parent c021746bc4
commit bd42ae8637
2 changed files with 118 additions and 0 deletions

View file

@ -242,6 +242,18 @@ abstract class E {}
await assertNoAssistAt('E {');
}
Future<void> test_invalid_base() async {
await resolveTestCode('''
base class E {
final int index;
static const E c0 = E(0);
const E(this.index);
}
''');
await assertNoAssistAt('E {');
}
Future<void> test_invalid_constructorUsedInConstructor() async {
await resolveTestCode('''
class _E {
@ -318,6 +330,17 @@ class _E {
await assertNoAssistAt('E {');
}
Future<void> test_invalid_final() async {
await resolveTestCode('''
final class E {
static const E c = E();
const E();
}
''');
await assertNoAssistAt('E {');
}
Future<void> test_invalid_hasPart() async {
// Change this test if the assist becomes able to look for references to the
// class and its constructors in part files.
@ -416,6 +439,17 @@ class _E {
await assertNoAssistAt('E {');
}
Future<void> test_invalid_sealed() async {
await resolveTestCode('''
sealed class E {
final int index;
const E._(this.index);
}
''');
await assertNoAssistAt('E {');
}
Future<void> test_minimal_privateClass() async {
await resolveTestCode('''
class _E {

View file

@ -28,6 +28,39 @@ mixin A {}
''');
}
Future<void> test_base_extendsWithImplements_super_both() async {
await resolveTestCode('''
class A {
a() {}
}
mixin class B {
b() {}
}
class C {}
base class D extends A with B implements C {
d() {
super.a();
super.b();
}
}
''');
await assertHasAssistAt('D', '''
class A {
a() {}
}
mixin class B {
b() {}
}
class C {}
base mixin D on A, B implements C {
d() {
super.a();
super.b();
}
}
''');
}
Future<void> test_extends_noSuper() async {
await resolveTestCode('''
class A {}
@ -337,6 +370,17 @@ mixin D on B implements A, C {
''');
}
Future<void> test_final_implements() async {
await resolveTestCode('''
class A {}
final class B implements A {}
''');
await assertHasAssistAt('B', '''
class A {}
final mixin B implements A {}
''');
}
Future<void> test_implements() async {
await resolveTestCode('''
class A {}
@ -373,6 +417,46 @@ mixin A {}
''');
}
Future<void> test_sealed_extends_noSuper() async {
await resolveTestCode('''
class A {}
sealed class B extends A {}
''');
await assertHasAssistAt('B', '''
class A {}
sealed mixin B implements A {}
''');
}
Future<void> test_sealed_extendsWith_super_extends() async {
await resolveTestCode('''
class A {
a() {}
}
mixin class B {
b() {}
}
sealed class C extends A with B {
c() {
super.a();
}
}
''');
await assertHasAssistAt('C', '''
class A {
a() {}
}
mixin class B {
b() {}
}
sealed mixin C on A implements B {
c() {
super.a();
}
}
''');
}
Future<void> test_typeParameters() async {
await resolveTestCode('''
class A<T> {}