Skip to content

Commit d5fc9fb

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Unit test generic annotation functionality of AstCloner.
The update to AstCloner was made as part of ba5064f, but it couldn't be unit tested until now due to the lack of parser support. Bug: #44838 Change-Id: If2fd5ce41a46c3460b5f90ba854f22ae1baef11c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182840 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 6b79335 commit d5fc9fb

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

pkg/analyzer/test/generated/utilities_test.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class AstClonerTest {
7878
_assertCloneUnitMember('@A.c() main() {}');
7979
}
8080

81+
void test_visitAnnotation_constructor_generic() {
82+
_assertCloneUnitMember('@A<int>.c() main() {}',
83+
featureSet: FeatureSet.forTesting(
84+
sdkVersion: '2.12',
85+
additionalFeatures: [Feature.generic_metadata]));
86+
}
87+
8188
void test_visitAnnotation_withComment() {
8289
CompilationUnitMember clazz =
8390
_parseUnitMember('/** comment */ @deprecated class A {}');
@@ -1160,8 +1167,8 @@ library l;''');
11601167
_assertClone(node);
11611168
}
11621169

1163-
void _assertCloneUnitMember(String code) {
1164-
AstNode node = _parseUnitMember(code);
1170+
void _assertCloneUnitMember(String code, {FeatureSet? featureSet}) {
1171+
AstNode node = _parseUnitMember(code, featureSet: featureSet);
11651172
_assertClone(node);
11661173
}
11671174

@@ -1178,10 +1185,10 @@ library l;''');
11781185
return body.block.statements.single;
11791186
}
11801187

1181-
CompilationUnit _parseUnit(String code) {
1188+
CompilationUnit _parseUnit(String code, {FeatureSet? featureSet}) {
11821189
GatheringErrorListener listener = GatheringErrorListener();
11831190
CharSequenceReader reader = CharSequenceReader(code);
1184-
var featureSet = FeatureSet.forTesting(sdkVersion: '2.2.2');
1191+
featureSet ??= FeatureSet.forTesting(sdkVersion: '2.2.2');
11851192
Scanner scanner = Scanner(TestSource(), reader, listener)
11861193
..configureFeatures(
11871194
featureSetForOverriding: featureSet,
@@ -1199,8 +1206,9 @@ library l;''');
11991206
return unit;
12001207
}
12011208

1202-
CompilationUnitMember _parseUnitMember(String code) {
1203-
CompilationUnit unit = _parseUnit(code);
1209+
CompilationUnitMember _parseUnitMember(String code,
1210+
{FeatureSet? featureSet}) {
1211+
CompilationUnit unit = _parseUnit(code, featureSet: featureSet);
12041212
return unit.declarations.single;
12051213
}
12061214

0 commit comments

Comments
 (0)