Files
sdk/pkg/front_end/parser_testcases/null_aware_elements/nested.dart
T
Chloe Stefantsova 06223ff9f0 [parser] Add missing handling of null-aware elements in if-else
Part of https://github.com/dart-lang/sdk/issues/55954

Change-Id: Ie22ff9ddf50f47e20b1cfbf11f01bdc900123619
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388003
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-10-07 09:41:35 +00:00

111 lines
1.8 KiB
Dart

test1(List list, bool Function(dynamic) p, int? a) {
return {
for (var element in list)
if (p(element))
?a
};
}
test2(List list, bool Function(dynamic) p, int? a, int? b) {
return {
for (var element in list)
if (p(element))
?a
else
?b
};
}
test3(List list, bool t, int? a) {
return {
if (t)
for (var element in list)
?a
};
}
test4(List list, bool t, int? a, int? b) {
return {
if (t)
for (var element in list)
?a
else
for (var element in list)
?b
};
}
test5(List list, bool Function(dynamic) p, int? a) {
return {
for (var element in list)
if (p(element))
?a: "value"
};
}
test6(List list, bool Function(dynamic) p, int? a, int? b) {
return {
for (var element in list)
if (p(element))
?a: "value"
else
?b: "value"
};
}
test7(List list, bool t, int? a) {
return {
if (t)
for (var element in list)
?a: "value"
};
}
test8(List list, bool t, int? a, int? b) {
return {
if (t)
for (var element in list)
?a: "value"
else
for (var element in list)
?b: "value"
};
}
test9(List list, bool Function(dynamic) p, int? a) {
return {
for (var element in list)
if (p(element))
"key": ?a
};
}
test10(List list, bool Function(dynamic) p, int? a, int? b) {
return {
for (var element in list)
if (p(element))
"key": ?a
else
"key": ?b
};
}
test11(List list, bool t, int? a) {
return {
if (t)
for (var element in list)
"key": ?a
};
}
test12(List list, bool t, int? a, int? b) {
return {
if (t)
for (var element in list)
"key": ?a
else
for (var element in list)
"key": ?b
};
}