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:
Michael "Z" Goddard 2019-06-25 14:38:46 -04:00
parent 832cfda56b
commit 8d91e3cbd7
No known key found for this signature in database
GPG key ID: 762CD40DD5349872
2 changed files with 34 additions and 1 deletions

View file

@ -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();
});