Skip to content

Commit 29fe663

Browse files
MarkzipanCommit Queue
authored andcommitted
[test] Porting VM enum tests to the hot reload test framework
Change-Id: I8fc17823e5236ab80d89d96c6e3f7d4b82b5b369 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402762 Reviewed-by: Nate Biggs <[email protected]> Commit-Queue: Mark Zhou <[email protected]>
1 parent 178de40 commit 29fe663

File tree

32 files changed

+1275
-0
lines changed

32 files changed

+1275
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2085
10+
11+
enum Fruit { Apple, Banana }
12+
13+
void helper() {}
14+
15+
Future<void> main() async {
16+
Expect.equals(0, Fruit.Apple.index);
17+
Expect.equals('Fruit.Apple', Fruit.Apple.toString());
18+
Expect.equals(1, Fruit.Banana.index);
19+
Expect.equals('Fruit.Banana', Fruit.Banana.toString());
20+
await hotReload();
21+
22+
Expect.equals(0, Fruit.Apple.index);
23+
Expect.equals('Fruit.Apple', Fruit.Apple.toString());
24+
Expect.equals(2, Fruit.Banana.index);
25+
Expect.equals('Fruit.Banana', Fruit.Banana.toString());
26+
helper();
27+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2085
10+
11+
enum Fruit { Apple, Cantaloupe, Banana }
12+
13+
void helper() {
14+
Expect.equals(1, Fruit.Cantaloupe.index);
15+
Expect.equals('Fruit.Cantaloupe', Fruit.Cantaloupe.toString());
16+
}
17+
18+
Future<void> main() async {
19+
Expect.equals(0, Fruit.Apple.index);
20+
Expect.equals('Fruit.Apple', Fruit.Apple.toString());
21+
Expect.equals(1, Fruit.Banana.index);
22+
Expect.equals('Fruit.Banana', Fruit.Banana.toString());
23+
await hotReload();
24+
25+
Expect.equals(0, Fruit.Apple.index);
26+
Expect.equals('Fruit.Apple', Fruit.Apple.toString());
27+
Expect.equals(2, Fruit.Banana.index);
28+
Expect.equals('Fruit.Banana', Fruit.Banana.toString());
29+
helper();
30+
}
31+
32+
/** DIFF **/
33+
/*
34+
@@ -8,9 +8,12 @@
35+
// Adapted from:
36+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2085
37+
38+
-enum Fruit { Apple, Banana }
39+
+enum Fruit { Apple, Cantaloupe, Banana }
40+
41+
-void helper() {}
42+
+void helper() {
43+
+ Expect.equals(1, Fruit.Cantaloupe.index);
44+
+ Expect.equals('Fruit.Cantaloupe', Fruit.Cantaloupe.toString());
45+
+}
46+
47+
Future<void> main() async {
48+
Expect.equals(0, Fruit.Apple.index);
49+
@@ -25,3 +28,4 @@
50+
Expect.equals('Fruit.Banana', Fruit.Banana.toString());
51+
helper();
52+
}
53+
+
54+
*/
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2170
10+
11+
enum Fruit { Apple, Banana, Cantaloupe }
12+
13+
var x;
14+
15+
Future<void> main() async {
16+
x = Fruit.Cantaloupe;
17+
Expect.equals('Fruit.Cantaloupe', x.toString());
18+
Expect.type<int>(x.hashCode);
19+
Expect.equals(2, x.index);
20+
await hotReload();
21+
22+
Expect.equals('Fruit.Deleted enum value from Fruit', x.toString());
23+
Expect.type<int>(x.hashCode);
24+
Expect.equals(-1, x.index);
25+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2170
10+
11+
enum Fruit { Apple, Banana }
12+
13+
var x;
14+
15+
Future<void> main() async {
16+
Expect.equals('Fruit.Cantaloupe', x.toString());
17+
Expect.type<int>(x.hashCode);
18+
Expect.equals(2, x.index);
19+
await hotReload();
20+
21+
Expect.equals('Fruit.Deleted enum value from Fruit', x.toString());
22+
Expect.type<int>(x.hashCode);
23+
Expect.equals(-1, x.index);
24+
}
25+
26+
/** DIFF **/
27+
/*
28+
@@ -8,12 +8,11 @@
29+
// Adapted from:
30+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2170
31+
32+
-enum Fruit { Apple, Banana, Cantaloupe }
33+
+enum Fruit { Apple, Banana }
34+
35+
var x;
36+
37+
Future<void> main() async {
38+
- x = Fruit.Cantaloupe;
39+
Expect.equals('Fruit.Cantaloupe', x.toString());
40+
Expect.type<int>(x.hashCode);
41+
Expect.equals(2, x.index);
42+
@@ -23,3 +22,4 @@
43+
Expect.type<int>(x.hashCode);
44+
Expect.equals(-1, x.index);
45+
}
46+
+
47+
*/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L1979
10+
11+
enum Fruit { Apple, Banana }
12+
13+
var x;
14+
15+
Future<void> main() async {
16+
x = Fruit.Banana;
17+
await hotReload();
18+
Expect.equals(Fruit.Banana, x);
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L1979
10+
11+
enum Fruit { Apple, Banana }
12+
13+
var x;
14+
15+
Future<void> main() async {
16+
x = Fruit.Banana;
17+
await hotReload();
18+
Expect.equals(Fruit.Banana, x);
19+
}
20+
21+
/** DIFF **/
22+
/*
23+
@@ -17,3 +17,4 @@
24+
await hotReload();
25+
Expect.equals(Fruit.Banana, x);
26+
}
27+
+
28+
*/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2015
10+
11+
enum Fruit { Apple, Banana }
12+
13+
var x;
14+
15+
Future<void> main() async {
16+
x = Fruit.Banana;
17+
await hotReload();
18+
Expect.identical(Fruit.Banana, x);
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2015
10+
11+
enum Fruit { Apple, Banana }
12+
13+
var x;
14+
15+
Future<void> main() async {
16+
x = Fruit.Banana;
17+
await hotReload();
18+
Expect.identical(Fruit.Banana, x);
19+
}
20+
21+
/** DIFF **/
22+
/*
23+
@@ -17,3 +17,4 @@
24+
await hotReload();
25+
Expect.identical(Fruit.Banana, x);
26+
}
27+
+
28+
*/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2207
10+
11+
enum Fruit { Apple, Banana, Cantaloupe }
12+
13+
var x, y, z, w;
14+
15+
Future<void> main() async {
16+
x = {
17+
Fruit.Apple: Fruit.Apple.index,
18+
Fruit.Banana: Fruit.Banana.index,
19+
Fruit.Cantaloupe: Fruit.Cantaloupe.index,
20+
};
21+
y = Fruit.Apple;
22+
z = Fruit.Banana;
23+
w = Fruit.Cantaloupe;
24+
await hotReload();
25+
26+
x.forEach((fruit, index) {
27+
Expect.identical(Fruit.values[index], fruit);
28+
});
29+
Expect.equals(x[Fruit.Apple], Fruit.Apple.index);
30+
Expect.equals(x[Fruit.Banana], Fruit.Banana.index);
31+
Expect.equals(x[Fruit.Cantaloupe], Fruit.Cantaloupe.index);
32+
Expect.equals(y, Fruit.values[x[Fruit.Apple]]);
33+
Expect.equals(z, Fruit.values[x[Fruit.Banana]]);
34+
Expect.equals(w, Fruit.values[x[Fruit.Cantaloupe]]);
35+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2025, 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+
import 'package:expect/expect.dart';
6+
import 'package:reload_test/reload_test_utils.dart';
7+
8+
// Adapted from:
9+
// https://github.com/dart-lang/sdk/blob/be2aabd91c67f7f331c49cb74e18fe5e469f04db/runtime/vm/isolate_reload_test.cc#L2207
10+
11+
enum Fruit { Apple, Banana, Cantaloupe }
12+
13+
var x, y, z, w;
14+
15+
Future<void> main() async {
16+
x = {
17+
Fruit.Apple: Fruit.Apple.index,
18+
Fruit.Banana: Fruit.Banana.index,
19+
Fruit.Cantaloupe: Fruit.Cantaloupe.index,
20+
};
21+
y = Fruit.Apple;
22+
z = Fruit.Banana;
23+
w = Fruit.Cantaloupe;
24+
await hotReload();
25+
26+
x.forEach((fruit, index) {
27+
Expect.identical(Fruit.values[index], fruit);
28+
});
29+
Expect.equals(x[Fruit.Apple], Fruit.Apple.index);
30+
Expect.equals(x[Fruit.Banana], Fruit.Banana.index);
31+
Expect.equals(x[Fruit.Cantaloupe], Fruit.Cantaloupe.index);
32+
Expect.equals(y, Fruit.values[x[Fruit.Apple]]);
33+
Expect.equals(z, Fruit.values[x[Fruit.Banana]]);
34+
Expect.equals(w, Fruit.values[x[Fruit.Cantaloupe]]);
35+
}
36+
37+
/** DIFF **/
38+
/*
39+
@@ -33,3 +33,4 @@
40+
Expect.equals(z, Fruit.values[x[Fruit.Banana]]);
41+
Expect.equals(w, Fruit.values[x[Fruit.Cantaloupe]]);
42+
}
43+
+
44+
*/

0 commit comments

Comments
 (0)