[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 <markzipan@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3806
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Foo {a, b, c:42} -> Foo {c:42}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Foo {
|
||||
var a;
|
||||
var b;
|
||||
var c;
|
||||
}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
f.c = 42;
|
||||
Expect.equals(42, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(42, f.c);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3806
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Foo {a, b, c:42} -> Foo {c:42}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Foo {
|
||||
var c;
|
||||
}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
f.c = 42;
|
||||
Expect.equals(42, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(42, f.c);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Foo {
|
||||
- var a;
|
||||
- var b;
|
||||
var c;
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3841
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Foo {} -> Foo {c:null}
|
||||
// Validate: c is initialized to null the retained Foo object.
|
||||
|
||||
class Foo {}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
await hotReload();
|
||||
|
||||
Expect.isNull(f.c);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3841
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Foo {} -> Foo {c:null}
|
||||
// Validate: c is initialized to null the retained Foo object.
|
||||
|
||||
class Foo {
|
||||
var c;
|
||||
}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
await hotReload();
|
||||
|
||||
Expect.isNull(f.c);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Change: Foo {} -> Foo {c:null}
|
||||
// Validate: c is initialized to null the retained Foo object.
|
||||
|
||||
-class Foo {}
|
||||
+class Foo {
|
||||
+ var c;
|
||||
+}
|
||||
|
||||
var f;
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3872
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Foo {c:42} -> Foo {}
|
||||
// Validate: running the after script fails.
|
||||
|
||||
class Foo {
|
||||
var c;
|
||||
}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
f.c = 42;
|
||||
Expect.equals(42, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.throws<NoSuchMethodError>(() => f.c);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3872
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Foo {c:42} -> Foo {}
|
||||
// Validate: running the after script fails.
|
||||
|
||||
class Foo {}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
f.c = 42;
|
||||
Expect.equals(42, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.throws<NoSuchMethodError>(() => f.c);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Change: Foo {c:42} -> Foo {}
|
||||
// Validate: running the after script fails.
|
||||
|
||||
-class Foo {
|
||||
- var c;
|
||||
-}
|
||||
+class Foo {}
|
||||
|
||||
var f;
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3908
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Foo {a, b, c:42, d} -> Foo {c:42, g}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Foo<A, B> {
|
||||
var a;
|
||||
var b;
|
||||
var c;
|
||||
var d;
|
||||
}
|
||||
|
||||
helper() {
|
||||
f = Foo();
|
||||
f.a = 1;
|
||||
f.b = 2;
|
||||
f.c = 3;
|
||||
f.d = 4;
|
||||
}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
helper();
|
||||
Expect.equals(3, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(3, f.c);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3908
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Foo {a, b, c:42, d} -> Foo {c:42, g}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Foo<A, B> {
|
||||
var c;
|
||||
var g;
|
||||
}
|
||||
|
||||
helper() {}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
helper();
|
||||
Expect.equals(3, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(3, f.c);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Foo<A, B> {
|
||||
- var a;
|
||||
- var b;
|
||||
var c;
|
||||
- var d;
|
||||
+ var g;
|
||||
}
|
||||
|
||||
-helper() {
|
||||
- f = Foo();
|
||||
- f.a = 1;
|
||||
- f.b = 2;
|
||||
- f.c = 3;
|
||||
- f.d = 4;
|
||||
-}
|
||||
+helper() {}
|
||||
|
||||
var f;
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3948
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Bar {
|
||||
var c;
|
||||
}
|
||||
|
||||
class Foo extends Bar {
|
||||
var d;
|
||||
var e;
|
||||
}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
f.c = 42;
|
||||
Expect.equals(42, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(42, f.c);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3948
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Foo {
|
||||
var c;
|
||||
}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
f.c = 42;
|
||||
Expect.equals(42, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(42, f.c);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
-class Bar {
|
||||
+class Foo {
|
||||
var c;
|
||||
}
|
||||
|
||||
-class Foo extends Bar {
|
||||
- var d;
|
||||
- var e;
|
||||
-}
|
||||
-
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3985
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Bar {a, b}, Foo : Bar {c:42} -> Bar {c:42}, Foo : Bar {}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Bar {
|
||||
var a;
|
||||
var b;
|
||||
}
|
||||
|
||||
class Foo extends Bar {
|
||||
var c;
|
||||
}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
f.c = 42;
|
||||
Expect.equals(42, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(42, f.c);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L3985
|
||||
|
||||
// Tests reload succeeds when instance format changes.
|
||||
// Change: Bar {a, b}, Foo : Bar {c:42} -> Bar {c:42}, Foo : Bar {}
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Bar {
|
||||
var c;
|
||||
}
|
||||
|
||||
class Foo extends Bar {}
|
||||
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
f = Foo();
|
||||
f.c = 42;
|
||||
Expect.equals(42, f.c);
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(42, f.c);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Validate: c keeps the value in the retained Foo object.
|
||||
|
||||
class Bar {
|
||||
- var a;
|
||||
- var b;
|
||||
-}
|
||||
-
|
||||
-class Foo extends Bar {
|
||||
var c;
|
||||
}
|
||||
|
||||
+class Foo extends Bar {}
|
||||
+
|
||||
var f;
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"expectedErrors": {
|
||||
"1": "type parameters have changed"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4024
|
||||
|
||||
// Tests reload fails when type parameters change.
|
||||
// Change: Foo<A,B> {a, b} -> Foo<A> {a}
|
||||
// Validate: the right error message is returned.
|
||||
|
||||
class Foo<A, B> {
|
||||
var a;
|
||||
var b;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Foo();
|
||||
await hotReload(expectRejection: true);
|
||||
|
||||
Foo();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4024
|
||||
|
||||
// Tests reload fails when type parameters change.
|
||||
// Change: Foo<A,B> {a, b} -> Foo<A> {a}
|
||||
// Validate: the right error message is returned.
|
||||
|
||||
class Foo<A> {
|
||||
var a;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Foo();
|
||||
await hotReload(expectRejection: true);
|
||||
|
||||
Foo();
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Change: Foo<A,B> {a, b} -> Foo<A> {a}
|
||||
// Validate: the right error message is returned.
|
||||
|
||||
-class Foo<A, B> {
|
||||
+class Foo<A> {
|
||||
var a;
|
||||
- var b;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4051
|
||||
|
||||
// Tests reload succeeds when type parameters are changed for allocated class.
|
||||
// Change: Foo<A,B> {a, b} -> Foo<A> {a}
|
||||
// Validate: return value from main is correct.
|
||||
// Please note: This test works because no instances are created from Foo.
|
||||
|
||||
class Foo<A, B> {
|
||||
var a;
|
||||
var b;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
await hotReload();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4051
|
||||
|
||||
// Tests reload succeeds when type parameters are changed for allocated class.
|
||||
// Change: Foo<A,B> {a, b} -> Foo<A> {a}
|
||||
// Validate: return value from main is correct.
|
||||
// Please note: This test works because no instances are created from Foo.
|
||||
|
||||
class Foo<A> {
|
||||
var a;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
await hotReload();
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Validate: return value from main is correct.
|
||||
// Please note: This test works because no instances are created from Foo.
|
||||
|
||||
-class Foo<A, B> {
|
||||
+class Foo<A> {
|
||||
var a;
|
||||
- var b;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4071
|
||||
|
||||
// Regression for handle sharing bug: Change the shape of two classes and see
|
||||
// that their instances don't change class.
|
||||
|
||||
class A {
|
||||
var x;
|
||||
}
|
||||
|
||||
class B {
|
||||
var x, y, z, w;
|
||||
}
|
||||
|
||||
var a, b;
|
||||
|
||||
Future<void> main() async {
|
||||
a = A();
|
||||
b = B();
|
||||
Expect.type<A>(a);
|
||||
Expect.type<B>(b);
|
||||
await hotReload();
|
||||
|
||||
Expect.type<A>(a);
|
||||
Expect.type<B>(b);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4071
|
||||
|
||||
// Regression for handle sharing bug: Change the shape of two classes and see
|
||||
// that their instances don't change class.
|
||||
|
||||
class A {
|
||||
var x, y;
|
||||
}
|
||||
|
||||
class B {
|
||||
var x, y, z, w, v;
|
||||
}
|
||||
|
||||
var a, b;
|
||||
|
||||
Future<void> main() async {
|
||||
a = A();
|
||||
b = B();
|
||||
Expect.type<A>(a);
|
||||
Expect.type<B>(b);
|
||||
await hotReload();
|
||||
|
||||
Expect.type<A>(a);
|
||||
Expect.type<B>(b);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// that their instances don't change class.
|
||||
|
||||
class A {
|
||||
- var x;
|
||||
+ var x, y;
|
||||
}
|
||||
|
||||
class B {
|
||||
- var x, y, z, w;
|
||||
+ var x, y, z, w, v;
|
||||
}
|
||||
|
||||
var a, b;
|
||||
*/
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"expectedErrors": {
|
||||
"1": "type parameters have changed"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4110
|
||||
|
||||
// Tests reload fails when type arguments change.
|
||||
// Change: Baz extends Foo<String> -> Baz extends Bar<String, double>
|
||||
// Validate: the right error message is returned.
|
||||
|
||||
class Foo<A> {
|
||||
var a;
|
||||
}
|
||||
|
||||
class Bar<B, C> extends Foo<B> {}
|
||||
|
||||
class Baz extends Foo<String> {}
|
||||
|
||||
Future<void> main() async {
|
||||
Baz();
|
||||
await hotReload(expectRejection: true);
|
||||
|
||||
Baz();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4110
|
||||
|
||||
// Tests reload fails when type arguments change.
|
||||
// Change: Baz extends Foo<String> -> Baz extends Bar<String, double>
|
||||
// Validate: the right error message is returned.
|
||||
|
||||
class Foo<A> {
|
||||
var a;
|
||||
}
|
||||
|
||||
class Bar<B, C> extends Foo<B> {}
|
||||
|
||||
class Baz extends Bar<String, double> {}
|
||||
|
||||
Future<void> main() async {
|
||||
Baz();
|
||||
await hotReload(expectRejection: true);
|
||||
|
||||
Baz();
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
|
||||
class Bar<B, C> extends Foo<B> {}
|
||||
|
||||
-class Baz extends Foo<String> {}
|
||||
+class Baz extends Bar<String, double> {}
|
||||
|
||||
Future<void> main() async {
|
||||
Baz();
|
||||
*/
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L959
|
||||
|
||||
class A {
|
||||
String name;
|
||||
A(this.name);
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
B(name) : super(name);
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
C(name) : super(name);
|
||||
}
|
||||
|
||||
helper() {}
|
||||
|
||||
var list = <dynamic>[A('a'), B('b'), C('c')];
|
||||
|
||||
check() {
|
||||
Expect.type<A>(list[0]);
|
||||
Expect.notType<B>(list[0]);
|
||||
Expect.notType<C>(list[0]);
|
||||
Expect.type<A>(list[1]);
|
||||
Expect.type<B>(list[1]);
|
||||
Expect.notType<C>(list[1]);
|
||||
Expect.type<A>(list[2]);
|
||||
Expect.type<B>(list[2]);
|
||||
Expect.type<C>(list[2]);
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
check();
|
||||
await hotReload();
|
||||
|
||||
helper();
|
||||
check();
|
||||
await hotReload();
|
||||
|
||||
// Revive the class B and make sure all allocated instances take
|
||||
// their place in the inheritance hierarchy.
|
||||
check();
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L959
|
||||
|
||||
class C {
|
||||
String name;
|
||||
C(this.name);
|
||||
}
|
||||
|
||||
class X extends C {
|
||||
X(name) : super(name);
|
||||
}
|
||||
|
||||
class A extends X {
|
||||
A(name) : super(name);
|
||||
}
|
||||
|
||||
helper() {
|
||||
list.add(new X('x'));
|
||||
}
|
||||
|
||||
var list;
|
||||
|
||||
check() {
|
||||
Expect.type<A>(list[0]);
|
||||
Expect.type<C>(list[0]);
|
||||
Expect.type<X>(list[0]);
|
||||
Expect.type<A>(list[1]);
|
||||
Expect.type<C>(list[1]);
|
||||
Expect.type<X>(list[1]);
|
||||
Expect.notType<A>(list[2]);
|
||||
Expect.type<C>(list[2]);
|
||||
Expect.notType<X>(list[2]);
|
||||
Expect.notType<A>(list[3]);
|
||||
Expect.type<C>(list[3]);
|
||||
Expect.type<X>(list[3]);
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
check();
|
||||
await hotReload();
|
||||
|
||||
helper();
|
||||
check();
|
||||
await hotReload();
|
||||
|
||||
// Revive the class B and make sure all allocated instances take
|
||||
// their place in the inheritance hierarchy.
|
||||
check();
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L959
|
||||
|
||||
-class A {
|
||||
+class C {
|
||||
String name;
|
||||
- A(this.name);
|
||||
+ C(this.name);
|
||||
}
|
||||
|
||||
-class B extends A {
|
||||
- B(name) : super(name);
|
||||
+class X extends C {
|
||||
+ X(name) : super(name);
|
||||
}
|
||||
|
||||
-class C extends B {
|
||||
- C(name) : super(name);
|
||||
+class A extends X {
|
||||
+ A(name) : super(name);
|
||||
}
|
||||
|
||||
-helper() {}
|
||||
+helper() {
|
||||
+ list.add(new X('x'));
|
||||
+}
|
||||
|
||||
-var list = <dynamic>[A('a'), B('b'), C('c')];
|
||||
+var list;
|
||||
|
||||
check() {
|
||||
Expect.type<A>(list[0]);
|
||||
- Expect.notType<B>(list[0]);
|
||||
- Expect.notType<C>(list[0]);
|
||||
+ Expect.type<C>(list[0]);
|
||||
+ Expect.type<X>(list[0]);
|
||||
Expect.type<A>(list[1]);
|
||||
- Expect.type<B>(list[1]);
|
||||
- Expect.notType<C>(list[1]);
|
||||
- Expect.type<A>(list[2]);
|
||||
- Expect.type<B>(list[2]);
|
||||
+ Expect.type<C>(list[1]);
|
||||
+ Expect.type<X>(list[1]);
|
||||
+ Expect.notType<A>(list[2]);
|
||||
Expect.type<C>(list[2]);
|
||||
+ Expect.notType<X>(list[2]);
|
||||
+ Expect.notType<A>(list[3]);
|
||||
+ Expect.type<C>(list[3]);
|
||||
+ Expect.type<X>(list[3]);
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -0,0 +1,123 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L959
|
||||
|
||||
class X {
|
||||
String name;
|
||||
X(this.name);
|
||||
}
|
||||
|
||||
class A extends X {
|
||||
A(name) : super(name);
|
||||
}
|
||||
|
||||
class B extends X {
|
||||
B(name) : super(name);
|
||||
}
|
||||
|
||||
class C extends A {
|
||||
C(name) : super(name);
|
||||
}
|
||||
|
||||
helper() {}
|
||||
|
||||
var list;
|
||||
|
||||
check() {
|
||||
Expect.type<A>(list[0]);
|
||||
Expect.notType<B>(list[0]);
|
||||
Expect.notType<C>(list[0]);
|
||||
Expect.type<X>(list[0]);
|
||||
Expect.notType<A>(list[1]);
|
||||
Expect.type<B>(list[1]);
|
||||
Expect.notType<C>(list[1]);
|
||||
Expect.type<X>(list[1]);
|
||||
Expect.type<A>(list[2]);
|
||||
Expect.notType<B>(list[2]);
|
||||
Expect.type<C>(list[2]);
|
||||
Expect.type<X>(list[2]);
|
||||
Expect.notType<A>(list[3]);
|
||||
Expect.notType<B>(list[3]);
|
||||
Expect.notType<C>(list[3]);
|
||||
Expect.type<X>(list[3]);
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
check();
|
||||
await hotReload();
|
||||
|
||||
helper();
|
||||
check();
|
||||
await hotReload();
|
||||
|
||||
// Revive the class B and make sure all allocated instances take
|
||||
// their place in the inheritance hierarchy.
|
||||
check();
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L959
|
||||
|
||||
-class C {
|
||||
+class X {
|
||||
String name;
|
||||
- C(this.name);
|
||||
-}
|
||||
-
|
||||
-class X extends C {
|
||||
- X(name) : super(name);
|
||||
+ X(this.name);
|
||||
}
|
||||
|
||||
class A extends X {
|
||||
A(name) : super(name);
|
||||
}
|
||||
|
||||
-helper() {
|
||||
- list.add(new X('x'));
|
||||
+class B extends X {
|
||||
+ B(name) : super(name);
|
||||
}
|
||||
|
||||
+class C extends A {
|
||||
+ C(name) : super(name);
|
||||
+}
|
||||
+
|
||||
+helper() {}
|
||||
+
|
||||
var list;
|
||||
|
||||
check() {
|
||||
Expect.type<A>(list[0]);
|
||||
- Expect.type<C>(list[0]);
|
||||
+ Expect.notType<B>(list[0]);
|
||||
+ Expect.notType<C>(list[0]);
|
||||
Expect.type<X>(list[0]);
|
||||
- Expect.type<A>(list[1]);
|
||||
- Expect.type<C>(list[1]);
|
||||
+ Expect.notType<A>(list[1]);
|
||||
+ Expect.type<B>(list[1]);
|
||||
+ Expect.notType<C>(list[1]);
|
||||
Expect.type<X>(list[1]);
|
||||
- Expect.notType<A>(list[2]);
|
||||
+ Expect.type<A>(list[2]);
|
||||
+ Expect.notType<B>(list[2]);
|
||||
Expect.type<C>(list[2]);
|
||||
- Expect.notType<X>(list[2]);
|
||||
+ Expect.type<X>(list[2]);
|
||||
Expect.notType<A>(list[3]);
|
||||
- Expect.type<C>(list[3]);
|
||||
+ Expect.notType<B>(list[3]);
|
||||
+ Expect.notType<C>(list[3]);
|
||||
Expect.type<X>(list[3]);
|
||||
}
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user