#1260. WeakReference tests added
diff --git a/LanguageFeatures/FinalizationRegistry/weak_reference_target_t01.dart b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t01.dart
new file mode 100644
index 0000000..3e0bbcc
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t01.dart
@@ -0,0 +1,36 @@
+// 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 either the
+/// object supplied in the constructor, or null if the weak reference has been
+/// cleared
+/// @author sgrekhov@unipro.ru
+
+import "gc_utils_lib.dart";
+import "../../Utils/expect.dart";
+
+class C {
+  int id;
+  C(this.id);
+}
+
+main() async {
+  C? c = C(42);
+  WeakReference<C> wr = WeakReference(c);
+  Expect.equals(c, wr.target);
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.equals(c, wr.target);
+  c = null;
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNull(wr.target);
+}
diff --git a/LanguageFeatures/FinalizationRegistry/weak_reference_target_t02.dart b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t02.dart
new file mode 100644
index 0000000..c487816
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t02.dart
@@ -0,0 +1,37 @@
+// 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 either the
+/// object supplied in the constructor, or null if the weak reference has been
+/// cleared
+/// @author sgrekhov@unipro.ru
+
+import "gc_utils_lib.dart";
+import "../../Utils/expect.dart";
+
+class C {
+  int id;
+  C(this.id);
+}
+
+main() async {
+  List<C> refs = List.filled(5, C(42), growable: true);
+
+  WeakReference<C> wr = WeakReference(refs[0]);
+  Expect.equals(refs[0], wr.target);
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.equals(refs[1], wr.target);
+  refs.clear();
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNull(wr.target);
+}
diff --git a/LanguageFeatures/FinalizationRegistry/weak_reference_target_t03.dart b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t03.dart
new file mode 100644
index 0000000..3f5ba47
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t03.dart
@@ -0,0 +1,37 @@
+// 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 either the
+/// object supplied in the constructor, or null if the weak reference has been
+/// cleared
+/// @author sgrekhov@unipro.ru
+
+import "gc_utils_lib.dart";
+import "../../Utils/expect.dart";
+
+class C {
+  int id;
+  C(this.id);
+}
+
+C? c = C(42);
+
+main() async {
+  WeakReference<C> wr = WeakReference(c!);
+  Expect.equals(c, wr.target);
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.equals(c, wr.target);
+  c = null;
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNull(wr.target);
+}
diff --git a/LanguageFeatures/FinalizationRegistry/weak_reference_target_t04.dart b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t04.dart
new file mode 100644
index 0000000..ae3c716
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t04.dart
@@ -0,0 +1,39 @@
+// 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 either the
+/// object supplied in the constructor, or null if the weak reference has been
+/// cleared
+/// @author sgrekhov@unipro.ru
+
+import "gc_utils_lib.dart";
+import "../../Utils/expect.dart";
+
+class C {
+  int id;
+  C(this.id);
+}
+
+main() async {
+  C? c = C(42);
+  dynamic d = c;
+  WeakReference<C> wr = WeakReference(c);
+  Expect.equals(c, wr.target);
+  c = null;
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNotNull(wr.target);
+  Expect.equals(d, wr.target);
+  d = 42;
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNull(wr.target);
+}
diff --git a/LanguageFeatures/FinalizationRegistry/weak_reference_target_t05.dart b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t05.dart
new file mode 100644
index 0000000..1ad3027
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t05.dart
@@ -0,0 +1,48 @@
+// 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 either the
+/// object supplied in the constructor, or null if the weak reference has been
+/// cleared
+/// @author sgrekhov@unipro.ru
+
+import "dart:async";
+import "gc_utils_lib.dart";
+import "../../Utils/expect.dart";
+
+class C {
+  int id;
+  C(this.id);
+}
+
+main() async {
+  C? c1 = C(42);
+  WeakReference<C> wr = WeakReference(c1);
+  asyncStart();
+  Future<C?>.delayed(Duration(milliseconds: 1), () => c1).then((C? c2) async {
+    Expect.isNotNull(wr.target);
+    Expect.equals(c1, wr.target);
+    triggerGc();
+    await Future.delayed(Duration(milliseconds: 5));
+    Expect.isNotNull(wr.target);
+    c2 = null;
+    triggerGc();
+    Expect.isNull(wr.target);
+    asyncEnd();
+  });
+  Expect.isNotNull(wr.target);
+  Expect.equals(c1, wr.target);
+  await Future.delayed(Duration(milliseconds: 2));
+  c1 = null;
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNotNull(wr.target);
+}
diff --git a/LanguageFeatures/FinalizationRegistry/weak_reference_target_t06.dart b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t06.dart
new file mode 100644
index 0000000..9fabe93
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t06.dart
@@ -0,0 +1,48 @@
+// 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 either the
+/// object supplied in the constructor, or null if the weak reference has been
+/// cleared
+/// @author sgrekhov@unipro.ru
+
+import "dart:async";
+import "gc_utils_lib.dart";
+import "../../Utils/expect.dart";
+
+class C {
+  int id;
+  C(this.id);
+}
+
+main() async {
+  C? c1 = C(42);
+  WeakReference<C> wr = WeakReference(c1);
+  asyncStart();
+  Future<C?>.delayed(Duration(milliseconds: 1), () => c1).then((C? c2) async {
+    Expect.isNotNull(wr.target);
+    Expect.equals(c1, wr.target);
+    triggerGc();
+    await Future.delayed(Duration(milliseconds: 1));
+    Expect.isNotNull(wr.target);
+    c2 = null;
+    triggerGc();
+    await Future.delayed(Duration(milliseconds: 1));
+    Expect.isNotNull(wr.target);
+    asyncEnd();
+  });
+  Expect.isNotNull(wr.target);
+  Expect.equals(c1, wr.target);
+  await Future.delayed(Duration(milliseconds: 10));
+  c1 = null;
+  triggerGc();
+  Expect.isNull(wr.target);
+}
diff --git a/LanguageFeatures/FinalizationRegistry/weak_reference_target_t07.dart b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t07.dart
new file mode 100644
index 0000000..5d8eac9
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t07.dart
@@ -0,0 +1,42 @@
+// 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 either the
+/// object supplied in the constructor, or null if the weak reference has been
+/// cleared
+/// @author sgrekhov@unipro.ru
+
+import "gc_utils_lib.dart";
+import "../../Utils/expect.dart";
+
+class C {
+  int id;
+  C(this.id);
+}
+
+main() async {
+  C? c1 = C(42);
+  C? c2 = c1;
+  WeakReference<C> wr = WeakReference(c1);
+  Expect.equals(c1, wr.target);
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.equals(c1, wr.target);
+  c1 = null;
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNotNull(wr.target);
+  Expect.equals(c2, wr.target);
+  c2 = null;
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNull(wr.target);
+}
diff --git a/LanguageFeatures/FinalizationRegistry/weak_reference_target_t08.dart b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t08.dart
new file mode 100644
index 0000000..e946b02
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/weak_reference_target_t08.dart
@@ -0,0 +1,40 @@
+// 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 either the
+/// object supplied in the constructor, or null if the weak reference has been
+/// cleared
+/// @author sgrekhov@unipro.ru
+
+import "gc_utils_lib.dart";
+import "../../Utils/expect.dart";
+
+class C {
+  int id;
+  C(this.id);
+}
+
+main() async {
+  C? c = C(42);
+  WeakReference<C> wr1 = WeakReference(c);
+  WeakReference<C> wr2 = WeakReference(c);
+  Expect.equals(c, wr1.target);
+  Expect.equals(c, wr2.target);
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.equals(c, wr1.target);
+  Expect.equals(c, wr2.target);
+  c = null;
+  triggerGc();
+  await Future.delayed(Duration(milliseconds: 1));
+  Expect.isNull(wr1.target);
+  Expect.isNull(wr2.target);
+}