[test] Porting VM tearoff tests to the hot reload test framework.

One test crashes due to #59671

Change-Id: I685bab8a87171c619da5bd685bf75fffe9fa7f39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399322
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
This commit is contained in:
MarkZ
2024-12-07 00:10:41 +00:00
committed by Commit Queue
parent af2527723b
commit 8aa86087a6
16 changed files with 609 additions and 0 deletions
@@ -0,0 +1,34 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1867
invoke(f, a) {
return f(a);
}
var f, r1, r2;
class C {
foo(x) => x;
}
helper() {
var c = C();
f = c.foo;
r1 = invoke(f, 1);
}
Future<void> main() async {
helper();
await hotReload();
Expect.throws<NoSuchMethodError>(
helper,
(err) => '$err'.contains("Class 'C' has no instance method "
"'foo' with matching arguments."));
}
@@ -0,0 +1,53 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1867
invoke(f, a) {
return f(a);
}
var f, r1, r2;
class C {
foo(x, y, z) => x + y + z;
}
helper() {
r2 = invoke(f, 1);
return '$r1 $r2';
}
Future<void> main() async {
helper();
await hotReload();
Expect.throws<NoSuchMethodError>(
helper,
(err) => '$err'.contains("Class 'C' has no instance method "
"'foo' with matching arguments."));
}
/** DIFF **/
/*
@@ -15,13 +15,12 @@
var f, r1, r2;
class C {
- foo(x) => x;
+ foo(x, y, z) => x + y + z;
}
helper() {
- var c = C();
- f = c.foo;
- r1 = invoke(f, 1);
+ r2 = invoke(f, 1);
+ return '$r1 $r2';
}
Future<void> main() async {
*/
@@ -0,0 +1,33 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1924
invoke(f, a) {
return f(a);
}
var f, r1, r2;
class C {
static foo(x) => x;
}
helper() {
f = C.foo;
r1 = invoke(f, 1);
}
Future<void> main() async {
helper();
await hotReload();
Expect.throws<NoSuchMethodError>(
helper,
(err) => '$err'.contains("Closure call with mismatched arguments: "
"function 'C.foo'"));
}
@@ -0,0 +1,52 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1924
invoke(f, a) {
return f(a);
}
var f, r1, r2;
class C {
static foo(x, y, z) => x + y + z;
}
helper() {
r2 = invoke(f, 1);
return '$r1 $r2';
}
Future<void> main() async {
helper();
await hotReload();
Expect.throws<NoSuchMethodError>(
helper,
(err) => '$err'.contains("Closure call with mismatched arguments: "
"function 'C.foo'"));
}
/** DIFF **/
/*
@@ -15,12 +15,12 @@
var f, r1, r2;
class C {
- static foo(x) => x;
+ static foo(x, y, z) => x + y + z;
}
helper() {
- f = C.foo;
- r1 = invoke(f, 1);
+ r2 = invoke(f, 1);
+ return '$r1 $r2';
}
Future<void> main() async {
*/
@@ -0,0 +1,27 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1732
class C {
static foo() => 'old';
}
var f1, f2;
getFoo() => C.foo;
Future<void> main() async {
var f1 = getFoo();
await hotReload();
var f2 = getFoo();
Expect.equals('new', f1());
Expect.equals('new', f2());
Expect.equals(f1, f2);
Expect.identical(f1, f2);
}
@@ -0,0 +1,39 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1732
class C {
static foo() => 'new';
}
var f1, f2;
getFoo() => C.foo;
Future<void> main() async {
var f1 = getFoo();
await hotReload();
var f2 = getFoo();
Expect.equals('new', f1());
Expect.equals('new', f2());
Expect.equals(f1, f2);
Expect.identical(f1, f2);
}
/** DIFF **/
/*
@@ -9,7 +9,7 @@
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1732
class C {
- static foo() => 'old';
+ static foo() => 'new';
}
var f1, f2;
*/
@@ -0,0 +1,29 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1618
class C {
foo() => 'old';
}
var c, f1, f2;
helper() {
c = new C();
f1 = c.foo;
}
Future<void> main() async {
helper();
await hotReload();
helper();
Expect.equals('new', f1());
Expect.equals('new', f2());
Expect.equals(f1, f2);
Expect.notIdentical(f1, f2);
}
@@ -0,0 +1,47 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1618
class C {
foo() => 'new';
}
var c, f1, f2;
helper() {
f2 = c.foo;
}
Future<void> main() async {
helper();
await hotReload();
helper();
Expect.equals('new', f1());
Expect.equals('new', f2());
Expect.equals(f1, f2);
Expect.notIdentical(f1, f2);
}
/** DIFF **/
/*
@@ -9,13 +9,12 @@
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1618
class C {
- foo() => 'old';
+ foo() => 'new';
}
var c, f1, f2;
helper() {
- c = new C();
- f1 = c.foo;
+ f2 = c.foo;
}
Future<void> main() async {
*/
@@ -0,0 +1,24 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1770
var f1, f2;
foo() => 'old';
getFoo() => foo;
Future<void> main() async {
var f1 = getFoo();
await hotReload();
var f2 = getFoo();
Expect.equals('new', f1());
Expect.equals('new', f2());
Expect.equals(f1, f2);
Expect.identical(f1, f2);
}
@@ -0,0 +1,36 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1770
var f1, f2;
foo() => 'new';
getFoo() => foo;
Future<void> main() async {
var f1 = getFoo();
await hotReload();
var f2 = getFoo();
Expect.equals('new', f1());
Expect.equals('new', f2());
Expect.equals(f1, f2);
Expect.identical(f1, f2);
}
/** DIFF **/
/*
@@ -9,7 +9,7 @@
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1770
var f1, f2;
-foo() => 'old';
+foo() => 'new';
getFoo() => foo;
Future<void> main() async {
*/
@@ -0,0 +1,44 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1804
class C {
foo() => 'old';
}
List list = List<dynamic>.filled(2, null);
Set set = Set();
Future<void> main() async {
var c = C();
list[0] = c.foo;
list[1] = c.foo;
set.add(c.foo);
set.add(c.foo);
int countBefore = set.length;
await hotReload();
list[1] = c.foo;
set.add(c.foo);
set.add(c.foo);
int countAfter = set.length;
Expect.equals('new', list[0]());
Expect.equals('new', list[1]());
Expect.equals(list[0], list[1]);
Expect.notIdentical(list[0], list[1]);
Expect.equals(1, countBefore);
Expect.equals(1, countAfter);
Expect.equals('new', (set.first)());
Expect.equals(set.first, c.foo);
Expect.equals(set.first, c.foo);
Expect.notIdentical(set.first, c.foo);
set.remove(c.foo);
Expect.isEmpty(set);
}
@@ -0,0 +1,56 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1804
class C {
foo() => 'new';
}
List list = List<dynamic>.filled(2, null);
Set set = Set();
Future<void> main() async {
var c = C();
list[0] = c.foo;
list[1] = c.foo;
set.add(c.foo);
set.add(c.foo);
int countBefore = set.length;
await hotReload();
list[1] = c.foo;
set.add(c.foo);
set.add(c.foo);
int countAfter = set.length;
Expect.equals('new', list[0]());
Expect.equals('new', list[1]());
Expect.equals(list[0], list[1]);
Expect.notIdentical(list[0], list[1]);
Expect.equals(1, countBefore);
Expect.equals(1, countAfter);
Expect.equals('new', (set.first)());
Expect.equals(set.first, c.foo);
Expect.equals(set.first, c.foo);
Expect.notIdentical(set.first, c.foo);
set.remove(c.foo);
Expect.isEmpty(set);
}
/** DIFF **/
/*
@@ -9,7 +9,7 @@
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1804
class C {
- foo() => 'old';
+ foo() => 'new';
}
List list = List<dynamic>.filled(2, null);
*/
@@ -0,0 +1,21 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1656
class C {
static foo() => 'old';
}
var f1 = C.foo;
helper() {}
Future<void> main() async {
await hotReload();
Expect.throws<ArgumentError>(helper);
}
@@ -0,0 +1,43 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1656
class C {
static foo(i) => 'new:$i';
}
var f1;
helper() {
f1();
}
Future<void> main() async {
await hotReload();
Expect.throws<ArgumentError>(helper);
}
/** DIFF **/
/*
@@ -9,11 +9,13 @@
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1656
class C {
- static foo() => 'old';
+ static foo(i) => 'new:$i';
}
-var f1 = C.foo;
-helper() {}
+var f1;
+helper() {
+ f1();
+}
Future<void> main() async {
await hotReload();
*/
@@ -0,0 +1,27 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1693
class C {
static foo({String bar = 'bar'}) => 'old';
}
var f1;
helper() {
f1 = C.foo;
}
Future<void> main() async {
helper();
await hotReload();
Expect.throws<NoSuchMethodError>(
helper,
(err) =>
'$err'.contains("No static method 'foo' declared in class 'C'."));
}
@@ -0,0 +1,44 @@
// Copyright (c) 2024, 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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1693
class C {}
var f1;
helper() {
f1();
}
Future<void> main() async {
helper();
await hotReload();
Expect.throws<NoSuchMethodError>(
helper,
(err) =>
'$err'.contains("No static method 'foo' declared in class 'C'."));
}
/** DIFF **/
/*
@@ -8,13 +8,11 @@
// Adapted from:
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1693
-class C {
- static foo({String bar = 'bar'}) => 'old';
-}
+class C {}
var f1;
helper() {
- f1 = C.foo;
+ f1();
}
Future<void> main() async {
*/