-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const path = require('path'); | ||
const test = require('tap').test; | ||
const makeTestStorage = require('../fixtures/make-test-storage'); | ||
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer; | ||
const VirtualMachine = require('../../src/index'); | ||
|
||
const projectUri = path.resolve(__dirname, '../fixtures/variable-comment.sb3'); | ||
const project = readFileToBuffer(projectUri); | ||
|
||
test('load an sb3 project with comments attached to variable blocks (#1893)', t => { | ||
const vm = new VirtualMachine(); | ||
vm.attachStorage(makeTestStorage()); | ||
|
||
// Evaluate playground data and exit | ||
vm.on('playgroundData', e => { | ||
const threads = JSON.parse(e.threads); | ||
t.equal(threads.length, 0); | ||
|
||
const stage = vm.runtime.targets[0]; | ||
const stageComments = Object.values(stage.comments); | ||
|
||
// Stage has 2 comments | ||
t.equal(stageComments.length, 2); | ||
|
||
// comment1 is atached to variable block | ||
t.equal(stageComments[0].text, 'comment1'); | ||
const variableBlock = stage.blocks.getBlock(stageComments[0].blockId); | ||
t.equal(variableBlock.opcode, 'data_variable'); | ||
|
||
// comment2 is atached to variable block | ||
t.equal(stageComments[1].text, 'comment2'); | ||
const listBlock = stage.blocks.getBlock(stageComments[1].blockId); | ||
t.equal(listBlock.opcode, 'data_listcontents'); | ||
|
||
t.end(); | ||
process.nextTick(process.exit); | ||
}); | ||
|
||
// Start VM, load project, and run | ||
t.doesNotThrow(() => { | ||
vm.start(); | ||
vm.clear(); | ||
vm.setCompatibilityMode(false); | ||
vm.setTurboMode(false); | ||
vm.loadProject(project).then(() => { | ||
vm.greenFlag(); | ||
setTimeout(() => { | ||
vm.getPlaygroundData(); | ||
vm.stopAll(); | ||
}, 100); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters