blob: 99e49fe81a885c98440c93d3efa5b228c7d63b2f [file] [log] [blame]
// 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] key.
/// 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>();
U u = p.ref;
try {
Expect.throws(() {
finalizer.attach(u, "Finalization token");
});
} finally {
calloc.free(p);
}
}