Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/fixtures/execute/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Tests in this folder are run in scratch by integration/execute.js. The tests can SAY test messages that map to tap methods. Read integration/execute.js for more.

Tests whose names start with `tw-` are added by TurboWarp. Some of these tests are based on real projects from the scratch.mit.edu website, in which case their filename contains the original project ID and additional credits are within the project's scripts. We believe our use of these projects is fair use as the projects have been sufficiently modified and stripped down such that the project found here bears not even a slight resemblance to the original project.

Tests whose names start with `forkphorus-` were imported from https://github.com/forkphorus/forkphorus/tree/master/tests. There is a fair bit of test case sharing between forkphorus and TurboWarp.
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-112.sb3
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-263-NaN.sb3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-56-NaN.sb3
Binary file not shown.
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-66-insert.sb3
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-70.sb3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-for-each-in.sb3
Binary file not shown.
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-glide-xy-NaN.sb3
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-mathop-NaN.sb3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-operators.sb3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/fixtures/execute/forkphorus-tangent.sb3
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// TW Snapshot
// Input SHA-256: d641b68a89119171eff5d36de1bd4f59b1649acc5ae55803fb0b797b636f52bb

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ () {
yield* thread.procedures["ZassertTrue %b %s"](("apple".toLowerCase().indexOf("aPPle".toLowerCase()) !== -1),"apple contains aPPle");
yield* thread.procedures["ZassertTrue %b %s"](("APPLE".toLowerCase().indexOf("app".toLowerCase()) !== -1),"APPLE contains app");
yield* thread.procedures["ZassertTrue %b %s"](("appLe".toLowerCase().indexOf("LE".toLowerCase()) !== -1),"appLe contains LE");
yield* thread.procedures["ZOK %s"]("ok");
retire(); return;
}; })

// Sprite1 ZassertTrue %b %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_assertTrue__ (p0,p1) {
if (!toBoolean(p0)) {
yield* thread.procedures["ZFAIL %s"](p1);
}
return "";
}; })

// Sprite1 ZOK %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_OK_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "j", null);
yield* executeInCompatibilityLayer({"MESSAGE":("pass " + ("" + p0)),}, b0, false, false, "a", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "l", null);
runtime.stopAll();
retire(); yield;
return "";
}; })

// Sprite1 ZFAIL %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_FAIL_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "n", null);
yield* executeInCompatibilityLayer({"MESSAGE":("fail " + ("" + p0)),}, b0, false, false, "b", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "p", null);
runtime.stopAll();
retire(); yield;
return "";
}; })
45 changes: 45 additions & 0 deletions test/snapshot/__snapshots__/forkphorus-112.sb3.tw-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// TW Snapshot
// Input SHA-256: ff616461f1a16504b3a7be65eeecfdd29d31e897c43157fbd51370f72458852d

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ () {
runtime.ext_scratch3_looks._setCostume(target, "costume2");
runtime.ext_scratch3_looks._setCostume(target, (" " + ""));
yield* thread.procedures["ZassertTrue %b %s"](((target.currentCostume + 1) === 2),"costume should not change");
yield* thread.procedures["ZOK %s"]("");
retire(); return;
}; })

// Sprite1 ZassertTrue %b %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_assertTrue__ (p0,p1) {
if (!toBoolean(p0)) {
yield* thread.procedures["ZFAIL %s"](p1);
}
return "";
}; })

// Sprite1 ZOK %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_OK_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "j", null);
yield* executeInCompatibilityLayer({"MESSAGE":("pass " + ("" + p0)),}, b0, false, false, "b", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "l", null);
runtime.stopAll();
retire(); yield;
return "";
}; })

// Sprite1 ZFAIL %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_FAIL_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "n", null);
yield* executeInCompatibilityLayer({"MESSAGE":("fail " + ("" + p0)),}, b0, false, false, "c", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "p", null);
runtime.stopAll();
retire(); yield;
return "";
}; })
48 changes: 48 additions & 0 deletions test/snapshot/__snapshots__/forkphorus-263-NaN.sb3.tw-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// TW Snapshot
// Input SHA-256: 67ab3b26c771f54d4181fa85a76430fdb4603a171c36a918cce1374c89bf9c23

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["rL_u6{W`ET;GKBRHZrag"];
return function* genXYZ () {
yield* thread.procedures["ZassertTrue %b %s"]((("" + (0 / 0)).toLowerCase() === "NaN".toLowerCase()),"0/0");
yield* thread.procedures["ZassertTrue %b %s"](compareEqual((0 / 0), (0 / 0)),"NaN == NaN");
yield* thread.procedures["ZassertTrue %b %s"](compareEqual(Math.sqrt(-100), (0 / 0)),"sqrt negative");
b0.value = (0 / 0);
yield* thread.procedures["ZassertTrue %b %s"]((("" + b0.value).toLowerCase() === "NaN".toLowerCase()),"NaN storable in variables");
yield* thread.procedures["ZOK %s"]("");
retire(); return;
}; })

