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); }); }); }