Skip to content

Commit 1536bba

Browse files
johnniwintherCommit Queue
authored and
Commit Queue
committed
[cfe] Updates test with ... in map patterns
Change-Id: I6dceb6d9490c3b42941874499e815638216b0d17 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292302 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Chloe Stefantsova <[email protected]>
1 parent 050eb42 commit 1536bba

32 files changed

+108
-505
lines changed

pkg/front_end/testcases/late_lowering/caching.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int ifCase(o) {
7878
if (o case {0: int _}) {
7979
return 22;
8080
}
81-
if (o case {1: String _, ...}) {
81+
if (o case {1: String _}) {
8282
return 23;
8383
}
8484
if (o case {2: var a}) {
@@ -145,7 +145,7 @@ int ifCaseElse(o) {
145145
return 21;
146146
} else if (o case {0: int _}) {
147147
return 22;
148-
} else if (o case {1: String _, ...}) {
148+
} else if (o case {1: String _}) {
149149
return 23;
150150
} else if (o case {2: var a}) {
151151
return 24;
@@ -209,7 +209,7 @@ int switchStatement(o) {
209209
return 21;
210210
case {0: int _}:
211211
return 22;
212-
case {1: String _, ...}:
212+
case {1: String _}:
213213
return 23;
214214
case {2: var a}:
215215
return 24;
@@ -251,7 +251,7 @@ int switchExpression(o) {
251251
bool _ => 20,
252252
Map() when o.isEmpty => 21,
253253
{0: int _} => 22,
254-
{1: String _, ...} => 23,
254+
{1: String _} => 23,
255255
{2: var a} => 24,
256256
{3: int b} => 25,
257257
(0, 1) => 26,

pkg/front_end/testcases/patterns/caching.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int ifCase(o) {
7878
if (o case {0: int _}) {
7979
return 22;
8080
}
81-
if (o case {1: String _, ...}) {
81+
if (o case {1: String _}) {
8282
return 23;
8383
}
8484
if (o case {2: var a}) {
@@ -145,7 +145,7 @@ int ifCaseElse(o) {
145145
return 21;
146146
} else if (o case {0: int _}) {
147147
return 22;
148-
} else if (o case {1: String _, ...}) {
148+
} else if (o case {1: String _}) {
149149
return 23;
150150
} else if (o case {2: var a}) {
151151
return 24;
@@ -209,7 +209,7 @@ int switchStatement(o) {
209209
return 21;
210210
case {0: int _}:
211211
return 22;
212-
case {1: String _, ...}:
212+
case {1: String _}:
213213
return 23;
214214
case {2: var a}:
215215
return 24;
@@ -251,7 +251,7 @@ int switchExpression(o) {
251251
bool _ => 20,
252252
Map() when o.isEmpty => 21,
253253
{0: int _} => 22,
254-
{1: String _, ...} => 23,
254+
{1: String _} => 23,
255255
{2: var a} => 24,
256256
{3: int b} => 25,
257257
(0, 1) => 26,

pkg/front_end/testcases/patterns/invalid.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ method(Unresolved o) {
77
case [_]:
88
case [_, ...var a, _]:
99
case [...]:
10-
case {0: 1, ...}:
10+
case {0: 1}:
1111
case String(length: 5):
1212
case == 5:
1313
case < 5: // TODO(johnniwinther): Why do we get an error here?

pkg/front_end/testcases/patterns/issue50886.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,9 @@ test2() {
2020
}
2121
}
2222

23-
test3() {
24-
Map<dynamic, dynamic> x = <int, int>{1: 1, 2:2};
25-
if (x case <int, int>{1: 1, ...}) {
26-
return 0;
27-
} else {
28-
return 1;
29-
}
30-
}
31-
3223
main() {
3324
expectEquals(0, test1());
3425
expectEquals(0, test2());
35-
expectEquals(0, test3());
3626
}
3727

3828
expectEquals(x, y) {

pkg/front_end/testcases/patterns/issue50886.dart.strong.expect

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,9 @@ static method test2() → dynamic {
2828
}
2929
}
3030
}
31-
static method test3() → dynamic {
32-
core::Map<dynamic, dynamic> x = <core::int, core::int>{1: 1, 2: 2};
33-
{
34-
final synthesized core::Map<dynamic, dynamic> #0#0 = x;
35-
late final synthesized core::int? #0#4 = #0#0{core::Map<core::int, core::int>}.{core::Map::[]}(#C1){(core::Object?) → core::int?};
36-
if(#0#0 is{ForNonNullableByDefault} core::Map<core::int, core::int> && (!(#0#4 == null) || null is{ForNonNullableByDefault} core::int && #0#0{core::Map<core::int, core::int>}.{core::Map::containsKey}(#C1){(core::Object?) → core::bool}) && #C1 =={core::num::==}{(core::Object) → core::bool} #0#4{core::int}) {
37-
return 0;
38-
}
39-
else {
40-
return 1;
41-
}
42-
}
43-
}
4431
static method main() → dynamic {
4532
self::expectEquals(0, self::test1());
4633
self::expectEquals(0, self::test2());
47-
self::expectEquals(0, self::test3());
4834
}
4935
static method expectEquals(dynamic x, dynamic y) → dynamic {
5036
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) {

pkg/front_end/testcases/patterns/issue50886.dart.strong.transformed.expect

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,9 @@ static method test2() → dynamic {
3232
}
3333
}
3434
}
35-
static method test3() → dynamic {
36-
core::Map<dynamic, dynamic> x = <core::int, core::int>{1: 1, 2: 2};
37-
{
38-
final synthesized core::Map<dynamic, dynamic> #0#0 = x;
39-
function ##0#4#initializer() → core::int?
40-
return #0#0{core::Map<core::int, core::int>}.{core::Map::[]}(#C1){(core::Object?) → core::int?};
41-
late final synthesized core::int? #0#4 = ##0#4#initializer(){() → core::int?};
42-
if(#0#0 is{ForNonNullableByDefault} core::Map<core::int, core::int> && (!(#0#4 == null) || null is{ForNonNullableByDefault} core::int && #0#0{core::Map<core::int, core::int>}.{core::Map::containsKey}(#C1){(core::Object?) → core::bool}) && #C1 =={core::num::==}{(core::Object) → core::bool} #0#4{core::int}) {
43-
return 0;
44-
}
45-
else {
46-
return 1;
47-
}
48-
}
49-
}
5035
static method main() → dynamic {
5136
self::expectEquals(0, self::test1());
5237
self::expectEquals(0, self::test2());
53-
self::expectEquals(0, self::test3());
5438
}
5539
static method expectEquals(dynamic x, dynamic y) → dynamic {
5640
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) {
@@ -65,5 +49,4 @@ constants {
6549
Extra constant evaluation status:
6650
Evaluated: LogicalExpression @ org-dartlang-testcase:///issue50886.dart:7:26 -> BoolConstant(false)
6751
Evaluated: LogicalExpression @ org-dartlang-testcase:///issue50886.dart:16:26 -> BoolConstant(false)
68-
Evaluated: LogicalExpression @ org-dartlang-testcase:///issue50886.dart:25:26 -> BoolConstant(false)
69-
Extra constant evaluation: evaluated: 62, effectively constant: 3
52+
Extra constant evaluation: evaluated: 44, effectively constant: 2
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
test1() {}
22
test2() {}
3-
test3() {}
43
main() {}
54
expectEquals(x, y) {}

pkg/front_end/testcases/patterns/issue50886.dart.textual_outline_modelled.expect

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ expectEquals(x, y) {}
22
main() {}
33
test1() {}
44
test2() {}
5-
test3() {}

pkg/front_end/testcases/patterns/issue50886.dart.weak.expect

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,9 @@ static method test2() → dynamic {
2626
}
2727
}
2828
}
29-
static method test3() → dynamic {
30-
core::Map<dynamic, dynamic> x = <core::int, core::int>{1: 1, 2: 2};
31-
{
32-
final synthesized core::Map<dynamic, dynamic> #0#0 = x;
33-
if(#0#0 is{ForNonNullableByDefault} core::Map<core::int, core::int> && #0#0{core::Map<core::int, core::int>}.{core::Map::containsKey}(#C1){(core::Object?) → core::bool} && #C1 =={core::num::==}{(core::Object) → core::bool} #0#0{core::Map<core::int, core::int>}.{core::Map::[]}(#C1){(core::Object?) → core::int?} as{ForNonNullableByDefault} core::int) {
34-
return 0;
35-
}
36-
else {
37-
return 1;
38-
}
39-
}
40-
}
4129
static method main() → dynamic {
4230
self::expectEquals(0, self::test1());
4331
self::expectEquals(0, self::test2());
44-
self::expectEquals(0, self::test3());
4532
}
4633
static method expectEquals(dynamic x, dynamic y) → dynamic {
4734
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) {

pkg/front_end/testcases/patterns/issue50886.dart.weak.modular.expect

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,9 @@ static method test2() → dynamic {
2626
}
2727
}
2828
}
29-
static method test3() → dynamic {
30-
core::Map<dynamic, dynamic> x = <core::int, core::int>{1: 1, 2: 2};
31-
{
32-
final synthesized core::Map<dynamic, dynamic> #0#0 = x;
33-
if(#0#0 is{ForNonNullableByDefault} core::Map<core::int, core::int> && #0#0{core::Map<core::int, core::int>}.{core::Map::containsKey}(#C1){(core::Object?) → core::bool} && #C1 =={core::num::==}{(core::Object) → core::bool} #0#0{core::Map<core::int, core::int>}.{core::Map::[]}(#C1){(core::Object?) → core::int?} as{ForNonNullableByDefault} core::int) {
34-
return 0;
35-
}
36-
else {
37-
return 1;
38-
}
39-
}
40-
}
4129
static method main() → dynamic {
4230
self::expectEquals(0, self::test1());
4331
self::expectEquals(0, self::test2());
44-
self::expectEquals(0, self::test3());
4532
}
4633
static method expectEquals(dynamic x, dynamic y) → dynamic {
4734
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) {

pkg/front_end/testcases/patterns/issue50886.dart.weak.outline.expect

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ static method test1() → dynamic
55
;
66
static method test2() → dynamic
77
;
8-
static method test3() → dynamic
9-
;
108
static method main() → dynamic
119
;
1210
static method expectEquals(dynamic x, dynamic y) → dynamic

pkg/front_end/testcases/patterns/issue50886.dart.weak.transformed.expect

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,9 @@ static method test2() → dynamic {
2626
}
2727
}
2828
}
29-
static method test3() → dynamic {
30-
core::Map<dynamic, dynamic> x = <core::int, core::int>{1: 1, 2: 2};
31-
{
32-
final synthesized core::Map<dynamic, dynamic> #0#0 = x;
33-
if(#0#0 is{ForNonNullableByDefault} core::Map<core::int, core::int> && #0#0{core::Map<core::int, core::int>}.{core::Map::containsKey}(#C1){(core::Object?) → core::bool} && #C1 =={core::num::==}{(core::Object) → core::bool} #0#0{core::Map<core::int, core::int>}.{core::Map::[]}(#C1){(core::Object?) → core::int?}) {
34-
return 0;
35-
}
36-
else {
37-
return 1;
38-
}
39-
}
40-
}
4129
static method main() → dynamic {
4230
self::expectEquals(0, self::test1());
4331
self::expectEquals(0, self::test2());
44-
self::expectEquals(0, self::test3());
4532
}
4633
static method expectEquals(dynamic x, dynamic y) → dynamic {
4734
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) {

pkg/front_end/testcases/patterns/issue51770.dart

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,3 @@ method2(o) {
5555
print(a);
5656
}
5757
}
58-
59-
method3(Map<dynamic, dynamic> o) {
60-
switch (o) {
61-
case {...}:
62-
print(o);
63-
}
64-
switch (o) {
65-
case {0: _, ...}:
66-
print(o);
67-
}
68-
}
69-
70-
method4(o) {
71-
switch (o) {
72-
case {...}:
73-
print(o);
74-
}
75-
switch (o) {
76-
case {0: _, ...}:
77-
print(o);
78-
}
79-
}

pkg/front_end/testcases/patterns/issue51770.dart.strong.expect

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -146,58 +146,7 @@ static method method2(dynamic o) → dynamic {
146146
}
147147
}
148148
}
149-
static method method3(core::Map<dynamic, dynamic> o) → dynamic {
150-
#L13:
151-
{
152-
final synthesized core::Map<dynamic, dynamic> #0#0 = o;
153-
{
154-
if(true) {
155-
{
156-
core::print(o);
157-
}
158-
}
159-
}
160-
}
161-
#L14:
162-
{
163-
final synthesized core::Map<dynamic, dynamic> #1#0 = o;
164-
late final synthesized dynamic #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → dynamic};
165-
{
166-
if((!(#1#3 == null) || null is{ForNonNullableByDefault} dynamic && #1#0.{core::Map::containsKey}(#C2){(core::Object?) → core::bool}) && (let final dynamic #t7 = #1#3 in true)) {
167-
{
168-
core::print(o);
169-
}
170-
}
171-
}
172-
}
173-
}
174-
static method method4(dynamic o) → dynamic {
175-
#L15:
176-
{
177-
final synthesized dynamic #0#0 = o;
178-
{
179-
if(#0#0 is{ForNonNullableByDefault} core::Map<dynamic, dynamic>) {
180-
{
181-
core::print(o{core::Map<dynamic, dynamic>});
182-
}
183-
}
184-
}
185-
}
186-
#L16:
187-
{
188-
final synthesized dynamic #1#0 = o;
189-
late final synthesized dynamic #1#4 = #1#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C2){(core::Object?) → dynamic};
190-
{
191-
if(#1#0 is{ForNonNullableByDefault} core::Map<dynamic, dynamic> && (!(#1#4 == null) || null is{ForNonNullableByDefault} dynamic && #1#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C2){(core::Object?) → core::bool}) && (let final dynamic #t8 = #1#4 in true)) {
192-
{
193-
core::print(o{core::Map<dynamic, dynamic>});
194-
}
195-
}
196-
}
197-
}
198-
}
199149

200150
constants {
201151
#C1 = 1
202-
#C2 = 0
203152
}

pkg/front_end/testcases/patterns/issue51770.dart.strong.transformed.expect

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -150,67 +150,7 @@ static method method2(dynamic o) → dynamic {
150150
}
151151
}
152152
}
153-
static method method3(core::Map<dynamic, dynamic> o) → dynamic {
154-
#L13:
155-
{
156-
final synthesized core::Map<dynamic, dynamic> #0#0 = o;
157-
{
158-
if(true) {
159-
{
160-
core::print(o);
161-
}
162-
}
163-
}
164-
}
165-
#L14:
166-
{
167-
final synthesized core::Map<dynamic, dynamic> #1#0 = o;
168-
function ##1#3#initializer() → dynamic
169-
return #1#0.{core::Map::[]}(#C2){(core::Object?) → dynamic};
170-
late final synthesized dynamic #1#3 = ##1#3#initializer(){() → dynamic};
171-
{
172-
if((!(#1#3 == null) || null is{ForNonNullableByDefault} dynamic && #1#0.{core::Map::containsKey}(#C2){(core::Object?) → core::bool}) && (let final dynamic #t7 = #1#3 in true)) {
173-
{
174-
core::print(o);
175-
}
176-
}
177-
}
178-
}
179-
}
180-
static method method4(dynamic o) → dynamic {
181-
#L15:
182-
{
183-
final synthesized dynamic #0#0 = o;
184-
{
185-
if(#0#0 is{ForNonNullableByDefault} core::Map<dynamic, dynamic>) {
186-
{
187-
core::print(o{core::Map<dynamic, dynamic>});
188-
}
189-
}
190-
}
191-
}
192-
#L16:
193-
{
194-
final synthesized dynamic #1#0 = o;
195-
function ##1#4#initializer() → dynamic
196-
return #1#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C2){(core::Object?) → dynamic};
197-
late final synthesized dynamic #1#4 = ##1#4#initializer(){() → dynamic};
198-
{
199-
if(#1#0 is{ForNonNullableByDefault} core::Map<dynamic, dynamic> && (!(#1#4 == null) || null is{ForNonNullableByDefault} dynamic && #1#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C2){(core::Object?) → core::bool}) && (let final dynamic #t8 = #1#4 in true)) {
200-
{
201-
core::print(o{core::Map<dynamic, dynamic>});
202-
}
203-
}
204-
}
205-
}
206-
}
207153

208154
constants {
209155
#C1 = 1
210-
#C2 = 0
211156
}
212-
213-
Extra constant evaluation status:
214-
Evaluated: IsExpression @ org-dartlang-testcase:///issue51770.dart:65:12 -> BoolConstant(true)
215-
Evaluated: IsExpression @ org-dartlang-testcase:///issue51770.dart:76:12 -> BoolConstant(true)
216-
Extra constant evaluation: evaluated: 158, effectively constant: 2

0 commit comments

Comments
 (0)