114 Commits
Author SHA1 Message Date
Thomas Weber 8ce06bc6a8 Import most of the forkphorus test suite (#303)
forkphorus has its own test suite, most of which are regression tests for real bugs in a real compiler so it may be worth testing against.

forkphorus-befunge-eratosthenes and forkphorus-string-functions are probably the most meaningful new test cases; at the very least i wouldn't have needed a new test case in #300 to see changes in snapshots if they were merged

The tests also add coverage for specializations like "delete 1 of list" that somehow weren't in the suite before?
2026-10-18 14:49:20 -05:00
Thomas Weber 3aca9363a3 Optimize jsexecute helpers (#389)
* replace Number.isNaN -> x !== x (see https://github.com/TurboWarp/scratch-vm/pull/367 for background on this though it matters less than expected)
 * optimize listGet for numbers
 * optimize listReplace for numbers
 * optimize listDelete for first and last items
 * optimize listContains / listIndexOf by hoisting work that would previously happened inside compareEqual many times
2026-10-18 13:29:37 -05:00
Thomas Weber ec5733a9e7 Remove yields from stop all and delete clone (#392) 2026-10-18 13:05:45 -05:00
Thomas Weber 55fd9b7c95 Fix compiler error when argument name is literal number (#387) 2026-10-11 19:29:56 -05:00
Thomas Weber 7d0d67ad9f Fix missing optimization passes on procedures with multiple variants (#383) 2026-10-11 17:09:05 -05:00
Thomas Weber 042235b193 Fix tangent (#381)
fix https://github.com/TurboWarp/scratch-vm/issues/380
2026-10-05 20:50:07 -05:00
Thomas Weber 32b5428fab Fix casting constant boolean interpretable string to number (#371)
They both should convert to 0
Fixes https://github.com/TurboWarp/scratch-vm/issues/359
2026-10-03 02:46:40 -05:00
Thomas Weber 8c62a150e1 Fix isNotActuallyZero on very small numbers (#373)
Fixes https://github.com/TurboWarp/scratch-vm/issues/361
2026-10-03 02:33:43 -05:00
Thomas Weber 984e05f83e Fix type analysis of casts with partially matching input types (#369)
Fixes https://github.com/TurboWarp/scratch-vm/issues/356
2026-10-03 01:45:28 -05:00
Thomas Weber c5bf9c3266 Fix custom reporter exit state analysis (#368)
Fixes https://github.com/TurboWarp/scratch-vm/issues/358
2026-10-03 01:39:14 -05:00
Thomas Weber 7fefa6f666 Check for either input never being numbers first in OP_EQUALS
Fixes https://github.com/TurboWarp/scratch-vm/issues/311
2025-12-29 20:06:36 -06:00
Thomas Weber 0e5043d4dc Fix missing boolean cast in control_repeat_until
Fixes https://github.com/TurboWarp/scratch-vm/issues/317
2025-12-29 19:50:15 -06:00
Thomas Weber 7aa8930802 Fix incorrect types for sensing_of
They can return 0 if the sprite does not exist
Fixes https://github.com/TurboWarp/scratch-vm/issues/262
Closes https://github.com/TurboWarp/scratch-vm/pull/325
(this one uses a different fix and has tests)

There are broader issues about compiled sensing_of not handling dynamic
sprite create/delete. We should tackle that later. The other PR wouldn't
really fix this either.
2025-12-29 18:58:44 -06:00
Thomas Weber eb0d678068 Only analyze repeat block inputs at the start of the loop 2025-10-12 11:12:05 -05:00
Thomas Weber d09f82a2fe Add new test case that does some simple string operations 2025-10-08 17:15:24 -05:00
Thomas Weber 2244b26773 Discard old state after calling yielding procedure 2025-09-24 16:48:01 -05:00
Thomas Weber 4a8a5ad901 Add test case for 7ed29f5801 2025-09-22 19:30:23 -05:00
Thomas Weber 214b86a063 Add test case for d8c73c71d2 2025-09-22 19:29:06 -05:00
Thomas Weber 445a129939 Add test case for 7cc8f580b3 2025-09-22 19:28:17 -05:00
Thomas Weber c372e925a5 Add test case for 6a37fee386 2025-09-22 19:27:08 -05:00
Thomas Weber 40715dc259 Add test case for https://github.com/TurboWarp/scratch-vm/issues/276 2025-09-22 18:41:48 -05:00
Thomas Weber 44e2589e65 Fix https://github.com/TurboWarp/scratch-vm/issues/277
Need to clear the state before analyzing the condition as the condition
may be re-evaluated after yielding.
2025-09-22 18:40:34 -05:00
Thomas Weber cd353ca31e Merge pull request #268 from TurboWarp/fix-analyzeLoopedBlock-infinite-loop
Give up analyzing looped stack after 10000 iterations
2025-09-20 13:57:52 -05:00
Thomas Weber fa035541da Give up analyzing looped stack after 10000 iterations
Temporary fix for an infinite loop, to be properly fixed later
2025-09-20 13:53:41 -05:00
Thomas Weber 5b027b995e Fix motion_turnleft and motion_turnright missing type casts 2025-09-15 18:01:45 -05:00
Tacodiva fbca1bf49b Fixed NaN = 0 wrongly reporting true, and add a test 2025-09-08 11:48:55 +10:00
Thomas Weber 7ef5e29c16 interpreter: fix skipped blocks in recursive procedures using "stop this script"
Closes https://github.com/TurboWarp/scratch-vm/issues/249
Regression from 20f25f252c
2025-03-07 01:21:08 -06:00
Muffin cd63c87f07 js: reset variable types after compatibility layer call
Fixes https://github.com/TurboWarp/scratch-vm/issues/245
2025-02-11 00:49:36 -06:00
Thomas Weber af3b7513a4 ir: Match vanilla quirks when handling variable or list fields with null ID 2025-01-18 00:29:09 -06:00
Thomas Weber 2c9d301da2 ir: Fix variable cache collision when variable or list field has null ID
Fixes https://github.com/TurboWarp/scratch-vm/issues/239
2025-01-18 00:09:09 -06:00
Muffin 179030ad49 Don't eagerly cast boolean arguments to boolean (#223)
Fixes https://github.com/TurboWarp/scratch-vm/issues/222
2024-09-08 11:56:47 -05:00
Muffin 6ce931b60a 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 f548d1b33c.
2024-05-23 14:16:57 -05:00
GarboMuffin 20f25f252c interpreter: Do not re-evaluate procedure arguments after stop this script or return (#202)
"stop this script" and "return" would previously cause all the procedure
arguments to be re-evaluated and then discarded. In vanilla Scratch the
worst case is a performance penalty, but with our custom reporters it
can cause infinite loops.

Fixes https://github.com/TurboWarp/scratch-vm/issues/201
2024-03-30 17:53:13 -05:00
Muffin 81a0382e0f merge-upstream: initial merge of upstream/develop
installs & compiles but has test errors

aside from expected merge conflicts, notable changes from upstream:
 - removed husky, commitlint, etc.
 - removed semantic-release etc.
2023-12-22 17:25:21 -06:00
GarboMuffin b90d1bc7ef Optimize counter blocks in compiler (#170) 2023-10-08 14:13:49 -05:00
Muffin 14ed3a9b99 Fix custom reporters when used inside of "repeat ( )" block in interpreter 2023-08-22 16:25:47 -05:00
Muffin 9cded93814 Fix return value of non-existent procedure in compiler 2023-07-29 10:45:28 -05:00
Muffin b8892efba6 Disable tests that are now intentionally broken 2023-07-23 15:17:44 -05:00
GarboMuffin f42b260cc0 Refactor procedure return tests into more manageable pieces 2023-07-14 22:22:22 -05:00
GarboMuffin 83605d0216 Fix execution order in recursive procedure reporters in compiler 2023-07-14 20:48:33 -05:00
GarboMuffin f033067b6f Non-warp recursion should yield in interpreter
Matches normal procedure blocks. Already worked in compiler.
2023-07-14 19:28:13 -05:00
GarboMuffin b8bc8571f1 Add reasonably comprehensive tests for return blocks 2023-07-10 21:49:38 -05:00
GarboMuffin 03bca533ba Fix ESLint warning in tw-generate-comparison-matrix-inline.js 2023-02-11 16:01:24 -06:00
GarboMuffin 9453bb45f7 Add more test cases 2023-01-17 13:57:27 -06:00
GarboMuffin 4fd7b3728a Fix handling of tab characters in comparison functions to match scratch-www
Closes https://github.com/TurboWarp/scratch-vm/issues/115
2023-01-14 22:36:57 -06:00
GarboMuffin f917741104 js: Mark sin, cos, tan, and random as NaN-able 2022-12-07 19:39:50 -06:00
GarboMuffin ef871f794c Fix compiled color pickers returning number instead of hex code
Hacked blocks and custom extensions expect colour_picker to return
a hex color code (#123abc) instead of the parsed number (1194684).
2022-11-22 21:22:12 -06:00
GarboMuffin 46f6d89b8d Import another test from https://github.com/forkphorus/forkphorus/pull/515 2022-08-28 12:58:33 -05:00
GarboMuffin 4943602646 Import some tests from https://github.com/forkphorus/forkphorus/pull/515 2022-08-27 17:53:30 -05:00
GarboMuffin 135fa04259 Fix tangent of perfect multiplies of 90
Previously they would return very large or very small numbers when they should instead be returning Infinity or -Infinity
2022-08-27 17:49:42 -05:00