11// JActionTests.cs
22// EditMode unit tests for JAction (synchronous execution)
33
4+ using System . Collections . Generic ;
5+ using System . Reflection ;
46using NUnit . Framework ;
57
68namespace JEngine . Util . Tests
@@ -92,7 +94,7 @@ public void Do_WithState_PassesStateToAction()
9294 int result = 0 ;
9395
9496 JAction . Create ( )
95- . Do ( ( int x ) => result = x , 42 )
97+ . Do ( x => result = x , 42 )
9698 . Execute ( ) ;
9799
98100 Assert . AreEqual ( 42 , result ) ;
@@ -105,7 +107,7 @@ public void Do_WithReferenceState_PassesStateToAction()
105107 int result = 0 ;
106108
107109 JAction . Create ( )
108- . Do ( ( TestData d ) => result = d . Value , data )
110+ . Do ( d => result = d . Value , data )
109111 . Execute ( ) ;
110112
111113 Assert . AreEqual ( 10 , result ) ;
@@ -129,7 +131,7 @@ public void Repeat_WithState_PassesStateEachTime()
129131 int sum = 0 ;
130132
131133 JAction . Create ( )
132- . Repeat ( ( int x ) => sum += x , state : 10 , count : 3 )
134+ . Repeat ( x => sum += x , state : 10 , count : 3 )
133135 . Execute ( ) ;
134136
135137 Assert . AreEqual ( 30 , sum ) ;
@@ -156,8 +158,8 @@ public void Cancel_InvokesOnCancelCallback()
156158
157159 // Force executing state and cancel
158160 typeof ( JAction ) . GetField ( "IsExecuting" ,
159- System . Reflection . BindingFlags . NonPublic |
160- System . Reflection . BindingFlags . Instance )
161+ BindingFlags . NonPublic |
162+ BindingFlags . Instance )
161163 ? . SetValue ( action2 , true ) ;
162164
163165 action2 . Cancel ( ) ;
@@ -173,12 +175,12 @@ public void Cancel_WithState_PassesStateToCallback()
173175 int result = 0 ;
174176
175177 var action = JAction . Create ( )
176- . OnCancel ( ( int x ) => result = x , 42 ) ;
178+ . OnCancel ( x => result = x , 42 ) ;
177179
178180 // Force executing state
179181 typeof ( JAction ) . GetField ( "IsExecuting" ,
180- System . Reflection . BindingFlags . NonPublic |
181- System . Reflection . BindingFlags . Instance )
182+ BindingFlags . NonPublic |
183+ BindingFlags . Instance )
182184 ? . SetValue ( action , true ) ;
183185
184186 action . Cancel ( ) ;
@@ -293,7 +295,7 @@ public void Do_WithIntState_WorksCorrectly()
293295 int result = 0 ;
294296
295297 JAction . Create ( )
296- . Do ( ( int x ) => result = x , 123 )
298+ . Do ( x => result = x , 123 )
297299 . Execute ( ) ;
298300
299301 Assert . AreEqual ( 123 , result ) ;
@@ -305,7 +307,7 @@ public void Do_WithFloatState_WorksCorrectly()
305307 float result = 0 ;
306308
307309 JAction . Create ( )
308- . Do ( ( float x ) => result = x , 3.14f )
310+ . Do ( x => result = x , 3.14f )
309311 . Execute ( ) ;
310312
311313 Assert . AreEqual ( 3.14f , result , 0.001f ) ;
@@ -317,7 +319,7 @@ public void Do_WithBoolState_WorksCorrectly()
317319 bool result = false ;
318320
319321 JAction . Create ( )
320- . Do ( ( bool x ) => result = x , true )
322+ . Do ( x => result = x , true )
321323 . Execute ( ) ;
322324
323325 Assert . IsTrue ( result ) ;
@@ -349,8 +351,8 @@ public void Dispose_DuringExecution_CancelsFirst()
349351
350352 // Start execution
351353 typeof ( JAction ) . GetField ( "IsExecuting" ,
352- System . Reflection . BindingFlags . NonPublic |
353- System . Reflection . BindingFlags . Instance )
354+ BindingFlags . NonPublic |
355+ BindingFlags . Instance )
354356 ? . SetValue ( action , true ) ;
355357
356358 action . Dispose ( ) ;
@@ -378,7 +380,7 @@ public void Execute_WithNullAction_SkipsGracefully()
378380 [ Test ]
379381 public void ComplexChain_ExecutesInOrder ( )
380382 {
381- var order = new System . Collections . Generic . List < int > ( ) ;
383+ var order = new List < int > ( ) ;
382384
383385 JAction . Create ( )
384386 . Do ( ( ) => order . Add ( 1 ) )
@@ -402,10 +404,10 @@ public void ComplexChain_WithState_PassesCorrectState()
402404 int sum = 0 ;
403405
404406 JAction . Create ( )
405- . Do ( ( int x ) => sum += x , 1 )
406- . Do ( ( int x ) => sum += x , 10 )
407- . Repeat ( ( int x ) => sum += x , state : 100 , count : 2 )
408- . Do ( ( int x ) => sum += x , 1000 )
407+ . Do ( x => sum += x , 1 )
408+ . Do ( x => sum += x , 10 )
409+ . Repeat ( x => sum += x , state : 100 , count : 2 )
410+ . Do ( x => sum += x , 1000 )
409411 . Execute ( ) ;
410412
411413 Assert . AreEqual ( 1211 , sum ) ; // 1 + 10 + 100 + 100 + 1000
@@ -414,15 +416,15 @@ public void ComplexChain_WithState_PassesCorrectState()
414416 [ Test ]
415417 public void ComplexChain_MixedStaticAndState_WorksCorrectly ( )
416418 {
417- var results = new System . Collections . Generic . List < string > ( ) ;
419+ var results = new List < string > ( ) ;
418420
419421 // Mix static lambdas (no closure) with state overloads
420422 using var action = JAction . Create ( )
421423 . Do ( static ( ) => { } ) // static lambda, no state needed
422- . Do ( static ( System . Collections . Generic . List < string > r ) => r . Add ( "step1" ) , results )
424+ . Do ( static r => r . Add ( "step1" ) , results )
423425 . Delay ( 0.01f )
424- . Do ( static ( System . Collections . Generic . List < string > r ) => r . Add ( "step2" ) , results )
425- . Repeat ( static ( System . Collections . Generic . List < string > r ) => r . Add ( "repeat" ) , results , count : 2 )
426+ . Do ( static r => r . Add ( "step2" ) , results )
427+ . Repeat ( static r => r . Add ( "repeat" ) , results , count : 2 )
426428 . Execute ( ) ;
427429
428430 Assert . AreEqual ( 4 , results . Count ) ;
@@ -437,7 +439,7 @@ public void Using_AutoDisposesAction()
437439 {
438440 int initialPoolCount = JAction . PooledCount ;
439441
440- using ( var action = JAction . Create ( ) . Do ( ( ) => { } ) . Execute ( ) )
442+ using ( JAction . Create ( ) . Do ( ( ) => { } ) . Execute ( ) )
441443 {
442444 Assert . AreEqual ( initialPoolCount , JAction . PooledCount ) ;
443445 }
@@ -457,7 +459,7 @@ public void WaitUntil_WithState_PassesStateToCondition()
457459 bool completed = false ;
458460
459461 JAction . Create ( )
460- . WaitUntil ( ( TestData d ) =>
462+ . WaitUntil ( d =>
461463 {
462464 d . Value ++ ;
463465 return d . Value >= 3 ;
@@ -476,7 +478,7 @@ public void WaitWhile_WithState_PassesStateToCondition()
476478 bool completed = false ;
477479
478480 JAction . Create ( )
479- . WaitWhile ( ( TestData d ) =>
481+ . WaitWhile ( d =>
480482 {
481483 d . Value ++ ;
482484 return d . Value < 3 ;
@@ -496,8 +498,8 @@ public void RepeatWhile_WithState_PassesStateToActionAndCondition()
496498
497499 JAction . Create ( )
498500 . RepeatWhile (
499- ( TestData d ) => { actionCount ++ ; d . Value ++ ; } ,
500- ( TestData d ) => d . Value < 5 ,
501+ d => { actionCount ++ ; d . Value ++ ; } ,
502+ d => d . Value < 5 ,
501503 data )
502504 . Execute ( ) ;
503505
@@ -513,8 +515,8 @@ public void RepeatUntil_WithState_PassesStateToActionAndCondition()
513515
514516 JAction . Create ( )
515517 . RepeatUntil (
516- ( TestData d ) => { actionCount ++ ; d . Value ++ ; } ,
517- ( TestData d ) => d . Value >= 5 ,
518+ d => { actionCount ++ ; d . Value ++ ; } ,
519+ d => d . Value >= 5 ,
518520 data )
519521 . Execute ( ) ;
520522
0 commit comments