File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Chickensoft.LogicBlocks/src
Chickensoft.LogicBlocks.Tests/test/src Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -373,6 +373,27 @@ public void ImplicitStartCallsOnStart() {
373
373
onStartCalled . ShouldBeTrue ( ) ;
374
374
}
375
375
376
+ [ Fact ]
377
+ public void OnStartDoesNotCauseInfiniteLoopWithInput ( ) {
378
+ var onStartCalled = false ;
379
+ var looped = false ;
380
+ var logic = new FakeLogicBlock ( ) ;
381
+ logic . OnStartCalled += ( ) => {
382
+ if ( onStartCalled ) {
383
+ looped = true ;
384
+ return ;
385
+ }
386
+
387
+ onStartCalled = true ;
388
+ logic . Input ( new FakeLogicBlock . Input . InputOne ( 2 , 3 ) ) ;
389
+ } ;
390
+
391
+ logic . Start ( ) ;
392
+
393
+ onStartCalled . ShouldBeTrue ( ) ;
394
+ looped . ShouldBeFalse ( ) ;
395
+ }
396
+
376
397
[ Fact ]
377
398
public void StopExitsState ( ) {
378
399
var exitCalled = false ;
Original file line number Diff line number Diff line change @@ -400,10 +400,10 @@ internal TState ProcessInputs<TInputType>(
400
400
401
401
if ( _value is null ) {
402
402
// No state yet. Let's get the first state going!
403
- OnStart ( ) ;
404
403
Blackboard . InstantiateAnyMissingSavedData ( ) ;
405
404
ChangeState ( RestoredState as TState ?? GetInitialState ( ) . State ) ;
406
405
RestoredState = null ;
406
+ OnStart ( ) ;
407
407
}
408
408
409
409
// We can always process the first input directly.
You can’t perform that action at this time.
0 commit comments