Skip to content

Commit 051a508

Browse files
committed
test: add test for broadcast and wait in warp mode
1 parent bea81b4 commit 051a508

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

‎test/fixtures/warped-broadcasts.sb3

41.5 KB
Binary file not shown.

‎test/integration/warped-broadcasts.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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

Comments
 (0)