Skip to content

Commit 8aa8608

Browse files
MarkzipanCommit Queue
authored andcommitted
[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 <[email protected]> Commit-Queue: Mark Zhou <[email protected]>
1 parent af25277 commit 8aa8608

File tree

16 files changed

+609
-0
lines changed

16 files changed

+609
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1867
10+
11+
invoke(f, a) {
12+
return f(a);
13+
}
14+
15+
var f, r1, r2;
16+
17+
class C {
18+
foo(x) => x;
19+
}
20+
21+
helper() {
22+
var c = C();
23+
f = c.foo;
24+
r1 = invoke(f, 1);
25+
}
26+
27+
Future<void> main() async {
28+
helper();
29+
await hotReload();
30+
Expect.throws<NoSuchMethodError>(
31+
helper,
32+
(err) => '$err'.contains("Class 'C' has no instance method "
33+
"'foo' with matching arguments."));
34+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1867
10+
11+
invoke(f, a) {
12+
return f(a);
13+
}
14+
15+
var f, r1, r2;
16+
17+
class C {
18+
foo(x, y, z) => x + y + z;
19+
}
20+
21+
helper() {
22+
r2 = invoke(f, 1);
23+
return '$r1 $r2';
24+
}
25+
26+
Future<void> main() async {
27+
helper();
28+
await hotReload();
29+
Expect.throws<NoSuchMethodError>(
30+
helper,
31+
(err) => '$err'.contains("Class 'C' has no instance method "
32+
"'foo' with matching arguments."));
33+
}
34+
/** DIFF **/
35+
/*
36+
@@ -15,13 +15,12 @@
37+
var f, r1, r2;
38+
39+
class C {
40+
- foo(x) => x;
41+
+ foo(x, y, z) => x + y + z;
42+
}
43+
44+
helper() {
45+
- var c = C();
46+
- f = c.foo;
47+
- r1 = invoke(f, 1);
48+
+ r2 = invoke(f, 1);
49+
+ return '$r1 $r2';
50+
}
51+
52+
Future<void> main() async {
53+
*/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1924
10+
11+
invoke(f, a) {
12+
return f(a);
13+
}
14+
15+
var f, r1, r2;
16+
17+
class C {
18+
static foo(x) => x;
19+
}
20+
21+
helper() {
22+
f = C.foo;
23+
r1 = invoke(f, 1);
24+
}
25+
26+
Future<void> main() async {
27+
helper();
28+
await hotReload();
29+
Expect.throws<NoSuchMethodError>(
30+
helper,
31+
(err) => '$err'.contains("Closure call with mismatched arguments: "
32+
"function 'C.foo'"));
33+
}
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1924
10+
11+
invoke(f, a) {
12+
return f(a);
13+
}
14+
15+
var f, r1, r2;
16+
17+
class C {
18+
static foo(x, y, z) => x + y + z;
19+
}
20+
21+
helper() {
22+
r2 = invoke(f, 1);
23+
return '$r1 $r2';
24+
}
25+
26+
Future<void> main() async {
27+
helper();
28+
await hotReload();
29+
Expect.throws<NoSuchMethodError>(
30+
helper,
31+
(err) => '$err'.contains("Closure call with mismatched arguments: "
32+
"function 'C.foo'"));
33+
}
34+
/** DIFF **/
35+
/*
36+
@@ -15,12 +15,12 @@
37+
var f, r1, r2;
38+
39+
class C {
40+
- static foo(x) => x;
41+
+ static foo(x, y, z) => x + y + z;
42+
}
43+
44+
helper() {
45+
- f = C.foo;
46+
- r1 = invoke(f, 1);
47+
+ r2 = invoke(f, 1);
48+
+ return '$r1 $r2';
49+
}
50+
51+
Future<void> main() async {
52+
*/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1732
10+
11+
class C {
12+
static foo() => 'old';
13+
}
14+
15+
var f1, f2;
16+
getFoo() => C.foo;
17+
18+
Future<void> main() async {
19+
var f1 = getFoo();
20+
await hotReload();
21+
22+
var f2 = getFoo();
23+
Expect.equals('new', f1());
24+
Expect.equals('new', f2());
25+
Expect.equals(f1, f2);
26+
Expect.identical(f1, f2);
27+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1732
10+
11+
class C {
12+
static foo() => 'new';
13+
}
14+
15+
var f1, f2;
16+
getFoo() => C.foo;
17+
18+
Future<void> main() async {
19+
var f1 = getFoo();
20+
await hotReload();
21+
22+
var f2 = getFoo();
23+
Expect.equals('new', f1());
24+
Expect.equals('new', f2());
25+
Expect.equals(f1, f2);
26+
Expect.identical(f1, f2);
27+
}
28+
/** DIFF **/
29+
/*
30+
@@ -9,7 +9,7 @@
31+
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1732
32+
33+
class C {
34+
- static foo() => 'old';
35+
+ static foo() => 'new';
36+
}
37+
38+
var f1, f2;
39+
*/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1618
10+
11+
class C {
12+
foo() => 'old';
13+
}
14+
15+
var c, f1, f2;
16+
helper() {
17+
c = new C();
18+
f1 = c.foo;
19+
}
20+
21+
Future<void> main() async {
22+
helper();
23+
await hotReload();
24+
helper();
25+
Expect.equals('new', f1());
26+
Expect.equals('new', f2());
27+
Expect.equals(f1, f2);
28+
Expect.notIdentical(f1, f2);
29+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1618
10+
11+
class C {
12+
foo() => 'new';
13+
}
14+
15+
var c, f1, f2;
16+
helper() {
17+
f2 = c.foo;
18+
}
19+
20+
Future<void> main() async {
21+
helper();
22+
await hotReload();
23+
helper();
24+
Expect.equals('new', f1());
25+
Expect.equals('new', f2());
26+
Expect.equals(f1, f2);
27+
Expect.notIdentical(f1, f2);
28+
}
29+
/** DIFF **/
30+
/*
31+
@@ -9,13 +9,12 @@
32+
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1618
33+
34+
class C {
35+
- foo() => 'old';
36+
+ foo() => 'new';
37+
}
38+
39+
var c, f1, f2;
40+
helper() {
41+
- c = new C();
42+
- f1 = c.foo;
43+
+ f2 = c.foo;
44+
}
45+
46+
Future<void> main() async {
47+
*/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1770
10+
11+
var f1, f2;
12+
foo() => 'old';
13+
getFoo() => foo;
14+
15+
Future<void> main() async {
16+
var f1 = getFoo();
17+
await hotReload();
18+
19+
var f2 = getFoo();
20+
Expect.equals('new', f1());
21+
Expect.equals('new', f2());
22+
Expect.equals(f1, f2);
23+
Expect.identical(f1, f2);
24+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1770
10+
11+
var f1, f2;
12+
foo() => 'new';
13+
getFoo() => foo;
14+
15+
Future<void> main() async {
16+
var f1 = getFoo();
17+
await hotReload();
18+
19+
var f2 = getFoo();
20+
Expect.equals('new', f1());
21+
Expect.equals('new', f2());
22+
Expect.equals(f1, f2);
23+
Expect.identical(f1, f2);
24+
}
25+
/** DIFF **/
26+
/*
27+
@@ -9,7 +9,7 @@
28+
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1770
29+
30+
var f1, f2;
31+
-foo() => 'old';
32+
+foo() => 'new';
33+
getFoo() => foo;
34+
35+
Future<void> main() async {
36+
*/

0 commit comments

Comments
 (0)