Skip to content

Commit

Permalink
#1260. WeakReference.target test added
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Feb 11, 2022
1 parent 4c0118f commit 310e789
Showing 1 changed file with 27 additions and 0 deletions.
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);
}

0 comments on commit 310e789

Please sign in to comment.