Skip to content

Commit ebbdbe4

Browse files
MarkzipanCommit Queue
authored andcommitted
[tests] Porting instance and hierarchy change tests to the hot reload framework.
Change-Id: I7a11a43d34772f2020dda235327da71fa388f3ad Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406062 Commit-Queue: Mark Zhou <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]>
1 parent 4f80ed7 commit ebbdbe4

File tree

25 files changed

+1030
-0
lines changed

25 files changed

+1030
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3806
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Foo {a, b, c:42} -> Foo {c:42}
13+
// Validate: c keeps the value in the retained Foo object.
14+
15+
class Foo {
16+
var a;
17+
var b;
18+
var c;
19+
}
20+
21+
var f;
22+
23+
Future<void> main() async {
24+
f = Foo();
25+
f.c = 42;
26+
Expect.equals(42, f.c);
27+
await hotReload();
28+
29+
Expect.equals(42, f.c);
30+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3806
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Foo {a, b, c:42} -> Foo {c:42}
13+
// Validate: c keeps the value in the retained Foo object.
14+
15+
class Foo {
16+
var c;
17+
}
18+
19+
var f;
20+
21+
Future<void> main() async {
22+
f = Foo();
23+
f.c = 42;
24+
Expect.equals(42, f.c);
25+
await hotReload();
26+
27+
Expect.equals(42, f.c);
28+
}
29+
30+
/** DIFF **/
31+
/*
32+
// Validate: c keeps the value in the retained Foo object.
33+
34+
class Foo {
35+
- var a;
36+
- var b;
37+
var c;
38+
}
39+
40+
*/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3841
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Foo {} -> Foo {c:null}
13+
// Validate: c is initialized to null the retained Foo object.
14+
15+
class Foo {}
16+
17+
var f;
18+
19+
Future<void> main() async {
20+
f = Foo();
21+
await hotReload();
22+
23+
Expect.isNull(f.c);
24+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3841
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Foo {} -> Foo {c:null}
13+
// Validate: c is initialized to null the retained Foo object.
14+
15+
class Foo {
16+
var c;
17+
}
18+
19+
var f;
20+
21+
Future<void> main() async {
22+
f = Foo();
23+
await hotReload();
24+
25+
Expect.isNull(f.c);
26+
}
27+
28+
/** DIFF **/
29+
/*
30+
// Change: Foo {} -> Foo {c:null}
31+
// Validate: c is initialized to null the retained Foo object.
32+
33+
-class Foo {}
34+
+class Foo {
35+
+ var c;
36+
+}
37+
38+
var f;
39+
40+
*/
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3872
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Foo {c:42} -> Foo {}
13+
// Validate: running the after script fails.
14+
15+
class Foo {
16+
var c;
17+
}
18+
19+
var f;
20+
21+
Future<void> main() async {
22+
f = Foo();
23+
f.c = 42;
24+
Expect.equals(42, f.c);
25+
await hotReload();
26+
27+
Expect.throws<NoSuchMethodError>(() => f.c);
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3872
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Foo {c:42} -> Foo {}
13+
// Validate: running the after script fails.
14+
15+
class Foo {}
16+
17+
var f;
18+
19+
Future<void> main() async {
20+
f = Foo();
21+
f.c = 42;
22+
Expect.equals(42, f.c);
23+
await hotReload();
24+
25+
Expect.throws<NoSuchMethodError>(() => f.c);
26+
}
27+
28+
/** DIFF **/
29+
/*
30+
// Change: Foo {c:42} -> Foo {}
31+
// Validate: running the after script fails.
32+
33+
-class Foo {
34+
- var c;
35+
-}
36+
+class Foo {}
37+
38+
var f;
39+
40+
*/
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3908
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Foo {a, b, c:42, d} -> Foo {c:42, g}
13+
// Validate: c keeps the value in the retained Foo object.
14+
15+
class Foo<A, B> {
16+
var a;
17+
var b;
18+
var c;
19+
var d;
20+
}
21+
22+
helper() {
23+
f = Foo();
24+
f.a = 1;
25+
f.b = 2;
26+
f.c = 3;
27+
f.d = 4;
28+
}
29+
30+
var f;
31+
32+
Future<void> main() async {
33+
helper();
34+
Expect.equals(3, f.c);
35+
await hotReload();
36+
37+
Expect.equals(3, f.c);
38+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3908
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Foo {a, b, c:42, d} -> Foo {c:42, g}
13+
// Validate: c keeps the value in the retained Foo object.
14+
15+
class Foo<A, B> {
16+
var c;
17+
var g;
18+
}
19+
20+
helper() {}
21+
22+
var f;
23+
24+
Future<void> main() async {
25+
helper();
26+
Expect.equals(3, f.c);
27+
await hotReload();
28+
29+
Expect.equals(3, f.c);
30+
}
31+
32+
/** DIFF **/
33+
/*
34+
// Validate: c keeps the value in the retained Foo object.
35+
36+
class Foo<A, B> {
37+
- var a;
38+
- var b;
39+
var c;
40+
- var d;
41+
+ var g;
42+
}
43+
44+
-helper() {
45+
- f = Foo();
46+
- f.a = 1;
47+
- f.b = 2;
48+
- f.c = 3;
49+
- f.d = 4;
50+
-}
51+
+helper() {}
52+
53+
var f;
54+
55+
*/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3948
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
13+
// Validate: c keeps the value in the retained Foo object.
14+
15+
class Bar {
16+
var c;
17+
}
18+
19+
class Foo extends Bar {
20+
var d;
21+
var e;
22+
}
23+
24+
var f;
25+
26+
Future<void> main() async {
27+
f = Foo();
28+
f.c = 42;
29+
Expect.equals(42, f.c);
30+
await hotReload();
31+
32+
Expect.equals(42, f.c);
33+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3948
10+
11+
// Tests reload succeeds when instance format changes.
12+
// Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
13+
// Validate: c keeps the value in the retained Foo object.
14+
15+
class Foo {
16+
var c;
17+
}
18+
19+
var f;
20+
21+
Future<void> main() async {
22+
f = Foo();
23+
f.c = 42;
24+
Expect.equals(42, f.c);
25+
await hotReload();
26+
27+
Expect.equals(42, f.c);
28+
}
29+
30+
/** DIFF **/
31+
/*
32+
// Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
33+
// Validate: c keeps the value in the retained Foo object.
34+
35+
-class Bar {
36+
+class Foo {
37+
var c;
38+
}
39+
40+
-class Foo extends Bar {
41+
- var d;
42+
- var e;
43+
-}
44+
-
45+
var f;
46+
47+
Future<void> main() async {
48+
*/

0 commit comments

Comments
 (0)