// Sprite1 ZassertTrue %b %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_assertTrue__ (p0,p1) {
if (!toBoolean(p0)) {
yield* thread.procedures["ZFAIL %s"](p1);
}
return "";
}; })

// Sprite1 ZOK %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_OK_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "n", null);
yield* executeInCompatibilityLayer({"MESSAGE":("pass " + ("" + p0)),}, b0, false, false, "a", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "p", null);
runtime.stopAll();
retire(); yield;
return "";
}; })

// Sprite1 ZFAIL %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_FAIL_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "r", null);
yield* executeInCompatibilityLayer({"MESSAGE":("fail " + ("" + p0)),}, b0, false, false, "b", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "t", null);
runtime.stopAll();
retire(); yield;
return "";
}; })
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// TW Snapshot
// Input SHA-256: 801a8e9ac5e607f022601f2eda4bddf37b29c30627f0e24864c7b0f9cf7b65f9

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["G3sNM{+Wa29PviNsXl~;"];
return function* genXYZ () {
b0.value = "4";
runtime.ext_scratch3_looks._setCostume(target, b0.value);
yield* thread.procedures["ZassertTrue %b %s"](((+target.getCostumes()[target.currentCostume].name || 0) === 4),"cn=4");
yield* thread.procedures["ZassertTrue %b %s"](((target.currentCostume + 1) === 2),"c#=2");
b0.value = 3;
runtime.ext_scratch3_looks._setCostume(target, b0.value);
yield* thread.procedures["ZassertTrue %b %s"]((target.getCostumes()[target.currentCostume].name.toLowerCase() === "costume3".toLowerCase()),"cn=costume3");
yield* thread.procedures["ZassertTrue %b %s"](((target.currentCostume + 1) === 3),"c#=3");
b0.value = ("" + "4");
runtime.ext_scratch3_looks._setCostume(target, b0.value);
yield* thread.procedures["ZassertTrue %b %s"](((+target.getCostumes()[target.currentCostume].name || 0) === 4),"cn=4");
yield* thread.procedures["ZassertTrue %b %s"](((target.currentCostume + 1) === 2),"c#=2");
b0.value = (4 * 1);
runtime.ext_scratch3_looks._setCostume(target, b0.value);
yield* thread.procedures["ZassertTrue %b %s"]((target.getCostumes()[target.currentCostume].name.toLowerCase() === "costume4".toLowerCase()),"cn=costume4");
yield* thread.procedures["ZassertTrue %b %s"](((target.currentCostume + 1) === 4),"c#=4");
b0.value = "4";
runtime.ext_scratch3_looks._setBackdrop(stage, b0.value);
yield* thread.procedures["ZassertTrue %b %s"](((+stage.getCostumes()[stage.currentCostume].name || 0) === 4),"bn=4");
yield* thread.procedures["ZassertTrue %b %s"](((stage.currentCostume + 1) === 2),"b#=2");
b0.value = 3;
runtime.ext_scratch3_looks._setBackdrop(stage, b0.value);
yield* thread.procedures["ZassertTrue %b %s"]((stage.getCostumes()[stage.currentCostume].name.toLowerCase() === "backdrop3".toLowerCase()),"cn=backdrop3");
yield* thread.procedures["ZassertTrue %b %s"](((stage.currentCostume + 1) === 3),"c#=3");
b0.value = ("" + "4");
runtime.ext_scratch3_looks._setBackdrop(stage, b0.value);
yield* thread.procedures["ZassertTrue %b %s"](((+stage.getCostumes()[stage.currentCostume].name || 0) === 4),"bn=4");
yield* thread.procedures["ZassertTrue %b %s"](((stage.currentCostume + 1) === 2),"b#=2");
b0.value = (4 * 1);
runtime.ext_scratch3_looks._setBackdrop(stage, b0.value);
yield* thread.procedures["ZassertTrue %b %s"]((stage.getCostumes()[stage.currentCostume].name.toLowerCase() === "backdrop4".toLowerCase()),"bn=backdrop4");
yield* thread.procedures["ZassertTrue %b %s"](((stage.currentCostume + 1) === 4),"b#=4");
yield* thread.procedures["ZOK %s"]("");
retire(); return;
}; })

// Sprite1 ZassertTrue %b %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_assertTrue__ (p0,p1) {
if (!toBoolean(p0)) {
yield* thread.procedures["ZFAIL %s"](p1);
}
return "";
}; })

// Sprite1 ZOK %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_OK_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "I", null);
yield* executeInCompatibilityLayer({"MESSAGE":("pass " + ("" + p0)),}, b0, false, false, "a", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "K", null);
runtime.stopAll();
retire(); yield;
return "";
}; })

