added a unit test to expose the bug.

This commit is contained in:
Zaafar 2021-04-08 12:14:46 -04:00
parent 5dc11e0d26
commit 581a01f048

View file

@ -301,5 +301,40 @@ namespace Tests {
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);
}
}
}