mirror of
https://github.com/Ellpeck/Coroutine.git
synced 2024-06-11 17:00:24 +02:00
added a unit test to expose the bug.
This commit is contained in:
parent
5dc11e0d26
commit
581a01f048
|
@ -301,5 +301,40 @@ namespace Tests {
|
||||||
Assert.AreEqual(cr.Name, "Bird", "Incorrect name of the coroutine.");
|
Assert.AreEqual(cr.Name, "Bird", "Incorrect name of the coroutine.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNestedCoroutineWithMoveToTime()
|
||||||
|
{
|
||||||
|
var frequentEvent = new Event();
|
||||||
|
var onceInAWhileEvent = new Event();
|
||||||
|
|
||||||
|
IEnumerator<Wait> FrequentCoroutine() {
|
||||||
|
int i = 0;
|
||||||
|
while (true) {
|
||||||
|
yield return new Wait(frequentEvent);
|
||||||
|
if (i % 2 == 0) {
|
||||||
|
CoroutineHandler.RaiseEvent(onceInAWhileEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator<Wait> OnceInAWhileCoroutine() {
|
||||||
|
while (true) {
|
||||||
|
yield return new Wait(onceInAWhileEvent);
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
yield return new Wait(0d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CoroutineHandler.Start(FrequentCoroutine());
|
||||||
|
CoroutineHandler.Start(OnceInAWhileCoroutine());
|
||||||
|
|
||||||
|
CoroutineHandler.RaiseEvent(frequentEvent);
|
||||||
|
CoroutineHandler.RaiseEvent(frequentEvent);
|
||||||
|
CoroutineHandler.RaiseEvent(frequentEvent);
|
||||||
|
CoroutineHandler.RaiseEvent(frequentEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue