mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
fix(coroutine): 修复协程扩展方法中的空引用和测试代码
- 为 RepeatEvery 方法的 action 参数添加可空引用支持 - 更新测试代码中集合断言的语法格式 - 移除测试方法中未使用的变量声明以简化代码 - 修复测试代码中 lambda 表达式的写法以避免不必要的变量赋值
This commit is contained in:
parent
c7f6b3a9b2
commit
c50797dbe2
@ -117,7 +117,7 @@ public class CoroutineComposeExtensionsTests
|
||||
combined.Current.Update(0.016);
|
||||
}
|
||||
|
||||
Assert.That(executionOrder, Is.EqualTo(new[] { 1, 2, 3 }));
|
||||
Assert.That(executionOrder, Is.EqualTo([1, 2, 3]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -109,8 +109,7 @@ public class CoroutineExtensionsTests
|
||||
[Test]
|
||||
public void ExecuteAfter_Should_Return_Valid_Coroutine()
|
||||
{
|
||||
var called = false;
|
||||
var coroutine = CoroutineExtensions.ExecuteAfter(1.0, () => called = true);
|
||||
var coroutine = CoroutineExtensions.ExecuteAfter(1.0, () => _ = true);
|
||||
|
||||
Assert.That(coroutine, Is.InstanceOf<IEnumerator<IYieldInstruction>>());
|
||||
}
|
||||
|
||||
@ -162,8 +162,7 @@ public class CoroutineHelperTests
|
||||
[Test]
|
||||
public void DelayedCall_Should_Return_IEnumerator()
|
||||
{
|
||||
var called = false;
|
||||
var coroutine = CoroutineHelper.DelayedCall(1.0, () => called = true);
|
||||
var coroutine = CoroutineHelper.DelayedCall(1.0, () => _ = true);
|
||||
|
||||
Assert.That(coroutine, Is.InstanceOf<IEnumerator<IYieldInstruction>>());
|
||||
}
|
||||
@ -300,8 +299,7 @@ public class CoroutineHelperTests
|
||||
[Test]
|
||||
public void DelayedCall_Should_Handle_Negative_Delay()
|
||||
{
|
||||
var called = false;
|
||||
var coroutine = CoroutineHelper.DelayedCall(-1.0, () => called = true);
|
||||
var coroutine = CoroutineHelper.DelayedCall(-1.0, () => _ = true);
|
||||
|
||||
Assert.That(coroutine, Is.Not.Null);
|
||||
Assert.DoesNotThrow(() => coroutine.MoveNext());
|
||||
|
||||
@ -17,7 +17,7 @@ public static class CoroutineExtensions
|
||||
/// <returns>协程枚举器</returns>
|
||||
public static IEnumerator<IYieldInstruction> RepeatEvery(
|
||||
double interval,
|
||||
Action action,
|
||||
Action? action,
|
||||
int? count = null)
|
||||
{
|
||||
if (count is < 0) yield break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user