Includes scratch-gui, scratch-vm, scratch-blocks, scratch-render, scratch-l10n, and deployment config. Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
const {test} = require('tap');
|
|
const Thread = require('../../src/engine/thread');
|
|
const Runtime = require('../../src/engine/runtime');
|
|
const Target = require('../../src/engine/target');
|
|
|
|
test('stopThisScript procedures_call reporter form', t => {
|
|
const rt = new Runtime();
|
|
const target = new Target(rt, null);
|
|
|
|
target.blocks.createBlock({
|
|
id: 'reporterCall',
|
|
opcode: 'procedures_call',
|
|
inputs: {},
|
|
fields: {},
|
|
mutation: {
|
|
return: '1'
|
|
},
|
|
shadow: false,
|
|
topLevel: true,
|
|
parent: null,
|
|
next: 'afterReporterCall'
|
|
});
|
|
target.blocks.createBlock({
|
|
id: 'afterReporterCall',
|
|
opcode: 'motion_ifonedgebounce',
|
|
inputs: {},
|
|
fields: {},
|
|
mutation: null,
|
|
shadow: false,
|
|
topLevel: false,
|
|
parent: null,
|
|
next: null
|
|
});
|
|
|
|
const thread = new Thread('reporterCall');
|
|
thread.target = target;
|
|
|
|
// pretend to run reporterCall
|
|
thread.pushStack('reporterCall');
|
|
thread.peekStackFrame().waitingReporter = true;
|
|
|
|
// pretend to run scripts inside of the procedure
|
|
thread.pushStack('fakeBlock');
|
|
|
|
// stopping or returning should always return to reporterCall, not the block after
|
|
thread.stopThisScript();
|
|
t.same(thread.stack, [
|
|
'reporterCall'
|
|
]);
|
|
|
|
t.end();
|
|
});
|