-
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.
[test] Adding a level of indirection for more clarity in constant ide…
…ntity tests. Change-Id: I9aa6c6bf278e8c8357d416d1a25be1eda4a4bf21 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398761 Commit-Queue: Mark Zhou <[email protected]> Reviewed-by: Nate Biggs <[email protected]>
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/26f2ff4f11f56841fc5a250231ef7d49f01eb234/runtime/vm/isolate_reload_test.cc#L2604 | ||
// Extended with logic to check for non-identity. | ||
|
||
class Fruit { | ||
final String name; | ||
const Fruit(this.name); | ||
String toString() => name; | ||
} | ||
|
||
var x; | ||
|
||
helper() { | ||
return const Fruit('Pear'); | ||
} | ||
|
||
Future<void> main() async { | ||
x = const Fruit('Pear'); | ||
Expect.equals('Pear', x.toString()); | ||
Expect.identical(x, helper()); | ||
|
||
await hotReload(); | ||
Expect.equals('Pear', x.toString()); | ||
Expect.identical(x, const Fruit('Pear')); | ||
Expect.notIdentical(x, 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,45 @@ | ||
// 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/26f2ff4f11f56841fc5a250231ef7d49f01eb234/runtime/vm/isolate_reload_test.cc#L2604 | ||
// Extended with logic to check for non-identity. | ||
|
||
class Fruit { | ||
final String name; | ||
final String field = 'field'; | ||
const Fruit(this.name); | ||
String toString() => name; | ||
} | ||
|
||
var x; | ||
|
||
helper() { | ||
return const Fruit('Pear'); | ||
} | ||
|
||
Future<void> main() async { | ||
x = const Fruit('Pear'); | ||
Expect.equals('Pear', x.toString()); | ||
Expect.identical(x, helper()); | ||
|
||
await hotReload(); | ||
Expect.equals('Pear', x.toString()); | ||
Expect.identical(x, const Fruit('Pear')); | ||
Expect.notIdentical(x, helper()); | ||
} | ||
/** DIFF **/ | ||
/* | ||
@@ -11,6 +11,7 @@ | ||
class Fruit { | ||
final String name; | ||
+ final String field = 'field'; | ||
const Fruit(this.name); | ||
String toString() => name; | ||
} | ||
*/ |