mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-11 13:34:00 -04:00
Merge pull request #1032 from towerofnix/while-vm
Implement "while" block
This commit is contained in:
commit
b794e19c31
3 changed files with 45 additions and 1 deletions
test/unit
|
@ -52,6 +52,28 @@ test('repeatUntil', t => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('repeatWhile', t => {
|
||||
const rt = new Runtime();
|
||||
const c = new Control(rt);
|
||||
|
||||
// Test harness (mocks `util`)
|
||||
let i = 0;
|
||||
const repeat = 10;
|
||||
const util = {
|
||||
stackFrame: Object.create(null),
|
||||
startBranch: function () {
|
||||
i++;
|
||||
// Note !== instead of ===
|
||||
c.repeatWhile({CONDITION: (i !== repeat)}, util);
|
||||
}
|
||||
};
|
||||
|
||||
// Execute test
|
||||
c.repeatWhile({CONDITION: (i !== repeat)}, util);
|
||||
t.strictEqual(i, repeat);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('forEach', t => {
|
||||
const rt = new Runtime();
|
||||
const c = new Control(rt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue