Skip to content

Commit 7a0f27f

Browse files
bkonyiCommit Bot
authored and
Commit Bot
committed
[ Service ] Added service tests for enhanced enums
Fixes #47870 TEST=pkg/vm_service/test/enhanced_enum_test.dart Change-Id: Ifa55c894f331452d1d88131d892d6c153dcbe8cf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232225 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Ben Konyi <[email protected]>
1 parent 5d7445e commit 7a0f27f

File tree

2 files changed

+407
-0
lines changed

2 files changed

+407
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// Copyright (c) 2022, 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+
// SharedOptions=--enable-experiment=enhanced-enums
6+
7+
// ignore_for_file: experiment_not_enabled
8+
// @dart=2.17
9+
10+
import 'common/service_test_common.dart';
11+
import 'common/test_helper.dart';
12+
13+
const int LINE_A = 24;
14+
const int LINE_B = LINE_A + 11;
15+
const int LINE_C = LINE_B + 4;
16+
const int LINE_D = LINE_C + 4;
17+
const int LINE_E = LINE_D + 5;
18+
const int LINE_F = LINE_E + 4;
19+
const int LINE_G = LINE_F + 5;
20+
const int LINE_H = LINE_G + 4;
21+
22+
mixin M on Object {
23+
int mixedInMethod() {
24+
print('mixedInMethod'); // LINE_A
25+
return 0;
26+
}
27+
}
28+
29+
enum E with M {
30+
e1,
31+
e2,
32+
e3;
33+
34+
void instanceMethod() {
35+
print('instanceMethod'); // LINE_B
36+
}
37+
38+
static void staticMethod() {
39+
print('staticMethod'); // LINE_C
40+
}
41+
42+
int get getter {
43+
print('getter'); // LINE_D
44+
return 0;
45+
}
46+
47+
set setter(int x) {
48+
print('setter'); // LINE_E
49+
}
50+
51+
static int get staticGetter {
52+
print('staticGetter'); // LINE_F
53+
return 0;
54+
}
55+
56+
static set staticSetter(int x) {
57+
print('staticSetter'); // LINE_G
58+
}
59+
60+
String toString() {
61+
print('overriden toString'); // LINE_H
62+
return '';
63+
}
64+
}
65+
66+
void testMain() {
67+
E.staticMethod();
68+
E.staticGetter;
69+
E.staticSetter = 42;
70+
final e = E.e1;
71+
e.mixedInMethod();
72+
e.instanceMethod();
73+
e.getter;
74+
e.setter = 42;
75+
e.toString();
76+
}
77+
78+
const lines = <int>[
79+
LINE_C,
80+
LINE_F,
81+
LINE_G,
82+
LINE_A,
83+
LINE_B,
84+
LINE_D,
85+
LINE_E,
86+
LINE_H,
87+
];
88+
89+
const fileName = 'breakpoint_in_enhanced_enums_test.dart';
90+
final expected = <String>[
91+
for (final line in lines) '$fileName:$line:5',
92+
];
93+
94+
final stops = <String>[];
95+
96+
final tests = <IsolateTest>[
97+
hasPausedAtStart,
98+
for (final line in lines) setBreakpointAtLine(line),
99+
resumeProgramRecordingStops(stops, false),
100+
checkRecordedStops(stops, expected),
101+
];
102+
103+
main([args = const <String>[]]) => runIsolateTests(
104+
args,
105+
tests,
106+
fileName,
107+
testeeConcurrent: testMain,
108+
pause_on_start: true,
109+
pause_on_exit: true,
110+
experiments: ['enhanced-enums'],
111+
);

0 commit comments

Comments
 (0)