Files
flutter_lua_runtime/test/runtime/lifecycle/runtime_async_gate_test.dart
2026-06-07 22:53:58 +08:00

37 lines
1.0 KiB
Dart

import 'package:flame_lua_runtime/runtime/lifecycle/runtime_async_gate.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('RuntimeAsyncGate', () {
test('accepts only current open generation tokens', () {
final gate = RuntimeAsyncGate();
final first = gate.activate();
expect(gate.accepts(first), isTrue);
expect(first.isAccepted, isTrue);
final second = gate.advance();
expect(gate.accepts(first), isFalse);
expect(gate.accepts(second), isTrue);
});
test('close rejects existing and future checks until activated again', () {
final gate = RuntimeAsyncGate();
final first = gate.activate();
gate.close();
expect(gate.isClosed, isTrue);
expect(gate.accepts(first), isFalse);
expect(gate.acceptsGeneration(gate.generation), isFalse);
final second = gate.activate();
expect(gate.isOpen, isTrue);
expect(gate.accepts(second), isTrue);
expect(gate.accepts(first), isFalse);
});
});
}