mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-12 22:14:07 -04:00
test: add test for broadcast and wait in warp mode
This commit is contained in:
parent
bea81b41f3
commit
dc18dbf3f8
2 changed files with 35 additions and 0 deletions
test
BIN
test/fixtures/warped-broadcasts.sb3
vendored
Normal file
BIN
test/fixtures/warped-broadcasts.sb3
vendored
Normal file
Binary file not shown.
35
test/integration/warped-broadcasts.js
Normal file
35
test/integration/warped-broadcasts.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
const path = require('path');
|
||||
const test = require('tap').test;
|
||||
const makeTestStorage = require('../fixtures/make-test-storage');
|
||||
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
|
||||
const VirtualMachine = require('../../src/index');
|
||||
const Runtime = require('../../src/engine/runtime');
|
||||
|
||||
const projectUri = path.resolve(__dirname, '../fixtures/warped-broadcasts.sb3');
|
||||
const project = readFileToBuffer(projectUri);
|
||||
|
||||
test('broadcasts in warp procedures ', t => {
|
||||
const vm = new VirtualMachine();
|
||||
vm.attachStorage(makeTestStorage());
|
||||
|
||||
// Start VM, load project, and run
|
||||
t.doesNotThrow(() => {
|
||||
// Note: don't run vm.start(), we handle calling _step() manually in this test
|
||||
vm.runtime.currentStepTime = Runtime.THREAD_STEP_INTERVAL;
|
||||
vm.clear();
|
||||
vm.setCompatibilityMode(false);
|
||||
vm.setTurboMode(false);
|
||||
|
||||
vm.loadProject(project).then(() => {
|
||||
t.equal(vm.runtime.threads.length, 0);
|
||||
|
||||
vm.greenFlag();
|
||||
t.equal(vm.runtime.threads.length, 1);
|
||||
vm.runtime._step();
|
||||
t.equal(vm.runtime.threads.length, 0);
|
||||
t.equal(vm.runtime._lastStepDoneThreads.length, 2);
|
||||
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue