-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1260. WeakReference.target test added
- Loading branch information
sgrekhov
committed
Feb 11, 2022
1 parent
4c0118f
commit 310e789
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
LanguageFeatures/FinalizationRegistry/no_ffi/WeakReference/weak_reference_target_t01.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,27 @@ | ||
// Copyright (c) 2022, 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. | ||
|
||
/// @assertion target property | ||
/// T? target | ||
/// The current object weakly referenced by this, if any. | ||
/// | ||
/// The value is either the object supplied in the constructor, or null if the | ||
/// weak reference has been cleared. | ||
/// | ||
/// @description Check that the value of this property value is the object | ||
/// supplied in the constructor if there are any live references to this object | ||
/// @author [email protected] | ||
import "../../../../Utils/expect.dart"; | ||
|
||
class C { | ||
int id; | ||
C(this.id); | ||
} | ||
|
||
main() { | ||
C? c = C(42); | ||
WeakReference<C> wr = WeakReference(c); | ||
Expect.equals(c, wr.target); | ||
} |