mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-10 06:52:00 -05:00
Fix monitor tests to count only monitor threads
The monitor tests no longer fail if the last step happens to have run a non-monitor thread in addition to the monitor threads.
This commit is contained in:
parent
e071cf3c0c
commit
3649c15f2a
2 changed files with 13 additions and 3 deletions
|
@ -17,7 +17,12 @@ test('importing sb2 project with monitors', t => {
|
|||
// All monitors should create threads that finish during the step and
|
||||
// are revoved from runtime.threads.
|
||||
t.equal(threads.length, 0);
|
||||
t.equal(vm.runtime._lastStepDoneThreads.length, 8);
|
||||
|
||||
// we care that the last step updated the right number of monitors
|
||||
// we don't care whether the last step ran other threads or not
|
||||
const lastStepUpdatedMonitorThreads = vm.runtime._lastStepDoneThreads.filter(thread => thread.updateMonitor);
|
||||
t.equal(lastStepUpdatedMonitorThreads.length, 8);
|
||||
|
||||
// There should be one additional hidden monitor that is in the monitorState but
|
||||
// does not start a thread.
|
||||
t.equal(vm.runtime._monitorState.size, 9);
|
||||
|
|
|
@ -8,7 +8,7 @@ const Variable = require('../../src/engine/variable');
|
|||
const projectUri = path.resolve(__dirname, '../fixtures/monitors.sb3');
|
||||
const project = readFileToBuffer(projectUri);
|
||||
|
||||
test('importing sb2 project with monitors', t => {
|
||||
test('importing sb3 project with monitors', t => {
|
||||
const vm = new VirtualMachine();
|
||||
vm.attachStorage(makeTestStorage());
|
||||
|
||||
|
@ -18,7 +18,12 @@ test('importing sb2 project with monitors', t => {
|
|||
// All monitors should create threads that finish during the step and
|
||||
// are revoved from runtime.threads.
|
||||
t.equal(threads.length, 0);
|
||||
t.equal(vm.runtime._lastStepDoneThreads.length, 17);
|
||||
|
||||
// we care that the last step updated the right number of monitors
|
||||
// we don't care whether the last step ran other threads or not
|
||||
const lastStepUpdatedMonitorThreads = vm.runtime._lastStepDoneThreads.filter(thread => thread.updateMonitor);
|
||||
t.equal(lastStepUpdatedMonitorThreads.length, 17);
|
||||
|
||||
// There should be one additional hidden monitor that is in the monitorState but
|
||||
// does not start a thread.
|
||||
t.equal(vm.runtime._monitorState.size, 18);
|
||||
|
|
Loading…
Reference in a new issue