-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ddc] Porting VM hot reload tests to the hot reload framework related…
… to type updates. Change-Id: I3c42781acd253ac82658593c96ab92ef6c2cdb50 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392466 Commit-Queue: Mark Zhou <markzipan@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
- Loading branch information
Showing
59 changed files
with
1,283 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exclude": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5493 | ||
|
||
// Note: The original VM test checks for allocated objects on the heap after a | ||
// hot reload. There isn't an obvious web analogue, so we've left this off | ||
// unless this side effect becomes visible across platforms. | ||
|
||
class C { | ||
int value = 42; | ||
} | ||
|
||
class Foo { | ||
static var x = C(); | ||
} | ||
|
||
late var closure; | ||
|
||
helper() { | ||
closure = () => Foo.x.value; | ||
} | ||
|
||
Future<void> main() async { | ||
helper(); | ||
Expect.equals(42, closure()); | ||
await hotReload(); | ||
|
||
Expect.throws(closure); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5493 | ||
|
||
// Note: The original VM test checks for allocated objects on the heap after a | ||
// hot reload. There isn't an obvious web analogue, so we've left this off | ||
// unless this side effect becomes visible across platforms. | ||
|
||
class C { | ||
int value = 42; | ||
} | ||
|
||
class Foo {} | ||
|
||
late var closure; | ||
|
||
helper() {} | ||
|
||
Future<void> main() async { | ||
helper(); | ||
Expect.equals(42, closure()); | ||
await hotReload(); | ||
|
||
Expect.throws(closure); | ||
} | ||
/** DIFF **/ | ||
/* | ||
@@ -16,15 +16,11 @@ | ||
int value = 42; | ||
} | ||
-class Foo { | ||
- static var x = C(); | ||
-} | ||
+class Foo {} | ||
late var closure; | ||
-helper() { | ||
- closure = () => Foo.x.value; | ||
-} | ||
+helper() {} | ||
Future<void> main() async { | ||
helper(); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exclude": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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 'dart:typed_data'; | ||
import 'package:expect/expect.dart'; | ||
import 'package:reload_test/reload_test_utils.dart'; | ||
|
||
// Adapted from: | ||
// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674 | ||
|
||
class Foo { | ||
int x = 42; | ||
} | ||
|
||
Future<void> main() async { | ||
Expect.type<int>(Foo().x); | ||
Expect.equals(42, Foo().x); | ||
await hotReload(); | ||
|
||
Expect.type<String>(Foo().x); | ||
Expect.equals('42', Foo().x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 'dart:typed_data'; | ||
import 'package:expect/expect.dart'; | ||
import 'package:reload_test/reload_test_utils.dart'; | ||
|
||
// Adapted from: | ||
// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674 | ||
|
||
class Foo { | ||
String x = '42'; | ||
} | ||
|
||
Future<void> main() async { | ||
Expect.type<int>(Foo().x); | ||
Expect.equals(42, Foo().x); | ||
await hotReload(); | ||
|
||
Expect.type<String>(Foo().x); | ||
Expect.equals('42', Foo().x); | ||
} | ||
/** DIFF **/ | ||
/* | ||
@@ -10,7 +10,7 @@ | ||
// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674 | ||
class Foo { | ||
- int x = 42; | ||
+ String x = '42'; | ||
} | ||
Future<void> main() async { | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tests/hot_reload/existing_static_field_changes_type_indirect_function/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exclude": [] | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/hot_reload/existing_static_field_changes_type_indirect_function/main.0.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5929 | ||
|
||
class A {} | ||
|
||
class B extends A {} | ||
|
||
typedef bool Predicate(B b); | ||
|
||
Predicate value = init(); | ||
init() => (A a) => true; | ||
|
||
String helper() { | ||
try { | ||
return value.toString(); | ||
} catch (e) { | ||
return e.toString(); | ||
} | ||
} | ||
|
||
Future<void> main() async { | ||
Expect.contains('Closure: (A) => bool', helper()); | ||
|
||
await hotReload(); | ||
|
||
// B is no longer a subtype of A. | ||
Expect.contains( | ||
"type '(A) => bool' is not a subtype of type '(B) => bool'", helper()); | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/hot_reload/existing_static_field_changes_type_indirect_function/main.1.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5929 | ||
|
||
class A {} | ||
|
||
class B {} | ||
|
||
typedef bool Predicate(B b); | ||
|
||
Predicate value = init(); | ||
init() => (A a) => true; | ||
|
||
String helper() { | ||
try { | ||
return value.toString(); | ||
} catch (e) { | ||
return e.toString(); | ||
} | ||
} | ||
|
||
Future<void> main() async { | ||
Expect.contains('Closure: (A) => bool', helper()); | ||
|
||
await hotReload(); | ||
|
||
// B is no longer a subtype of A. | ||
Expect.contains( | ||
"type '(A) => bool' is not a subtype of type '(B) => bool'", helper()); | ||
} | ||
/** DIFF **/ | ||
/* | ||
@@ -10,7 +10,7 @@ | ||
class A {} | ||
-class B extends A {} | ||
+class B {} | ||
typedef bool Predicate(B b); | ||
*/ |
3 changes: 3 additions & 0 deletions
3
tests/hot_reload/existing_static_field_changes_type_indirect_generic/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exclude": [] | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/hot_reload/existing_static_field_changes_type_indirect_generic/main.0.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5841 | ||
|
||
class A {} | ||
|
||
class B extends A {} | ||
|
||
List<A> value = init(); | ||
init() => List<B>.empty(); | ||
|
||
String helper() { | ||
try { | ||
return value.toString(); | ||
} catch (e) { | ||
return e.toString(); | ||
} | ||
} | ||
|
||
Future<void> main() async { | ||
Expect.equals('[]', helper()); | ||
|
||
await hotReload(); | ||
|
||
// B is no longer a subtype of A. | ||
Expect.contains( | ||
"type 'List<B>' is not a subtype of type 'List<A>'", helper()); | ||
} |
Oops, something went wrong.