Initial flame_lua_runtime package
This commit is contained in:
36
test/runtime/lifecycle/runtime_async_gate_test.dart
Normal file
36
test/runtime/lifecycle/runtime_async_gate_test.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user