mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-26 14:12:32 -04: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(() => {
|
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
|
// 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`
|
// 2. `sb3.deserialize` and its helpers do some `hasOwnProperty` checks which fail on the object returned by
|
||||||
// due to its inheritance structure.
|
// `sb3.serialize` but succeed if that object is "flattened" in this way.
|
||||||
const serializedState = Clone.simple(sb3.serialize(runtime1));
|
const serializedState = JSON.parse(JSON.stringify(sb3.serialize(runtime1)));
|
||||||
return sb3.deserialize(serializedState, runtime2);
|
return sb3.deserialize(serializedState, runtime2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue