From 4b21efc43c2a61163e715dfb4efaec8278c508cb Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 15 Mar 2026 10:46:50 +0000 Subject: [PATCH] JS test harness: 375/469 spec tests pass with full build - Add --full flag for full-spec build (includes continuations + types) - Add types module to JS SPEC_MODULES - 375 tests pass on JavaScript, 94 remaining failures are: 29 type platform stubs, 14 render format, 6 continuation aliases, 5 type system platform, 4 string primitive aliases - Full test build: hosts/javascript/cli.py --extensions continuations --spec-modules types --output sx-full-test.js Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 1 + hosts/javascript/platform.py | 3 ++- hosts/javascript/run_tests.js | 22 ++++++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index ff099ff..8f1ec4a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ _snapshot/ _debug/ sx-haskell/ sx-rust/ +shared/static/scripts/sx-full-test.js diff --git a/hosts/javascript/platform.py b/hosts/javascript/platform.py index aab6f80..d3e258d 100644 --- a/hosts/javascript/platform.py +++ b/hosts/javascript/platform.py @@ -48,11 +48,12 @@ SPEC_MODULES = { "page-helpers": ("page-helpers.sx", "page-helpers (pure data transformation helpers)"), "frames": ("frames.sx", "frames (CEK continuation frames)"), "cek": ("cek.sx", "cek (explicit CEK machine evaluator)"), + "types": ("types.sx", "types (gradual type system)"), } # Explicit ordering for spec modules with dependencies. # Modules listed here are emitted in this order; any not listed use alphabetical. -SPEC_MODULE_ORDER = ["deps", "frames", "page-helpers", "router", "cek", "signals"] +SPEC_MODULE_ORDER = ["deps", "frames", "page-helpers", "router", "cek", "signals", "types"] EXTENSION_NAMES = {"continuations"} diff --git a/hosts/javascript/run_tests.js b/hosts/javascript/run_tests.js index fadbf89..3f1d31c 100644 --- a/hosts/javascript/run_tests.js +++ b/hosts/javascript/run_tests.js @@ -36,7 +36,15 @@ global.clearTimeout = clearTimeout; global.console = console; // Load the bootstrapped evaluator -const jsPath = path.join(__dirname, "..", "..", "shared", "static", "scripts", "sx-browser.js"); +// Use --full flag to load a full-spec build (if available) +const fullBuild = process.argv.includes("--full"); +const jsPath = fullBuild + ? path.join(__dirname, "..", "..", "shared", "static", "scripts", "sx-full-test.js") + : path.join(__dirname, "..", "..", "shared", "static", "scripts", "sx-browser.js"); +if (fullBuild && !fs.existsSync(jsPath)) { + console.error("Full test build not found. Run: python3 hosts/javascript/cli.py --extensions continuations --spec-modules types --output shared/static/scripts/sx-full-test.js"); + process.exit(1); +} const Sx = require(jsPath); if (!Sx || !Sx.parse) { console.error("Failed to load Sx evaluator"); @@ -95,6 +103,16 @@ env["make-continuation"] = function(fn) { env["continuation?"] = function(x) { return x != null && x._continuation === true; }; env["continuation-fn"] = function(c) { return c.fn; }; +// Render helpers +if (Sx.renderToHtml) { + env["render-html"] = function(expr, e) { return Sx.renderToHtml(expr, e || env); }; +} + +// Type system helpers — available when types module is included +env["test-prim-param-types"] = function(name, types) { return null; }; +env["component-param-types"] = function(c) { return c && c._paramTypes ? c._paramTypes : null; }; +env["component-set-param-types!"] = function(c, t) { if (c) c._paramTypes = t; return null; }; + // Platform test functions env["try-call"] = function(thunk) { try { @@ -142,7 +160,7 @@ for (const expr of frameworkExprs) { } // Determine which tests to run -const args = process.argv.slice(2); +const args = process.argv.slice(2).filter(a => !a.startsWith("--")); let testFiles = []; if (args.length > 0) {