#1260: Added tests for Finalizer.
diff --git a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A03_t02.dart b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A03_t02.dart
deleted file mode 100644
index d3ba8f9..0000000
--- a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A03_t02.dart
+++ /dev/null
@@ -1,29 +0,0 @@
-// 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 If a non-null detach value is provided, that object can be passed
-/// to Finalizer.detach to remove the attachment again.
-///
-/// @description Checks that nothing happens if detach token is [null].
-/// @author iarkh@unipro.ru
-
-import "../gc_utils_lib.dart";
-import "../../../Utils/expect.dart";
-
-class A {}
-
-int cnt = 0;
-final Finalizer<Object> finalizer = Finalizer((token) {
- cnt++;
-});
-
-main() {
- A detachToken = A();
- {
- Object value = Object();
- finalizer.attach(value, "Finalization token", detach: null);
- }
- triggerGcWithDelay();
- Expect.equals(1, cnt);
-}
diff --git a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t01.dart b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t01.dart
new file mode 100644
index 0000000..cd0b3d9
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t01.dart
@@ -0,0 +1,32 @@
+// 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 The value and detach arguments ... Both must be objects supported
+/// as an [Expando] key.
+///
+/// @description Checks that [value] must be supported as an [Expando] keys.
+/// Test String.
+/// @author iarkh@unipro.ru
+
+import "../gc_utils_lib.dart";
+import "../../../Utils/expect.dart";
+
+final Finalizer finalizer = Finalizer((_) { throw "Should not reach here"; });
+Object detachToken = Object;
+
+main() {
+ Expect.throws(() {
+ finalizer.attach("Shouldn't work", "Finalization token", detach: detachToken);
+ });
+
+ String s = "Just a string";
+ Expect.throws(() {
+ finalizer.attach("Shouldn't work", "Finalization token");
+ });
+
+ dynamic d = s;
+ Expect.throws(() {
+ finalizer.attach("Shouldn't work", "Finalization token");
+ });
+}
diff --git a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t02.dart b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t02.dart
new file mode 100644
index 0000000..2a95758
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_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 The value and detach arguments ... Both must be objects supported
+/// as an [Expando] key.
+///
+/// @description Checks that [value] must be supported as an [Expando] keys.
+/// Test numbers.
+/// @author iarkh@unipro.ru
+
+import "../gc_utils_lib.dart";
+import "../../../Utils/expect.dart";
+
+final Finalizer finalizer = Finalizer((_) { throw "Should not reach here"; });
+Object detachToken = Object;
+
+main() {
+ Expect.throws(() {
+ finalizer.attach(12345, "Finalization token", detach: detachToken);
+ });
+
+ var i = 3.14;
+ Expect.throws(() {
+ finalizer.attach(i, "Finalization token");
+ });
+
+ int j = -12934;
+ Expect.throws(() {
+ finalizer.attach(j, "Finalization token");
+ });
+
+ dynamic d = -12.376;
+ Expect.throws(() {
+ finalizer.attach(d, "Finalization token");
+ });
+}
diff --git a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t03.dart b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t03.dart
new file mode 100644
index 0000000..92f4c08
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_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 The value and detach arguments ... Both must be objects supported
+/// as an [Expando] key.
+///
+/// @description Checks that [value] must be supported as an [Expando] keys.
+/// Test booleans.
+/// @author iarkh@unipro.ru
+
+import "../gc_utils_lib.dart";
+import "../../../Utils/expect.dart";
+
+final Finalizer finalizer = Finalizer((_) { throw "Should not reach here"; });
+Object detachToken = Object;
+
+main() {
+ Expect.throws(() {
+ finalizer.attach(true, "Finalization token", detach: detachToken);
+ });
+
+ var b1 = false;
+ Expect.throws(() {
+ finalizer.attach(b1, "Finalization token");
+ });
+
+ bool? b2 = true;
+ Expect.throws(() {
+ finalizer.attach(b2, "Finalization token");
+ });
+
+ dynamic b3 = true;
+ Expect.throws(() {
+ finalizer.attach(b3, "Finalization token");
+ });
+}
diff --git a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t04.dart b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t04.dart
new file mode 100644
index 0000000..c70e551
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t04.dart
@@ -0,0 +1,22 @@
+// 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 The value and detach arguments ... Both must be objects supported
+/// as an [Expando] key.
+///
+/// @description Checks that [value] must be supported as an [Expando] keys.
+/// Test [Null].
+/// @author iarkh@unipro.ru
+
+import "../gc_utils_lib.dart";
+import "../../../Utils/expect.dart";
+
+final Finalizer finalizer = Finalizer((_) { throw "Should not reach here"; });
+
+main() {
+ dynamic d = null;
+ Expect.throws(() {
+ finalizer.attach(d, "Finalization token");
+ });
+}
diff --git a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t05.dart b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t05.dart
new file mode 100644
index 0000000..9097e8c
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t05.dart
@@ -0,0 +1,38 @@
+// 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 The value and detach arguments ... Both must be objects supported
+/// as an [Expando] key.
+///
+/// @description Checks that [value] must be supported as an [Expando] keys.
+/// Test Test dart:ffi pointers.
+/// @author iarkh@unipro.ru
+
+import "dart:ffi";
+import "package:ffi/ffi.dart";
+import "../../../Utils/expect.dart";
+
+final Finalizer finalizer = Finalizer((_) { throw "Should not reach here"; });
+Object detachToken = Object;
+
+main() {
+ Pointer<Int8> p1 = calloc<Int8>();
+ try {
+ Expect.throws(() {
+ finalizer.attach(p1, "Finalization token");
+ });
+ } finally {
+ calloc.free(p1);
+ }
+
+ Pointer<Int16> p2 = calloc<Int16>();
+ try {
+ Expect.throws(() {
+ finalizer.attach(p2, "Finalization token");
+ });
+ } finally {
+ calloc.free(p2);
+ }
+
+}
diff --git a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t06.dart b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t06.dart
new file mode 100644
index 0000000..f9d9663
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t06.dart
@@ -0,0 +1,33 @@
+// 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 The value and detach arguments ... Both must be objects supported
+/// as an [Expando] key.
+///
+/// @description Checks that [value] must be supported as an [Expando] keys.
+/// Test Test dart:ffi struct.
+/// @author iarkh@unipro.ru
+
+import "dart:ffi";
+import "package:ffi/ffi.dart";
+import "../../../Utils/expect.dart";
+
+final Finalizer finalizer = Finalizer((_) { throw "Should not reach here"; });
+
+class S extends Struct {
+ @Int32()
+ external int x;
+}
+
+main() {
+ Pointer<S> p = calloc<S>();
+ try {
+ S s = p.ref;
+ Expect.throws(() {
+ finalizer.attach(p, "Finalization token");
+ });
+ } finally {
+ calloc.free(p);
+ }
+}
diff --git a/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t067.dart b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t067.dart
new file mode 100644
index 0000000..5922a2d
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/Finalizer/attach_A04_t067.dart
@@ -0,0 +1,35 @@
+// 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 The value and detach arguments ... Both must be objects supported
+/// as an [Expando] key.
+///
+/// @description Checks that [value] must be supported as an [Expando] keys.
+/// Test Test dart:ffi union.
+/// @author iarkh@unipro.ru
+
+import "dart:ffi";
+import "package:ffi/ffi.dart";
+import "../../../Utils/expect.dart";
+
+final Finalizer finalizer = Finalizer((_) { throw "Should not reach here"; });
+
+class U extends Union {
+ @Int32()
+ external int x;
+ @Int16()
+ external int y;
+}
+
+main() {
+ Pointer<U> p = calloc<U>();
+ try {
+ U u = p.ref;
+ Expect.throws(() {
+ finalizer.attach(u, "Finalization token");
+ });
+ } finally {
+ calloc.free(p);
+ }
+}