mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
Clarify "flattening" step in SB3 roundtrip test
This commit is contained in:
parent
4b1aad5099
commit
1bf1808826
1 changed files with 4 additions and 4 deletions
|
@ -95,11 +95,11 @@ test('sb3-roundtrip', t => {
|
|||
});
|
||||
|
||||
const serializeAndDeserialize = installThings.then(() => {
|
||||
// `Clone.simple` here helps in two ways:
|
||||
// Doing a JSON `stringify` and `parse` here more accurately simulate a save/load cycle. In particular:
|
||||
// 1. it ensures that any non-serializable data is thrown away, and
|
||||
// 2. `sb3.deserialize` does some `hasOwnProperty` checks which fail on the object returned by `sb3.serialize`
|
||||
// due to its inheritance structure.
|
||||
const serializedState = Clone.simple(sb3.serialize(runtime1));
|
||||
// 2. `sb3.deserialize` and its helpers do some `hasOwnProperty` checks which fail on the object returned by
|
||||
// `sb3.serialize` but succeed if that object is "flattened" in this way.
|
||||
const serializedState = JSON.parse(JSON.stringify(sb3.serialize(runtime1)));
|
||||
return sb3.deserialize(serializedState, runtime2);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue