Skip to content

Commit

Permalink
Add test for behavior of self-restarting scripts
Browse files Browse the repository at this point in the history
The behavior is non-trivial as it will keep running the old thread
unti it yields.

I briefly tested putting `thread.status = 4` at the start of _restartThread
and all the old execution tests still passed, so let's just add a bit more
coverage. This was nearly regressed by f548d1b.
  • Loading branch information
GarboMuffin committed May 23, 2024
1 parent d39a30f commit 6ce931b
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// TW Snapshot
// Input SHA-256: dc029abbf128cea0830f4578e89619949837ec26dfa76f110ca599a9ee12e66e

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
const b1 = stage.variables["G{NQ*NXG*qzywe1Q3?FM"];
const b2 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
return function* genXYZ () {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "c", null);
b1.value = 0;
b2.value = 0;
startHats("event_whenbroadcastreceived", { BROADCAST_OPTION: "message1" });
retire(); return;
}; })

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
const b1 = stage.variables["G{NQ*NXG*qzywe1Q3?FM"];
const b2 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ () {
if (compareEqual(b0.value, 0)) {
b0.value = 1;
startHats("event_whenbroadcastreceived", { BROADCAST_OPTION: "message1" });
b1.value = 1;
for (var a0 = 1; a0 >= 0.5; a0--) {
yield;
}
b1.value = 2;
} else {
if (((+b1.value || 0) === 1)) {
yield* executeInCompatibilityLayer({"MESSAGE":"pass",}, b2, false, false, "p", null);
}
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b2, false, false, "n", null);
}
retire(); return;
}; })
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// TW Snapshot
// Input SHA-256: dc029abbf128cea0830f4578e89619949837ec26dfa76f110ca599a9ee12e66e

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
const b1 = stage.variables["G{NQ*NXG*qzywe1Q3?FM"];
const b2 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
return function* genXYZ () {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "c", null);
b1.value = 0;
b2.value = 0;
startHats("event_whenbroadcastreceived", { BROADCAST_OPTION: "message1" });
retire(); return;
}; })

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
const b1 = stage.variables["G{NQ*NXG*qzywe1Q3?FM"];
const b2 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ () {
if (compareEqual(b0.value, 0)) {
b0.value = 1;
startHats("event_whenbroadcastreceived", { BROADCAST_OPTION: "message1" });
b1.value = 1;
for (var a0 = 1; a0 >= 0.5; a0--) {
yield;
}
b1.value = 2;
} else {
if (((+b1.value || 0) === 1)) {
yield* executeInCompatibilityLayer({"MESSAGE":"pass",}, b2, false, false, "p", null);
}
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b2, false, false, "n", null);
}
retire(); return;
}; })

0 comments on commit 6ce931b

Please sign in to comment.