fix(coroutine): 修复协程扩展方法中的空引用和测试代码

- 为 RepeatEvery 方法的 action 参数添加可空引用支持
- 更新测试代码中集合断言的语法格式
- 移除测试方法中未使用的变量声明以简化代码
- 修复测试代码中 lambda 表达式的写法以避免不必要的变量赋值
This commit is contained in:
GeWuYou 2026-02-01 12:32:26 +08:00
parent c7f6b3a9b2
commit c50797dbe2
4 changed files with 5 additions and 8 deletions

View File

@ -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>

View File

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

View File

@ -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());

View File

@ -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;