|
| 1 | +const path = require('path'); |
| 2 | +const test = require('tap').test; |
| 3 | +const makeTestStorage = require('../fixtures/make-test-storage'); |
| 4 | +const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer; |
| 5 | +const VirtualMachine = require('../../src/index'); |
| 6 | +const Runtime = require('../../src/engine/runtime'); |
| 7 | + |
| 8 | +const projectUri = path.resolve(__dirname, '../fixtures/warped-broadcasts.sb3'); |
| 9 | +const project = readFileToBuffer(projectUri); |
| 10 | + |
| 11 | +test('broadcasts in warp procedures ', t => { |
| 12 | + const vm = new VirtualMachine(); |
| 13 | + vm.attachStorage(makeTestStorage()); |
| 14 | + |
| 15 | + // Start VM, load project, and run |
| 16 | + t.doesNotThrow(() => { |
| 17 | + // Note: don't run vm.start(), we handle calling _step() manually in this test |
| 18 | + vm.runtime.currentStepTime = Runtime.THREAD_STEP_INTERVAL; |
| 19 | + vm.clear(); |
| 20 | + vm.setCompatibilityMode(false); |
| 21 | + vm.setTurboMode(false); |
| 22 | + |
| 23 | + vm.loadProject(project).then(() => { |
| 24 | + t.equal(vm.runtime.threads.length, 0); |
| 25 | + |
| 26 | + vm.greenFlag(); |
| 27 | + t.equal(vm.runtime.threads.length, 1); |
| 28 | + vm.runtime._step(); |
| 29 | + t.equal(vm.runtime.threads.length, 0); |
| 30 | + t.equal(vm.runtime._lastStepDoneThreads.length, 2); |
| 31 | + |
| 32 | + t.end(); |
| 33 | + }); |
| 34 | + }); |
| 35 | +}); |
0 commit comments