Skip to content

Commit f807792

Browse files
pqCommit Queue
authored and
Commit Queue
committed
augmentation tests for annotate_redeclares
See: https://github.com/dart-lang/linter/issues/4927 Change-Id: I88e6206765c3e236c25f1fcdc830090e310d9869 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363103 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 5108871 commit f807792

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

pkg/linter/test/rules/annotate_redeclares_test.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,56 @@ class AnnotateRedeclaresTest extends LintRuleTest {
2020
@override
2121
String get lintRule => 'annotate_redeclares';
2222

23+
test_augmentationClass_method() async {
24+
newFile('$testPackageLibPath/a.dart', r'''
25+
import augment 'test.dart';
26+
27+
class A {
28+
void m() {}
29+
}
30+
''');
31+
32+
await assertDiagnostics(r'''
33+
augment library 'a.dart';
34+
35+
extension type E(A a) implements A {
36+
void m() {}
37+
}
38+
''', [
39+
lint(71, 1),
40+
]);
41+
}
42+
43+
@FailingTest(
44+
reason:
45+
"CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION [61, 7, The declaration being augmented doesn't exist.]",
46+
issue: 'https://github.com/dart-lang/linter/issues/4927',
47+
)
48+
test_augmentationMethodWithAnnotation() async {
49+
newFile('$testPackageLibPath/a.dart', r'''
50+
import augment 'test.dart';
51+
52+
import 'package:meta/meta.dart';
53+
54+
class A {
55+
void m() {}
56+
}
57+
58+
extension type E(A a) implements A {
59+
@redeclare
60+
void m() {}
61+
}
62+
''');
63+
64+
await assertNoDiagnostics(r'''
65+
augment library 'a.dart';
66+
67+
augment extension type E(A a) {
68+
augment void m() { }
69+
}
70+
''');
71+
}
72+
2373
test_method() async {
2474
await assertDiagnostics(r'''
2575
class A {

0 commit comments

Comments
 (0)