Files
刘宇飞 6e0a1fbcbb 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>
2026-06-16 15:37:45 +08:00

30 lines
803 B
JavaScript

const fs = require('fs');
const path = require('path');
const {test} = require('tap');
const VirtualMachine = require('../../src/virtual-machine');
const projectPath = path.join(__dirname, '..', 'fixtures', 'tw-stackframe-op.sb3');
test('util.thread.peekStackFrame().op', t => {
const vm = new VirtualMachine();
vm.runtime.setCompilerOptions({
enabled: false
});
// Easiest way to test this is to overwrite an existing block
vm.runtime._primitives.operator_add = function (args, util) {
const op = util.thread.peekStackFrame().op;
t.equal(op.id, 'c');
t.end();
// return value not used
return 4;
};
vm.loadProject(fs.readFileSync(projectPath)).then(() => {
vm.greenFlag();
vm.runtime._step();
});
});