mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:31:58 +00:00
fbee607329
Address all warnings and errors in positive tests. Move all static checks tests to tests/ffi/static_checks/ so it's easier to ignore them in the analyzer. Change-Id: I16ac2c00432a4e1b6750bffd9b03ac8a2e988fe6 Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351123 Reviewed-by: Liam Appelbe <liama@google.com>
35 lines
872 B
Dart
35 lines
872 B
Dart
// Copyright (c) 2023, 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.
|
|
//
|
|
// SharedObjects=ffi_test_functions
|
|
|
|
import 'dart:ffi';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
import 'dylib_utils.dart';
|
|
|
|
void main() {
|
|
testClose();
|
|
testUnclosable();
|
|
}
|
|
|
|
void testClose() {
|
|
final lib = dlopenPlatformSpecific("ffi_test_functions");
|
|
lib.lookup('ReturnMaxUint8');
|
|
|
|
lib.close();
|
|
Expect.throwsStateError(
|
|
() => lib.lookup('ReturnMaxUint8'), 'Illegal lookup in closed library');
|
|
lib.close(); // Duplicate close should not crash.
|
|
}
|
|
|
|
void testUnclosable() {
|
|
final proc = DynamicLibrary.process();
|
|
final exec = DynamicLibrary.executable();
|
|
|
|
Expect.throwsStateError(proc.close);
|
|
Expect.throwsStateError(exec.close);
|
|
}
|