Skip to content

Commit

Permalink
[analyzer] Add tests for null-aware elements in closing labels
Browse files Browse the repository at this point in the history
Part of #56989

Change-Id: I9d402523ea065eaac4c4edbba2461a2ed23cac27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396600
Commit-Queue: Chloe Stefantsova <[email protected]>
Reviewed-by: Keerti Parthasarathy <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
  • Loading branch information
chloestefantsova authored and Commit Queue committed Nov 21, 2024
1 parent 53844a6 commit d6ddaf4
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,42 @@ void f(HighlightRegionType type, int offset, int length) {
_compareLabels(labels, content, expectedLabelCount: 2);
}

Future<void> test_nullAwareElement_inList() async {
var content = '''
void myMethod() {
return /*1*/new Wrapper(
Widget.createWidget(/*2*/<Widget>[
1,
?null,
2
]/*2:<Widget>[]*/)
)/*1:Wrapper*/;
}
''';

var labels = await _computeElements(content);
_compareLabels(labels, content, expectedLabelCount: 2);
}

Future<void> test_nullAwareElement_inList_containingList() async {
var content = '''
void myMethod() {
return /*1*/new Wrapper(
Widget.createWidget(/*2*/<Widget>[
1,
?Widget.createWidget(/*3*/<Widget>[
3
]/*3:<Widget>[]*/),
2
]/*2:<Widget>[]*/)
)/*1:Wrapper*/;
}
''';

var labels = await _computeElements(content);
_compareLabels(labels, content, expectedLabelCount: 3);
}

Future<void> test_prefixedConstConstructor() async {
var content = """
import 'dart:async' as a;
Expand Down

0 comments on commit d6ddaf4

Please sign in to comment.