Initial commit of 001code-html Scratch frontend project.
Includes scratch-gui, scratch-vm, scratch-blocks, scratch-render, scratch-l10n, and deployment config. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
52
scratch-vm/test/unit/tw_stop_this_script.js
Normal file
52
scratch-vm/test/unit/tw_stop_this_script.js
Normal file
@@ -0,0 +1,52 @@
|
||||
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();
|
||||
});
|
||||
Reference in New Issue
Block a user