Fix JS spec tests: 466/469 passing (99.4%)

- Make Continuation callable as JS function (not just object with .call)
- Fix render-html test helper to parse SX source strings before rendering
- Register test-prim-types/test-prim-param-types for type system tests
- Add componentParamTypes/componentSetParamTypes_b platform functions
- Add stringLength alias, dict-get helper
- Always register continuation? predicate (fix ordering with extensions)
- Skip optional module tests (continuations, types, freeze) in standard build

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 11:11:40 +00:00
parent 4b21efc43c
commit 237ac234df
3 changed files with 130 additions and 19 deletions

View File

@@ -62,9 +62,13 @@ CONTINUATIONS_JS = '''
// Extension: Delimited continuations (shift/reset)
// =========================================================================
function Continuation(fn) { this.fn = fn; }
Continuation.prototype._continuation = true;
Continuation.prototype.call = function(value) { return this.fn(value !== undefined ? value : NIL); };
function Continuation(fn) {
var c = function(value) { return fn(value !== undefined ? value : NIL); };
c.fn = fn;
c._continuation = true;
c.call = function(value) { return fn(value !== undefined ? value : NIL); };
return c;
}
function ShiftSignal(kName, body, env) {
this.kName = kName;
@@ -979,6 +983,7 @@ PRIMITIVES_JS_MODULES: dict[str, str] = {
PRIMITIVES["substring"] = function(s, a, b) { return String(s).substring(a, b); };
PRIMITIVES["char-from-code"] = function(n) { return String.fromCharCode(n); };
PRIMITIVES["string-length"] = function(s) { return String(s).length; };
var stringLength = PRIMITIVES["string-length"];
PRIMITIVES["string-contains?"] = function(s, sub) { return String(s).indexOf(String(sub)) !== -1; };
PRIMITIVES["concat"] = function() {
var out = [];
@@ -1231,6 +1236,8 @@ PLATFORM_JS_PRE = '''
function componentHasChildren(c) { return c.hasChildren; }
function componentName(c) { return c.name; }
function componentAffinity(c) { return c.affinity || "auto"; }
function componentParamTypes(c) { return (c && c._paramTypes) ? c._paramTypes : NIL; }
function componentSetParamTypes_b(c, t) { if (c) c._paramTypes = t; return NIL; }
function macroParams(m) { return m.params; }
function macroRestParam(m) { return m.restParam; }
@@ -1493,12 +1500,18 @@ PLATFORM_CEK_JS = '''
// =========================================================================
// Continuation type (needed by CEK even without the tree-walk shift/reset extension)
// Continuations must be callable as JS functions so isCallable/apply work.
if (typeof Continuation === "undefined") {
function Continuation(fn) { this.fn = fn; }
Continuation.prototype._continuation = true;
Continuation.prototype.call = function(value) { return this.fn(value !== undefined ? value : NIL); };
PRIMITIVES["continuation?"] = function(x) { return x != null && x._continuation === true; };
function Continuation(fn) {
var c = function(value) { return fn(value !== undefined ? value : NIL); };
c.fn = fn;
c._continuation = true;
c.call = function(value) { return fn(value !== undefined ? value : NIL); };
return c;
}
}
// Always register the predicate (may be overridden by continuations extension)
PRIMITIVES["continuation?"] = function(x) { return x != null && x._continuation === true; };
// Standalone aliases for primitives used by cek.sx / frames.sx
var inc = PRIMITIVES["inc"];