Remove invoke from platform interfaces, add cek-call integration tests

- platform_js.py: remove invoke function definition and PRIMITIVES
  registration, switch domListen handler wrapping to cek-call
- platform_py.py: remove invoke function definition
- run_signal_tests.py: remove invoke patch, use cek_call in batch wrapper
- run_cek_reactive_tests.py: remove invoke, fix primitive lookup to use
  two-level is_primitive/get_primitive, increase recursion limit for
  interpreted CEK evaluation
- test-cek-reactive.sx: add 7 new tests covering cek-call dispatch with
  computed, effect, cleanup, batch coalescing

All 79 tests pass (20 signal + 43 CEK + 16 CEK reactive).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 10:29:32 +00:00
parent 6581211a10
commit d0a5ce1070
7 changed files with 70 additions and 70 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Run test-signals.sx using the bootstrapped evaluator with signal primitives.
Uses bootstrapped signal functions from sx_ref.py directly, patching invoke
Uses bootstrapped signal functions from sx_ref.py directly, patching apply
to handle SX lambdas from the interpreter (test expressions create lambdas
that need evaluator dispatch).
"""
@@ -25,14 +25,9 @@ sx_ref.trampoline = trampoline
# Build env with primitives
env = make_env()
# --- Patch invoke and apply BEFORE anything else ---
# Test expressions create SX Lambdas that bootstrapped code calls via invoke/apply.
# Patch the module-level functions so all bootstrapped functions see them.
def _invoke(f, *args):
if isinstance(f, Lambda):
return trampoline(eval_expr([f] + list(args), env))
return f(*args)
sx_ref.__dict__["invoke"] = _invoke
# --- Patch apply BEFORE anything else ---
# Test expressions create SX Lambdas that bootstrapped code calls via apply.
# Patch the module-level function so all bootstrapped functions see it.
# apply is used by swap! and other forms to call functions with arg lists
def _apply(f, args):
@@ -124,7 +119,7 @@ env["effect"] = sx_ref.effect
# Wrap it to work correctly in the test context.
def _batch(thunk):
sx_ref._batch_depth = getattr(sx_ref, '_batch_depth', 0) + 1
_invoke(thunk)
sx_ref.cek_call(thunk, None)
sx_ref._batch_depth -= 1
if sx_ref._batch_depth == 0:
queue = list(sx_ref._batch_queue)
@@ -145,7 +140,6 @@ env["flush-subscribers"] = sx_ref.flush_subscribers
env["dispose-computed"] = sx_ref.dispose_computed
env["with-island-scope"] = sx_ref.with_island_scope
env["register-in-scope"] = sx_ref.register_in_scope
env["invoke"] = _invoke
env["callable?"] = sx_ref.is_callable
# Load test framework