tests: #808 — ≥300-module init-scale harness#823
Merged
Conversation
Reproduces the conditions of #684 (Effect's Schema.ts ~310th-init regression) by forcing a 300-module topological-import chain and checking per-module state isolation. Each module: - Exports `VAL_NNN: number = 1000 + N` and `class Cls_NNN` with a `tag()` method returning `"Cls_NNN"`. - Imports `VAL_{N-1}` from the predecessor and references it in a top-level expression so module-init order has to walk the chain end to end (no DCE escape hatch). `index.ts` imports all 300 and asserts, for each `i`: - `typeof VAL_i === "number"` AND `VAL_i === 1000 + i` (no NaN-box tag leak across inits). - `new Cls_i().tag() === "Cls_i"` (no `class_id` smear / vtable collision after 300 distinct class registrations). On success prints a single `init-scale: OK (300 modules)` line; on failure pins the first failing probe so a regression is one grep away. `generate.py` is the source of truth — it regenerates `m000.ts ... m299.ts` and `index.ts` idempotently. Re-run with `python3 generate.py 600` to push past 300 once the current bug closes and we want a higher ceiling. Verified on v0.5.912: Perry compiles + runs the 300-module chain and prints the OK line. Node won't run this multi/ harness directly (no .ts-extension imports, by existing test-files/multi/* convention), so it's a Perry-specific smoke — same shape as the existing test_stress_cross_module under multi/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test-files/multi/test_harness_init_scale/reproducing the conditions of perry-codegen: Effect — (number).slice is not a function during Schema.ts__init (#680 follow-up, ~310th init) #684 (Effect's Schema.ts ~310th-init regression).VAL_NNN: number = 1000 + Nandclass Cls_NNN;index.tsimports all 300 and asserts per-module that:typeof VAL_i === \"number\"ANDVAL_i === 1000 + i(no NaN-box tag leak across inits).new Cls_i().tag() === \"Cls_i\"(no class_id smear / vtable collision across 300 registrations).init-scale: OK (300 modules)line; on failure pins the first failing probe.Generator
generate.pyis the source of truth for the module + index files — re-run withpython3 generate.py 600to push the ceiling once the current bug closes and we want a higher bar. Re-running is idempotent.Verification on v0.5.912
./target/release/perry test-files/multi/test_harness_init_scale/index.ts -o /tmp/init_scale && /tmp/init_scale→init-scale: OK (300 modules). Compiles + runs through the full 300-module chain on macOS arm64.Why a Perry-only harness (no Node baseline)
Existing
test-files/multi/*tests don't have.tsextensions in their import specifiers, so Node--experimental-strip-typesdoesn't resolve them — same astest_stress_cross_module. The harness is a Perry compile-and-run smoke; the CI hookup belongs in a separate compat-job issue (#802/#805 family).Test plan
python3 generate.py 300produces 300 modules + index.ts idempotently.perry compile … -o /tmp/init_scale && /tmp/init_scaleprints the OK line on v0.5.912.VAL_{i-1}in a top-level expression so the import survives DCE and the predecessor init has to run first.Diff size note
The PR adds 302 files (generator + index + 300 m*.ts) totalling ~7.6k inserts of mechanical, generator-emitted TypeScript. Diff is large but mechanical — review by spot-checking
generate.pyplus 2–3 generated modules.Closes #808.