[tests] Porting misc hot reload tests.
Change-Id: Ib77f447954049315a6a4812cf1d6066529fd9057 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406683 Reviewed-by: Nate Biggs <natebiggs@google.com> Commit-Queue: Mark Zhou <markzipan@google.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// 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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L3546
|
||||
|
||||
enum Fruit { Apple, Banana }
|
||||
|
||||
helper() {
|
||||
String r = '';
|
||||
r += Fruit.Apple.toString();
|
||||
r += ' ';
|
||||
r += Fruit.Banana.toString();
|
||||
return r;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals('Fruit.Apple Fruit.Banana', helper());
|
||||
await hotReload();
|
||||
|
||||
Expect.equals('Fruit.Apple Fruit.Cantaloupe Fruit.Banana', helper());
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L3546
|
||||
|
||||
enum Fruit { Apple, Cantaloupe, Banana }
|
||||
|
||||
helper() {
|
||||
String r = '';
|
||||
r += Fruit.Apple.toString();
|
||||
r += ' ';
|
||||
r += Fruit.Cantaloupe.toString();
|
||||
r += ' ';
|
||||
r += Fruit.Banana.toString();
|
||||
return r;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals('Fruit.Apple Fruit.Banana', helper());
|
||||
await hotReload();
|
||||
|
||||
Expect.equals('Fruit.Apple Fruit.Cantaloupe Fruit.Banana', helper());
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L3546
|
||||
|
||||
-enum Fruit { Apple, Banana }
|
||||
+enum Fruit { Apple, Cantaloupe, Banana }
|
||||
|
||||
helper() {
|
||||
String r = '';
|
||||
r += Fruit.Apple.toString();
|
||||
r += ' ';
|
||||
+ r += Fruit.Cantaloupe.toString();
|
||||
+ r += ' ';
|
||||
r += Fruit.Banana.toString();
|
||||
return r;
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,20 @@
|
||||
// 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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L47
|
||||
|
||||
helper() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals(4, helper());
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(10, helper());
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L47
|
||||
|
||||
helper() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals(4, helper());
|
||||
await hotReload();
|
||||
|
||||
Expect.equals(10, helper());
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// https://github.com/dart-lang/sdk/blob/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L47
|
||||
|
||||
helper() {
|
||||
- return 4;
|
||||
+ return 10;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -0,0 +1,20 @@
|
||||
// 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/174ce4005f34bc860d1a4189ff21292b0796c94b/runtime/vm/isolate_reload_test.cc#L6091
|
||||
|
||||
dynamic field = (a) => 'a$a';
|
||||
|
||||
Future<void> main() async {
|
||||
dynamic f = field;
|
||||
Expect.equals('ab', f('b'));
|
||||
await hotReload();
|
||||
|
||||
dynamic g = field;
|
||||
Expect.equals('ac', g('c'));
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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/174ce4005f34bc860d1a4189ff21292b0796c94b/runtime/vm/isolate_reload_test.cc#L6091
|
||||
|
||||
dynamic field = (_, __) => 'Not executed';
|
||||
|
||||
Future<void> main() async {
|
||||
dynamic f = field;
|
||||
Expect.equals('ab', f('b'));
|
||||
await hotReload();
|
||||
|
||||
dynamic g = field;
|
||||
Expect.equals('ac', g('c'));
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/174ce4005f34bc860d1a4189ff21292b0796c94b/runtime/vm/isolate_reload_test.cc#L6091
|
||||
|
||||
-dynamic field = (a) => 'a$a';
|
||||
+dynamic field = (_, __) => 'Not executed';
|
||||
|
||||
Future<void> main() async {
|
||||
dynamic f = field;
|
||||
*/
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"expectedErrors": {
|
||||
"1": "Error: Expected an identifier, but got '...'"
|
||||
}
|
||||
}
|
||||
@@ -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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L5209
|
||||
|
||||
// When an initializer expression has a syntax error, we detect it at reload
|
||||
// time.
|
||||
|
||||
class Foo {
|
||||
int x = 4;
|
||||
}
|
||||
|
||||
late Foo value;
|
||||
helper() {
|
||||
value = Foo();
|
||||
return value.x;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals(4, helper());
|
||||
// Add the field y with a syntax error in the initializing expression.
|
||||
// The reload fails because the initializing expression is parsed at
|
||||
// class finalization time.
|
||||
await hotReload(expectRejection: true);
|
||||
}
|
||||
@@ -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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L5209
|
||||
|
||||
// When an initializer expression has a syntax error, we detect it at reload
|
||||
// time.
|
||||
|
||||
class Foo {
|
||||
int x = 4;
|
||||
int y = ......;
|
||||
}
|
||||
|
||||
late Foo value;
|
||||
helper() {
|
||||
return value.y;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals(4, helper());
|
||||
// Add the field y with a syntax error in the initializing expression.
|
||||
// The reload fails because the initializing expression is parsed at
|
||||
// class finalization time.
|
||||
await hotReload(expectRejection: true);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
|
||||
class Foo {
|
||||
int x = 4;
|
||||
+ int y = ......;
|
||||
}
|
||||
|
||||
late Foo value;
|
||||
helper() {
|
||||
- value = Foo();
|
||||
- return value.x;
|
||||
+ return value.y;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"expectedErrors": {
|
||||
"1": "Error: Expected an identifier, but got '...'"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// 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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L5247
|
||||
|
||||
// When an initializer expression has a syntax error, we detect it at reload
|
||||
// time.
|
||||
|
||||
class Foo {
|
||||
Foo() { /* default constructor */ }
|
||||
int x = 4;
|
||||
}
|
||||
|
||||
late Foo value;
|
||||
helper() {
|
||||
value = Foo();
|
||||
return value.x;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals(4, helper());
|
||||
// Add the field y with a syntax error in the initializing expression.
|
||||
// The reload fails because the initializing expression is parsed at
|
||||
// class finalization time.
|
||||
await hotReload(expectRejection: true);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L5247
|
||||
|
||||
// When an initializer expression has a syntax error, we detect it at reload
|
||||
// time.
|
||||
|
||||
class Foo {
|
||||
Foo() { /* default constructor */ }
|
||||
int x = 4;
|
||||
int y = ......;
|
||||
}
|
||||
|
||||
late Foo value;
|
||||
helper() {
|
||||
return value.y;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals(4, helper());
|
||||
// Add the field y with a syntax error in the initializing expression.
|
||||
// The reload fails because the initializing expression is parsed at
|
||||
// class finalization time.
|
||||
await hotReload(expectRejection: true);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
class Foo {
|
||||
Foo() { /* default constructor */ }
|
||||
int x = 4;
|
||||
+ int y = ......;
|
||||
}
|
||||
|
||||
late Foo value;
|
||||
helper() {
|
||||
- value = Foo();
|
||||
- return value.x;
|
||||
+ return value.y;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L4140
|
||||
|
||||
class A {
|
||||
var x;
|
||||
get yourself => this;
|
||||
}
|
||||
|
||||
var retained1;
|
||||
var retained2;
|
||||
|
||||
Future<void> main() async {
|
||||
retained1 = new A();
|
||||
retained2 = new A();
|
||||
retained1.x = retained2;
|
||||
retained2.x = retained1;
|
||||
Expect.identical(retained1.x.yourself, retained2);
|
||||
Expect.identical(retained2.x.yourself, retained1);
|
||||
|
||||
await hotReload();
|
||||
}
|
||||
@@ -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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L4140
|
||||
|
||||
class A {
|
||||
var x;
|
||||
var y;
|
||||
var z;
|
||||
var w;
|
||||
get yourself => this;
|
||||
}
|
||||
|
||||
var retained1;
|
||||
var retained2;
|
||||
|
||||
Future<void> main() async {
|
||||
retained1 = new A();
|
||||
retained2 = new A();
|
||||
retained1.x = retained2;
|
||||
retained2.x = retained1;
|
||||
Expect.identical(retained1.x.yourself, retained2);
|
||||
Expect.identical(retained2.x.yourself, retained1);
|
||||
|
||||
await hotReload();
|
||||
|
||||
Expect.identical(retained1.x.yourself, retained2);
|
||||
Expect.identical(retained2.x.yourself, retained1);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
|
||||
class A {
|
||||
var x;
|
||||
+ var y;
|
||||
+ var z;
|
||||
+ var w;
|
||||
get yourself => this;
|
||||
}
|
||||
|
||||
@@ -25,4 +28,7 @@ Future<void> main() async {
|
||||
Expect.identical(retained2.x.yourself, retained1);
|
||||
|
||||
await hotReload();
|
||||
+
|
||||
+ Expect.identical(retained1.x.yourself, retained2);
|
||||
+ Expect.identical(retained2.x.yourself, retained1);
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"expectedErrors": {
|
||||
"1": "Variables must be declared using the keywords 'const', 'final', 'var' or a type name"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L1257
|
||||
|
||||
helper() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals(4, helper());
|
||||
await hotReload(expectRejection: true);
|
||||
}
|
||||
@@ -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/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L1257
|
||||
|
||||
kjsadkfjaksldfjklsadf;
|
||||
helper() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
Expect.equals(4, helper());
|
||||
await hotReload(expectRejection: true);
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/13f5fc6b168d8b6e5843d17fb9ba77f1343a7dfe/runtime/vm/isolate_reload_test.cc#L1257
|
||||
|
||||
+kjsadkfjaksldfjklsadf;
|
||||
helper() {
|
||||
return 4;
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user