Skip to content

Commit 3e0f53a

Browse files
kallentuCommit Queue
authored andcommitted
[tests] Enum shorthands - Expressions with no context (simple identifiers).
Testing expressions where enum shorthands might pop up and making sure there are no crashes. Follow up to Erik's comment: https://dart-review.googlesource.com/c/sdk/+/393606/comments/16e214b1_4bbfad8f Bug: #57038 Change-Id: Ia72b7f40f47dfc782085f56473ee68c5bd755d2b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397500 Commit-Queue: Kallen Tu <[email protected]> Reviewed-by: Erik Ernst <[email protected]>
1 parent bacbbf8 commit 3e0f53a

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Test that there are no crashes when enum shorthands are used in places
6+
// with no context type, or it's not allowed.
7+
8+
// SharedOptions=--enable-experiment=enum-shorthands
9+
10+
import '../enum_shorthand_helper.dart';
11+
12+
void main() async {
13+
// Enum shorthands in postfix and prefix expressions.
14+
.red++;
15+
// ^
16+
// [analyzer] unspecified
17+
// [cfe] unspecified
18+
19+
.red--;
20+
// ^
21+
// [analyzer] unspecified
22+
// [cfe] unspecified
23+
24+
++.red;
25+
// ^
26+
// [analyzer] unspecified
27+
// [cfe] unspecified
28+
29+
--.red;
30+
// ^
31+
// [analyzer] unspecified
32+
// [cfe] unspecified
33+
34+
-.red;
35+
// ^
36+
// [analyzer] unspecified
37+
// [cfe] unspecified
38+
39+
~.red;
40+
// ^
41+
// [analyzer] unspecified
42+
// [cfe] unspecified
43+
44+
!.red;
45+
// ^
46+
// [analyzer] unspecified
47+
// [cfe] unspecified
48+
49+
// Await.
50+
await .red;
51+
// ^
52+
// [analyzer] unspecified
53+
// [cfe] unspecified
54+
55+
// Parenthesis.
56+
(.red);
57+
// ^
58+
// [analyzer] unspecified
59+
// [cfe] unspecified
60+
61+
// Map operators.
62+
var map = <Color, Color> {.red: .red, .blue: .blue, .green: .green};
63+
map[.red];
64+
// ^
65+
// [analyzer] unspecified
66+
// [cfe] unspecified
67+
68+
map[.blue] = Color.red;
69+
// ^
70+
// [analyzer] unspecified
71+
// [cfe] unspecified
72+
73+
// Null assert.
74+
.one!;
75+
// ^
76+
// [analyzer] unspecified
77+
// [cfe] unspecified
78+
79+
// Assignment operators.
80+
.red = 1;
81+
// ^
82+
// [analyzer] unspecified
83+
// [cfe] unspecified
84+
85+
.red *= 1;
86+
// ^
87+
// [analyzer] unspecified
88+
// [cfe] unspecified
89+
90+
.red /= 1;
91+
// ^
92+
// [analyzer] unspecified
93+
// [cfe] unspecified
94+
95+
.red ~/= 1;
96+
// ^
97+
// [analyzer] unspecified
98+
// [cfe] unspecified
99+
100+
.red %= 1;
101+
// ^
102+
// [analyzer] unspecified
103+
// [cfe] unspecified
104+
105+
.red += 1;
106+
// ^
107+
// [analyzer] unspecified
108+
// [cfe] unspecified
109+
110+
.red -= 1;
111+
// ^
112+
// [analyzer] unspecified
113+
// [cfe] unspecified
114+
115+
.red <<= 1;
116+
// ^
117+
// [analyzer] unspecified
118+
// [cfe] unspecified
119+
120+
.red >>>= 1;
121+
// ^
122+
// [analyzer] unspecified
123+
// [cfe] unspecified
124+
125+
.red >>= 1;
126+
// ^
127+
// [analyzer] unspecified
128+
// [cfe] unspecified
129+
130+
.red &= 1;
131+
// ^
132+
// [analyzer] unspecified
133+
// [cfe] unspecified
134+
135+
.red ^= 1;
136+
// ^
137+
// [analyzer] unspecified
138+
// [cfe] unspecified
139+
140+
.red |= 1;
141+
// ^
142+
// [analyzer] unspecified
143+
// [cfe] unspecified
144+
145+
.red ??= 1;
146+
// ^
147+
// [analyzer] unspecified
148+
// [cfe] unspecified
149+
}

0 commit comments

Comments
 (0)