// Sprite1 ZFAIL %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_FAIL_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "M", null);
yield* executeInCompatibilityLayer({"MESSAGE":("fail " + ("" + p0)),}, b0, false, false, "b", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "O", null);
runtime.stopAll();
retire(); yield;
return "";
}; })
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// TW Snapshot
// Input SHA-256: 1accbfd57a291524a062413a9c361d51e94ac5555fd3d861dd2d56806cd7e8c7

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["T{7z:Z^j(zfah+5ca3R0"];
return function* genXYZ () {
yield* thread.procedures["ZassertTrue %b %s"](((+b0.value || 0) === 33),"uses ID");
yield* thread.procedures["ZOK %s"]("");
retire(); return;
}; })

// Sprite1 ZassertTrue %b %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_assertTrue__ (p0,p1) {
if (!toBoolean(p0)) {
yield* thread.procedures["ZFAIL %s"](p1);
}
return "";
}; })

// Sprite1 ZOK %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_OK_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "h", null);
yield* executeInCompatibilityLayer({"MESSAGE":("pass " + ("" + p0)),}, b0, false, false, "a", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "j", null);
runtime.stopAll();
retire(); yield;
return "";
}; })

// Sprite1 ZFAIL %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_FAIL_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "l", null);
yield* executeInCompatibilityLayer({"MESSAGE":("fail " + ("" + p0)),}, b0, false, false, "b", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "n", null);
runtime.stopAll();
retire(); yield;
return "";
}; })
47 changes: 47 additions & 0 deletions test/snapshot/__snapshots__/forkphorus-56-NaN.sb3.tw-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// TW Snapshot
// Input SHA-256: 930b81005746fcf09490be69206cf92f6b882a8d4d66ef9cfa19139090131aad

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ () {
yield* thread.procedures["ZassertTrue %b %s"]((((5 + (+("" + "+") || 0)) || 0) === 5),1);
yield* thread.procedures["ZassertTrue %b %s"]((((5 + (+("" + "-") || 0)) || 0) === 5),2);
yield* thread.procedures["ZassertTrue %b %s"]((((5 + (+("" + "x") || 0)) || 0) === 5),3);
yield* thread.procedures["ZassertTrue %b %s"]((((5 + (+("" + "-=-2398749") || 0)) || 0) === 5),4);
yield* thread.procedures["ZassertTrue %b %s"]((((5 + (+("" + "") || 0)) || 0) === 5),5);
yield* thread.procedures["ZOK %s"]("");
retire(); return;
}; })

// Sprite1 ZassertTrue %b %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_assertTrue__ (p0,p1) {
if (!toBoolean(p0)) {
yield* thread.procedures["ZFAIL %s"](p1);
}
return "";
}; })

// Sprite1 ZOK %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_OK_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "A", null);
yield* executeInCompatibilityLayer({"MESSAGE":("pass " + ("" + p0)),}, b0, false, false, "g", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "C", null);
runtime.stopAll();
retire(); yield;
return "";
}; })

// Sprite1 ZFAIL %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_FAIL_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "l", null);
yield* executeInCompatibilityLayer({"MESSAGE":("fail " + ("" + p0)),}, b0, false, false, "a", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "n", null);
runtime.stopAll();
retire(); yield;
return "";
}; })
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// TW Snapshot
// Input SHA-256: 95f7dfd29f2a3aec8027d03eab202b439a7630a1ee6b9a7cf534c7d971e41ef7

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables[")@7t1F9WM1F[_jBWx]7["];
const b1 = stage.variables[",VHjOaLurDh*^;8kZ~I?"];
return function* genXYZ () {
b0.value = [];
b1.value = [];
b0.value.push(3);
b0._monitorUpToDate = false;
b0.value.push(2);
b0._monitorUpToDate = false;
b0.value.push(8);
b0._monitorUpToDate = false;
b0.value.push(4);
b0._monitorUpToDate = false;
b1.value.push(listContents(b0));
b1._monitorUpToDate = false;
b0.value = [];
yield* thread.procedures["ZassertTrue %b %s"]((b1.value.length === 1),"output length = 1");
yield* thread.procedures["ZassertTrue %b %s"]((b0.value.length === 0),"data length = 0");
yield* thread.procedures["ZassertTrue %b %s"](((+(b1.value[1 - 1] ?? "") || 0) === 3284),"output item 1");
yield* thread.procedures["ZOK %s"]("");
retire(); return;
}; })

// Sprite1 ZassertTrue %b %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_assertTrue__ (p0,p1) {
if (!toBoolean(p0)) {
yield* thread.procedures["ZFAIL %s"](p1);
}
return "";
}; })

// Sprite1 ZOK %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_OK_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "j", null);
yield* executeInCompatibilityLayer({"MESSAGE":("pass " + ("" + p0)),}, b0, false, false, "a", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "l", null);
runtime.stopAll();
retire(); yield;
return "";
}; })

// Sprite1 ZFAIL %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_FAIL_ (p0) {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "n", null);
yield* executeInCompatibilityLayer({"MESSAGE":("fail " + ("" + p0)),}, b0, false, false, "b", null);
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "p", null);
runtime.stopAll();
retire(); yield;
return "";
}; })
Loading