mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
unit test more stepToBranch scenarios
This commit is contained in:
parent
e1254bd8c7
commit
832cfda56b
1 changed files with 25 additions and 1 deletions
|
@ -120,15 +120,39 @@ test('stepToBranch', t => {
|
||||||
const r = new Runtime();
|
const r = new Runtime();
|
||||||
const s = new Sequencer(r);
|
const s = new Sequencer(r);
|
||||||
const th = generateThread(r);
|
const th = generateThread(r);
|
||||||
|
|
||||||
|
// Push substack 2 (null).
|
||||||
s.stepToBranch(th, 2, false);
|
s.stepToBranch(th, 2, false);
|
||||||
t.strictEquals(th.peekStack(), null);
|
t.strictEquals(th.peekStack(), null);
|
||||||
th.popStack();
|
th.popStack();
|
||||||
|
t.strictEquals(th.peekStackFrame().isLoop, false);
|
||||||
|
// Push substack 1 (null).
|
||||||
s.stepToBranch(th, 1, false);
|
s.stepToBranch(th, 1, false);
|
||||||
t.strictEquals(th.peekStack(), null);
|
t.strictEquals(th.peekStack(), null);
|
||||||
th.popStack();
|
th.popStack();
|
||||||
|
t.strictEquals(th.peekStackFrame().isLoop, false);
|
||||||
|
// Push loop substack (null).
|
||||||
|
s.stepToBranch(th, 1, true);
|
||||||
|
t.strictEquals(th.peekStack(), null);
|
||||||
th.popStack();
|
th.popStack();
|
||||||
|
t.strictEquals(th.peekStackFrame().isLoop, true);
|
||||||
|
// isLoop resets when thread goes to next block.
|
||||||
|
th.goToNextBlock();
|
||||||
|
t.strictEquals(th.peekStackFrame().isLoop, false);
|
||||||
|
th.popStack();
|
||||||
|
// Push substack 1 (not null).
|
||||||
s.stepToBranch(th, 1, false);
|
s.stepToBranch(th, 1, false);
|
||||||
t.notEquals(th.peekStack(), null);
|
t.notEquals(th.peekStack(), null);
|
||||||
|
th.popStack();
|
||||||
|
t.strictEquals(th.peekStackFrame().isLoop, false);
|
||||||
|
// Push loop substack (not null).
|
||||||
|
s.stepToBranch(th, 1, true);
|
||||||
|
t.notEquals(th.peekStack(), null);
|
||||||
|
th.popStack();
|
||||||
|
t.strictEquals(th.peekStackFrame().isLoop, true);
|
||||||
|
// isLoop resets when thread goes to next block.
|
||||||
|
th.goToNextBlock();
|
||||||
|
t.strictEquals(th.peekStackFrame().isLoop, false);
|
||||||
|
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue