Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/engine/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ Runtime.prototype.allScriptsDo = function (f, optTarget) {
if (optTarget) {
targets = [optTarget];
}
for (var t = 0; t < targets.length; t++) {
for (var t = targets.length - 1; t >= 0; t--) {
var target = targets[t];
var scripts = target.blocks.getScripts();
for (var j = 0; j < scripts.length; j++) {
Expand Down
6 changes: 3 additions & 3 deletions src/sprites/rendered-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ RenderedTarget.prototype.goBackLayers = function (nLayers) {

/**
* Move behind some other rendered target.
* @param {!Clone} other Other rendered target to move behind.
* @param {!RenderedTarget} other Other rendered target to move behind.
*/
RenderedTarget.prototype.goBehindOther = function (other) {
if (this.renderer) {
Expand Down Expand Up @@ -637,11 +637,11 @@ RenderedTarget.prototype.keepInFence = function (newX, newY, optFence) {
/**
* Make a clone, copying any run-time properties.
* If we've hit the global clone limit, returns null.
* @return {!RenderedTarget} New clone.
* @return {RenderedTarget} New clone.
*/
RenderedTarget.prototype.makeClone = function () {
if (!this.runtime.clonesAvailable() || this.isStage) {
return; // Hit max clone limit, or this is the stage.
return null; // Hit max clone limit, or this is the stage.
}
this.runtime.changeCloneCounter(1);
var newClone = this.sprite.createClone();
Expand Down
2 changes: 1 addition & 1 deletion src/sprites/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var Sprite = function (blocks, runtime) {

/**
* Create a clone of this sprite.
* @returns {!Clone} Newly created clone.
* @returns {!RenderedTarget} Newly created clone.
*/
Sprite.prototype.createClone = function () {
var newClone = new RenderedTarget(this, this.runtime);
Expand Down
Binary file added test/fixtures/hat-execution-order.sb2
Binary file not shown.
39 changes: 39 additions & 0 deletions test/integration/hat-execution-order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var path = require('path');
var test = require('tap').test;
var extract = require('../fixtures/extract');
var VirtualMachine = require('../../src/index');

var projectUri = path.resolve(__dirname, '../fixtures/hat-execution-order.sb2');
var project = extract(projectUri);

test('complex', function (t) {
var vm = new VirtualMachine();

// Evaluate playground data and exit
vm.on('playgroundData', function (e) {
var threads = JSON.parse(e.threads);
t.ok(threads.length === 0);

var results = vm.runtime.targets[0].lists.results.contents;
t.deepEqual(results, ['3', '2', '1', 'stage']);

t.end();
process.nextTick(process.exit);
});

// Start VM, load project, and run
t.doesNotThrow(function () {
vm.start();
vm.clear();
vm.setCompatibilityMode(false);
vm.setTurboMode(false);
vm.loadProject(project);
vm.greenFlag();
});

// After two seconds, get playground data and stop
setTimeout(function () {
vm.getPlaygroundData();
vm.stopAll();
}, 2000);
});