mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-18 05:00:14 +00:00
complete implementation(triggers and etc...)
This commit is contained in:
@@ -101,12 +101,12 @@ namespace UniRx.AsyncTests
|
||||
{
|
||||
var a = UniTask.FromResult(999);
|
||||
var b = UniTask.Yield(PlayerLoopTiming.Update, CancellationToken.None).AsAsyncUnitUniTask();
|
||||
var c = UniTask.DelayFrame(99);
|
||||
var c = UniTask.DelayFrame(99).AsAsyncUnitUniTask();
|
||||
|
||||
var (a2, b2, c2) = await UniTask.WhenAll(a, b, c);
|
||||
a2.Should().Be(999);
|
||||
b2.Should().Be(AsyncUnit.Default);
|
||||
c2.Should().Be(99);
|
||||
c2.Should().Be(AsyncUnit.Default);
|
||||
});
|
||||
|
||||
[UnityTest]
|
||||
@@ -114,14 +114,11 @@ namespace UniRx.AsyncTests
|
||||
{
|
||||
var a = UniTask.FromResult(999);
|
||||
var b = UniTask.Yield(PlayerLoopTiming.Update, CancellationToken.None).AsAsyncUnitUniTask();
|
||||
var c = UniTask.DelayFrame(99);
|
||||
var c = UniTask.DelayFrame(99).AsAsyncUnitUniTask();
|
||||
|
||||
var (win, a2, b2, c2) = await UniTask.WhenAny(a, b, c);
|
||||
win.Should().Be(0);
|
||||
a2.hasResult.Should().Be(true);
|
||||
a2.result0.Should().Be(999);
|
||||
b2.hasResult.Should().Be(false);
|
||||
c2.hasResult.Should().Be(false);
|
||||
a2.Should().Be(999);
|
||||
});
|
||||
|
||||
[UnityTest]
|
||||
@@ -153,7 +150,7 @@ namespace UniRx.AsyncTests
|
||||
|
||||
await UniTask.Yield(PlayerLoopTiming.PostLateUpdate);
|
||||
|
||||
UniTask.DelayFrame(10,PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => t = true).Forget();
|
||||
UniTask.DelayFrame(10,PlayerLoopTiming.PostLateUpdate).ContinueWith(() => t = true).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitUntil(() => t, PlayerLoopTiming.EarlyUpdate);
|
||||
@@ -167,7 +164,7 @@ namespace UniRx.AsyncTests
|
||||
{
|
||||
bool t = true;
|
||||
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => t = false).Forget();
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(() => t = false).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitWhile(() => t, PlayerLoopTiming.EarlyUpdate);
|
||||
@@ -181,7 +178,7 @@ namespace UniRx.AsyncTests
|
||||
{
|
||||
var v = new MyMyClass { MyProperty = 99 };
|
||||
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => v.MyProperty = 1000).Forget();
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(() => v.MyProperty = 1000).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitUntilValueChanged(v, x => x.MyProperty, PlayerLoopTiming.EarlyUpdate);
|
||||
@@ -271,10 +268,10 @@ namespace UniRx.AsyncTests
|
||||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
UniTask.DelayFrame(10).ContinueWith(_ => cts.Cancel()).Forget();
|
||||
UniTask.DelayFrame(10).ContinueWith(() => cts.Cancel()).Forget();
|
||||
|
||||
var first = Time.frameCount;
|
||||
var (canceled, value) = await UniTask.DelayFrame(100, cancellationToken: cts.Token).SuppressCancellationThrow();
|
||||
var canceled = await UniTask.DelayFrame(100, cancellationToken: cts.Token).SuppressCancellationThrow();
|
||||
|
||||
(Time.frameCount - first).Should().Be(11); // 10 frame canceled
|
||||
canceled.Should().Be(true);
|
||||
@@ -285,12 +282,12 @@ namespace UniRx.AsyncTests
|
||||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
UniTask.DelayFrame(10).ContinueWith(_ => cts.Cancel()).Forget();
|
||||
UniTask.DelayFrame(10).ContinueWith(() => cts.Cancel()).Forget();
|
||||
|
||||
bool occur = false;
|
||||
try
|
||||
{
|
||||
var value = await UniTask.DelayFrame(100, cancellationToken: cts.Token);
|
||||
await UniTask.DelayFrame(100, cancellationToken: cts.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user