mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-29 07:29:12 -04:00
update runtime thread tests
Threads are now removed after every "inner" step. Any thread that reaches its DONE conditions is immediately removed instead of requiring an extra step to remove it. As such tests that check the number of threads have been updated to consider this.
This commit is contained in:
parent
b833ef8d24
commit
2ffa8eb333
5 changed files with 73 additions and 34 deletions
test/integration
|
@ -55,13 +55,19 @@ test('monitor thread runs every frame', t => {
|
|||
t.equal(vm.runtime.threads.length, 0);
|
||||
|
||||
vm.runtime._step();
|
||||
checkMonitorThreadPresent(t, vm.runtime.threads);
|
||||
t.assert(vm.runtime.threads[0].status === Thread.STATUS_DONE);
|
||||
let doneThreads = vm.runtime._lastStepDoneThreads;
|
||||
t.equal(vm.runtime.threads.length, 0);
|
||||
t.equal(doneThreads.length, 1);
|
||||
checkMonitorThreadPresent(t, doneThreads);
|
||||
t.assert(doneThreads[0].status === Thread.STATUS_DONE);
|
||||
|
||||
// Check that both are added again when another step is taken
|
||||
vm.runtime._step();
|
||||
checkMonitorThreadPresent(t, vm.runtime.threads);
|
||||
t.assert(vm.runtime.threads[0].status === Thread.STATUS_DONE);
|
||||
doneThreads = vm.runtime._lastStepDoneThreads;
|
||||
t.equal(vm.runtime.threads.length, 0);
|
||||
t.equal(doneThreads.length, 1);
|
||||
checkMonitorThreadPresent(t, doneThreads);
|
||||
t.assert(doneThreads[0].status === Thread.STATUS_DONE);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -103,12 +109,18 @@ test('monitor thread not added twice', t => {
|
|||
t.equal(vm.runtime.threads.length, 0);
|
||||
|
||||
vm.runtime._step();
|
||||
let doneThreads = vm.runtime._lastStepDoneThreads;
|
||||
t.equal(vm.runtime.threads.length, 1);
|
||||
t.equal(doneThreads.length, 0);
|
||||
checkMonitorThreadPresent(t, vm.runtime.threads);
|
||||
t.assert(vm.runtime.threads[0].status === Thread.STATUS_RUNNING);
|
||||
const prevThread = vm.runtime.threads[0];
|
||||
|
||||
// Check that both are added again when another step is taken
|
||||
vm.runtime._step();
|
||||
doneThreads = vm.runtime._lastStepDoneThreads;
|
||||
t.equal(vm.runtime.threads.length, 1);
|
||||
t.equal(doneThreads.length, 0);
|
||||
checkMonitorThreadPresent(t, vm.runtime.threads);
|
||||
t.equal(vm.runtime.threads[0], prevThread);
|
||||
t.end();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue