mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-11 13:59:23 -04:00
test stopThisScript in procedures
- Test that stopThisScript in a procedure stays in the procedure and moves it to the end where Sequencer can pop it normally
This commit is contained in:
parent
832cfda56b
commit
8d91e3cbd7
2 changed files with 34 additions and 1 deletions
test/unit
|
@ -209,21 +209,54 @@ test('stopThisScript', t => {
|
|||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
const block3 = {fields: Object,
|
||||
id: 'thirdString',
|
||||
inputs: Object,
|
||||
STEPS: Object,
|
||||
block: 'fakeBlock',
|
||||
name: 'STEPS',
|
||||
next: null,
|
||||
opcode: 'procedures_definition',
|
||||
mutation: {proccode: 'fakeCode'},
|
||||
parent: null,
|
||||
shadow: false,
|
||||
topLevel: true,
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
|
||||
rt.blocks.createBlock(block1);
|
||||
rt.blocks.createBlock(block2);
|
||||
rt.blocks.createBlock(block3);
|
||||
th.target = rt;
|
||||
|
||||
th.stopThisScript();
|
||||
t.strictEquals(th.peekStack(), null);
|
||||
t.strictEquals(th.peekStackFrame(), null);
|
||||
|
||||
th.pushStack('arbitraryString');
|
||||
t.strictEquals(th.peekStack(), 'arbitraryString');
|
||||
t.notEqual(th.peekStackFrame(), null);
|
||||
th.stopThisScript();
|
||||
t.strictEquals(th.peekStack(), null);
|
||||
t.strictEquals(th.peekStackFrame(), null);
|
||||
|
||||
th.pushStack('arbitraryString');
|
||||
th.pushStack('secondString');
|
||||
th.stopThisScript();
|
||||
t.strictEquals(th.peekStack(), 'secondString');
|
||||
t.strictEquals(th.peekStack(), null);
|
||||
t.same(th.stack, ['arbitraryString', 'secondString']);
|
||||
t.notEqual(th.peekStackFrame(), null);
|
||||
|
||||
while (th.peekStackFrame()) th.popStack();
|
||||
|
||||
th.pushStack('arbitraryString');
|
||||
th.pushStack('secondString');
|
||||
th.pushStack('thirdString');
|
||||
th.stopThisScript();
|
||||
t.strictEquals(th.peekStack(), null);
|
||||
t.same(th.stack, ['arbitraryString', 'secondString']);
|
||||
t.notEqual(th.peekStackFrame(), null);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue