Add deps and engine test specs, bootstrap engine to Python
New test specs (test-deps.sx: 33 tests, test-engine.sx: 37 tests) covering component dependency analysis and engine pure functions. All 6 spec modules now have formal SX tests: eval (81), parser (39), router (18), render (23), deps (33), engine (37) = 231 total. - Add engine as spec module in bootstrap_py.py (alongside deps) - Add primitive aliases (trim, replace, parse_int, upper) for engine functions - Fix parse-int to match JS parseInt semantics (strip trailing non-digits) - Regenerate sx_ref.py with --spec-modules deps,engine - Update all three test runners (run.js, run.py, sx-test-runner.js) - Add Dependencies and Engine nav items and testing page entries - Wire deps-source/engine-source through testing overview UI Node.js: 231/231 pass. Python: 226/231 (5 pre-existing parser/router gaps). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -854,6 +854,7 @@ ADAPTER_FILES = {
|
||||
SPEC_MODULES = {
|
||||
"deps": ("deps.sx", "deps (component dependency analysis)"),
|
||||
"router": ("router.sx", "router (client-side route matching)"),
|
||||
"engine": ("engine.sx", "engine (fetch/swap/trigger pure logic)"),
|
||||
}
|
||||
|
||||
|
||||
@@ -958,7 +959,7 @@ def compile_ref_to_py(
|
||||
Valid names: continuations.
|
||||
None = no extensions.
|
||||
spec_modules: List of spec module names to include.
|
||||
Valid names: deps.
|
||||
Valid names: deps, engine.
|
||||
None = no spec modules.
|
||||
"""
|
||||
# Determine which primitive modules to include
|
||||
@@ -1832,10 +1833,15 @@ PRIMITIVES["parse-int"] = lambda v, d=0: _sx_parse_int(v, d)
|
||||
PRIMITIVES["parse-datetime"] = lambda s: str(s) if s else NIL
|
||||
|
||||
def _sx_parse_int(v, default=0):
|
||||
try:
|
||||
return _b_int(v)
|
||||
except (ValueError, TypeError):
|
||||
if v is None or v is NIL:
|
||||
return default
|
||||
s = str(v).strip()
|
||||
# Match JS parseInt: extract leading integer portion
|
||||
import re as _re
|
||||
m = _re.match(r'^[+-]?\\d+', s)
|
||||
if m:
|
||||
return _b_int(m.group())
|
||||
return default
|
||||
''',
|
||||
|
||||
"stdlib.text": '''
|
||||
@@ -1976,6 +1982,10 @@ concat = PRIMITIVES["concat"]
|
||||
split = PRIMITIVES["split"]
|
||||
length = PRIMITIVES["len"]
|
||||
merge = PRIMITIVES["merge"]
|
||||
trim = PRIMITIVES["trim"]
|
||||
replace = PRIMITIVES["replace"]
|
||||
parse_int = PRIMITIVES["parse-int"]
|
||||
upper = PRIMITIVES["upper"]
|
||||
'''
|
||||
|
||||
|
||||
@@ -2189,7 +2199,7 @@ def main():
|
||||
parser.add_argument(
|
||||
"--spec-modules",
|
||||
default=None,
|
||||
help="Comma-separated spec modules (deps). Default: none.",
|
||||
help="Comma-separated spec modules (deps,engine). Default: none.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
adapters = args.adapters.split(",") if args.adapters else None
|
||||
|
||||
Reference in New Issue
Block a user