simulateFinalizerForTest method

  1. @visibleForTesting
void simulateFinalizerForTest(
  1. String name,
  2. Object resource
)

Test seam matching the production Finalizer callback path. Locates the registration whose target is identical to resource under name, then dispatches _recordRelease(token) against its token. Deterministically simulates GC reclamation without depending on VM finalization timing.

Implementation

@visibleForTesting
void simulateFinalizerForTest(String name, Object resource) {
  final bucket = _buckets[name];
  if (bucket == null) return;
  for (final r in bucket.refs) {
    if (identical(r.ref.target, resource)) {
      _recordRelease(r.token);
      return;
    }
  }
}