Skip to content

Commit 5b01285

Browse files
MarkzipanCommit Queue
authored andcommitted
[ddc] Porting VM hot reload tests to the hot reload framework related to type updates.
Change-Id: I3c42781acd253ac82658593c96ab92ef6c2cdb50 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392466 Commit-Queue: Mark Zhou <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]>
1 parent 4436320 commit 5b01285

File tree

59 files changed

+1283
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1283
-22
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"exclude": []
3+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
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/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5493
10+
11+
// Note: The original VM test checks for allocated objects on the heap after a
12+
// hot reload. There isn't an obvious web analogue, so we've left this off
13+
// unless this side effect becomes visible across platforms.
14+
15+
class C {
16+
int value = 42;
17+
}
18+
19+
class Foo {
20+
static var x = C();
21+
}
22+
23+
late var closure;
24+
25+
helper() {
26+
closure = () => Foo.x.value;
27+
}
28+
29+
Future<void> main() async {
30+
helper();
31+
Expect.equals(42, closure());
32+
await hotReload();
33+
34+
Expect.throws(closure);
35+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
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/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5493
10+
11+
// Note: The original VM test checks for allocated objects on the heap after a
12+
// hot reload. There isn't an obvious web analogue, so we've left this off
13+
// unless this side effect becomes visible across platforms.
14+
15+
class C {
16+
int value = 42;
17+
}
18+
19+
class Foo {}
20+
21+
late var closure;
22+
23+
helper() {}
24+
25+
Future<void> main() async {
26+
helper();
27+
Expect.equals(42, closure());
28+
await hotReload();
29+
30+
Expect.throws(closure);
31+
}
32+
/** DIFF **/
33+
/*
34+
@@ -16,15 +16,11 @@
35+
int value = 42;
36+
}
37+
38+
-class Foo {
39+
- static var x = C();
40+
-}
41+
+class Foo {}
42+
43+
late var closure;
44+
45+
-helper() {
46+
- closure = () => Foo.x.value;
47+
-}
48+
+helper() {}
49+
50+
Future<void> main() async {
51+
helper();
52+
*/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"exclude": []
3+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
import 'dart:typed_data';
6+
import 'package:expect/expect.dart';
7+
import 'package:reload_test/reload_test_utils.dart';
8+
9+
// Adapted from:
10+
// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674
11+
12+
class Foo {
13+
int x = 42;
14+
}
15+
16+
Future<void> main() async {
17+
Expect.type<int>(Foo().x);
18+
Expect.equals(42, Foo().x);
19+
await hotReload();
20+
21+
Expect.type<String>(Foo().x);
22+
Expect.equals('42', Foo().x);
23+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
import 'dart:typed_data';
6+
import 'package:expect/expect.dart';
7+
import 'package:reload_test/reload_test_utils.dart';
8+
9+
// Adapted from:
10+
// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674
11+
12+
class Foo {
13+
String x = '42';
14+
}
15+
16+
Future<void> main() async {
17+
Expect.type<int>(Foo().x);
18+
Expect.equals(42, Foo().x);
19+
await hotReload();
20+
21+
Expect.type<String>(Foo().x);
22+
Expect.equals('42', Foo().x);
23+
}
24+
/** DIFF **/
25+
/*
26+
@@ -10,7 +10,7 @@
27+
// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674
28+
29+
class Foo {
30+
- int x = 42;
31+
+ String x = '42';
32+
}
33+
34+
Future<void> main() async {
35+
*/

tests/hot_reload/existing_field_changes_type_indirect/main.0.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Future<void> main() async {
3030

3131
await hotReload();
3232

33-
Expect.contains(
34-
"type 'B' is not a subtype of type 'A' of 'function result'", helper());
33+
Expect.contains("type 'B' is not a subtype of type 'A'", helper());
3534
Expect.equals(1, hotReloadGeneration);
3635
}

tests/hot_reload/existing_field_changes_type_indirect/main.1.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ Future<void> main() async {
3030

3131
await hotReload();
3232

33-
Expect.contains(
34-
"type 'B' is not a subtype of type 'A' of 'function result'", helper());
33+
Expect.contains("type 'B' is not a subtype of type 'A'", helper());
3534
Expect.equals(1, hotReloadGeneration);
3635
}
3736
/** DIFF **/

tests/hot_reload/existing_field_changes_type_indirect_function/main.0.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ Future<void> main() async {
3434

3535
// B is no longer a subtype of A.
3636
Expect.equals(
37-
"type '(A) => bool' is not a subtype of type "
38-
"'(B) => bool' of 'function result'",
39-
helper());
37+
"type '(A) => bool' is not a subtype of type '(B) => bool'", helper());
4038
Expect.equals(1, hotReloadGeneration);
4139
}

tests/hot_reload/existing_field_changes_type_indirect_function/main.1.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ Future<void> main() async {
3737

3838
// B is no longer a subtype of A.
3939
Expect.equals(
40-
"type '(A) => bool' is not a subtype of type "
41-
"'(B) => bool' of 'function result'",
42-
helper());
40+
"type '(A) => bool' is not a subtype of type '(B) => bool'", helper());
4341
Expect.equals(1, hotReloadGeneration);
4442
}
4543
/** DIFF **/

0 commit comments

Comments
 (0)