Skip to content

Commit 6ce931b

Browse files
committed
Add test for behavior of self-restarting scripts
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.
1 parent d39a30f commit 6ce931b

3 files changed

+76
-0
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// TW Snapshot
2+
// Input SHA-256: dc029abbf128cea0830f4578e89619949837ec26dfa76f110ca599a9ee12e66e
3+
4+
// Sprite1 script
5+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
6+
const b0 = runtime.getOpcodeFunction("looks_say");
7+
const b1 = stage.variables["G{NQ*NXG*qzywe1Q3?FM"];
8+
const b2 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
9+
return function* genXYZ () {
10+
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "c", null);
11+
b1.value = 0;
12+
b2.value = 0;
13+
startHats("event_whenbroadcastreceived", { BROADCAST_OPTION: "message1" });
14+
retire(); return;
15+
}; })
16+
17+
// Sprite1 script
18+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
19+
const b0 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
20+
const b1 = stage.variables["G{NQ*NXG*qzywe1Q3?FM"];
21+
const b2 = runtime.getOpcodeFunction("looks_say");
22+
return function* genXYZ () {
23+
if (compareEqual(b0.value, 0)) {
24+
b0.value = 1;
25+
startHats("event_whenbroadcastreceived", { BROADCAST_OPTION: "message1" });
26+
b1.value = 1;
27+
for (var a0 = 1; a0 >= 0.5; a0--) {
28+
yield;
29+
}
30+
b1.value = 2;
31+
} else {
32+
if (((+b1.value || 0) === 1)) {
33+
yield* executeInCompatibilityLayer({"MESSAGE":"pass",}, b2, false, false, "p", null);
34+
}
35+
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b2, false, false, "n", null);
36+
}
37+
retire(); return;
38+
}; })
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// TW Snapshot
2+
// Input SHA-256: dc029abbf128cea0830f4578e89619949837ec26dfa76f110ca599a9ee12e66e
3+
4+
// Sprite1 script
5+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
6+
const b0 = runtime.getOpcodeFunction("looks_say");
7+
const b1 = stage.variables["G{NQ*NXG*qzywe1Q3?FM"];
8+
const b2 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
9+
return function* genXYZ () {
10+
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "c", null);
11+
b1.value = 0;
12+
b2.value = 0;
13+
startHats("event_whenbroadcastreceived", { BROADCAST_OPTION: "message1" });
14+
retire(); return;
15+
}; })
16+
17+
// Sprite1 script
18+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
19+
const b0 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
20+
const b1 = stage.variables["G{NQ*NXG*qzywe1Q3?FM"];
21+
const b2 = runtime.getOpcodeFunction("looks_say");
22+
return function* genXYZ () {
23+
if (compareEqual(b0.value, 0)) {
24+
b0.value = 1;
25+
startHats("event_whenbroadcastreceived", { BROADCAST_OPTION: "message1" });
26+
b1.value = 1;
27+
for (var a0 = 1; a0 >= 0.5; a0--) {
28+
yield;
29+
}
30+
b1.value = 2;
31+
} else {
32+
if (((+b1.value || 0) === 1)) {
33+
yield* executeInCompatibilityLayer({"MESSAGE":"pass",}, b2, false, false, "p", null);
34+
}
35+
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b2, false, false, "n", null);
36+
}
37+
retire(); return;
38+
}; })

0 commit comments

Comments
 (0)