forked from scratchfoundation/scratch-vm
-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor platform serialization to make it easier for forks
Also allows extensions an easy way to access it
- Loading branch information
1 parent
6a9bed0
commit 7efdf51
Showing
4 changed files
with
41 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Forks should change this. | ||
// This can be accessed externally on `vm.runtime.platform` | ||
|
||
module.exports = { | ||
name: 'TurboWarp', | ||
url: 'https://turbowarp.org/' | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const {test} = require('tap'); | ||
const VM = require('../../src/virtual-machine'); | ||
const platform = require('../../src/engine/tw-platform'); | ||
|
||
test('the internal object', t => { | ||
// the idea with this test is to make it harder for forks to screw up modifying the file | ||
t.type(platform.name, 'string'); | ||
t.type(platform.url, 'string'); | ||
t.end(); | ||
}); | ||
|
||
test('vm property', t => { | ||
const vm = new VM(); | ||
t.same(vm.runtime.platform, platform, 'copy of tw-platform.js'); | ||
t.not(vm.runtime.platform, platform, 'not the same object as tw-platform.js'); | ||
t.end(); | ||
}); | ||
|
||
test('sanitize', t => { | ||
const vm = new VM(); | ||
vm.runtime.platform.name += ' - test'; | ||
const json = JSON.parse(vm.toJSON()); | ||
t.same(json.meta.platform, vm.runtime.platform, 'copy of runtime.platform'); | ||
t.not(json.meta.platform, vm.runtime.platform, 'not the same object as runtime.platform'); | ||
t.end(); | ||
}); |