Three parts: (a) `runtime.sx` hs-hide-one!/hs-show-one! consult a new
`_hs-hide-strategies` dict (and `_hs-default-hide-strategy` override)
before falling through to the built-in display/opacity/etc. cases. The
strategy fn is called directly with (op, el, arg). New setters
`hs-set-hide-strategies!` and `hs-set-default-hide-strategy!`. (b)
`generate-sx-tests.py` `_hs_config_setup_ops` recognises
`_hyperscript.config.defaultHideShowStrategy = "X"`, `delete …default…`,
and `hideShowStrategies = { NAME: function (op, el, arg) { if …
classList.add/remove } }` with brace-matched function body extraction.
(c) Pre-setup emitter handles `__hs_config__` pseudo-name by emitting
the SX expression as-is (not a window.X = Y assignment).
Suite hs-upstream-hide: 12/16 → 15/16. Remaining test
(`hide element then show element retains original display`) needs
`on click 1 hide` / `on click 2 show` count-filtered events — separate
feature. Smoke 0-195: 162/195 unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mock `El` now exposes `dataset` as a Proxy that syncs property
writes back to `attributes["data-*"]`, and `setAttribute("data-*", ...)`
populates the backing dataset with camelCase key. That way
`#target.dataset.val = "new"` updates the `data-val` attribute,
letting the swap command read/write the property correctly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five parts: (a) tests/hs-run-filtered.js `io-wait-event` mock now
registers a one-shot listener on the target element and resumes with
the event, instead of immediately resuming with nil. (b) Added
hs-wait-for-or runtime form carrying a timeout-ms; mock resumes
immediately when a timeout is present (0ms tests). (c) parser
parse-wait-cmd recognises `wait for EV(v1, v2)` destructure syntax,
emits :destructure list on wait-for AST. (d) compiler emit-wait-for
updated for :from/:or combos; a new `__bind-from-detail__` form
compiles to `(define v (host-get (host-get it "detail") v))`, and the
`do`-sequence handler preprocesses wait-for to splice these synthetic
bindings after the wait. (e) generator extracts `detail: ...` from
`CustomEvent` options so dispatched events carry their payload.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Partial fix. The generator's block-form `evaluate(() => { ... })`
swallowed blocks that weren't window-setup assignments (e.g. `const e =
new Event(...); elem.dispatchEvent(e);`). It now only `continue`s when
at least one window-setup pair was parsed; otherwise falls through to
downstream patterns. Also added a new pattern that recognises the
`evaluate(() => { const e = new Event(...); document.querySelector(SEL)
.dispatchEvent(e); })` shape and emits a `dom-dispatch` op.
Still failing: "at start of", "in a element target", "in a symbol
write" — root cause here is that the inserted-button's hyperscript
handler still isn't activating in the afterbegin / innerHTML paths.
Tracked separately.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`\$window.foo` / `\${window.foo}` couldn't resolve. Two fixes:
(a) compiler.sx: in a dot-chain base position, known globals (window,
document, navigator, location, history, screen, localStorage,
sessionStorage, console) emit `(host-global "name")` instead of a
bare unbound symbol.
(b) generator: `eval-hs-locals` now also sets each binding on
`window.<name>` via `host-set!`, so tests that translated
`window.X = Y` as a local pair still see `window.X` at eval time.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`some <html/>` compiles to (not (hs-falsy? (hs-query-first "html"))), which
called document.querySelector('html'). The mock's querySelector searched
only inside _body, so the html element wasn't found. Adjusted the mock to
return _html for the 'html' selector (and walk documentElement too).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds an `outerHTML` getter to the mock `El` class. Builds `<tag attrs>inner</tag>`
by merging `.id` / `.className` (set as direct properties via host-set!) with
the `.attributes` bag, and falling back to `innerText` / `textContent` when
there are no children or innerHTML.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Upstream body helpers often call element methods directly — showModal,
close, focus, blur, reset, remove. Emit dom-dispatch or host-call ops so
tests that rely on these pre-click state changes work.
Net: dialog 9→12 (100%).
Mock DOM:
- El now tracks defaultValue/defaultChecked/defaultSelected and a reset()
method that walks descendant form controls, restoring them.
- setAttribute(value|checked|selected) sets the matching default-* too, so
the initial HTML state can be restored later.
- parseHTMLFragments + _setInnerHTML capture a textarea's textContent as
its value AND defaultValue.
Generator (pw-body):
- add_action / add_assertion extract .first() / .last() / .nth(N) modifiers
into (nth (dom-query-all …) i) or a (let ((_all …)) (nth _all (- … 1)))
tail so multi-match helpers hit the right element.
Compiler:
- emit-reset! with a .<class>/.<sel> query target now compiles to hs-query-all
so 'reset .resettable' resets every matching control (not just the first).
Net: reset 1→8 (100%).
Upstream tests use clickAndReadStyle(evaluate, sel, prop) to click-and-read
before asserting toHaveCSS(sel, prop, val). Emit just the click — downstream
toHaveCSS checks then test the post-click state. Net: transition 6→13.
- tokenizer: add 'giving' as keyword so parse-take-cmd can detect it.
- parser.sx parse-take-cmd: loop over 'with <class>' / 'giving <class>' /
'from <sel>' / 'for <tgt>' clauses in any order for both the class and
attribute cases. Emits uniform (take! kind name from-sel for-tgt
attr-val with-val) 7-slot AST.
- compiler emit-take: pass with-cls for the class case through to runtime.
- runtime hs-take!: with a class 'with' replacement, toggle both classes
across scope + target. For attribute take, always strip the attr from
the scope 'others' (setting to with-val if given, otherwise removing).
- generator pw-body: translate evaluate(() => document.querySelector(s).
click()) and .dispatchEvent(new Event('name', …)) into dom-dispatch ops
so bubbling-click assertions in 'parent takes…' tests work.
- generator toHaveClass: strip JS regex word-boundaries (\\b) from the
expected class name.
- shared/static/wasm/sx/dom.sx: dom-child-list / dom-child-nodes mirror
the dom-query-all SX-list passthrough — childNodes arrives pre-SXified.
Net: take 6→15 (100%), remove 16→17, fetch 11→15.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- generate-sx-tests.py: add_action/add_assertion accept .nth(N) in PW-body
tests so 'find(sel).nth(1).dispatchEvent(...)' lands as a dispatch on
the Nth matching element, and assertions target that same element.
- shared/static/wasm/sx/dom.sx: dom-query-all hands through an already-SX
list unchanged — the bridge often pre-converts NodeLists/arrays to SX
lists, so the host-get 'length' / host-call 'item' loop was returning
empty. Guards node-list=nil and non-list types too.
- tests/hs-run-filtered.js (mock DOM): fnd() understands
':nth-of-type(N)', ':first-of-type', ':last-of-type' by matching the
stripped base selector and returning the correct-indexed sibling.
Covers upstream tests that write 'find("div:nth-of-type(2)")' to
pick the HS-owning element.
- Runtime runtime.sx: hs-sorted-by, hs-fetch format normalizer (JSON/
Object/etc.), nil-safe hs-joined-by/hs-split-by, emit-fetch chain sets
the-result when wrapped in let((it …)).
Net: take 0→6, hide 11→12, show 15→16, fetch 11→15,
collectionExpressions 13→15 (remaining are a WASM JIT bug on
{…} literals inside arrays).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Runtime (lib/hyperscript/ + shared/static/wasm/sx/hs-*.sx):
- make: parser accepts `<tag.class#id/>` selectors and `from <expr>,…`; compiler
emits via scoped-set so `called <name>` persists; `called $X` lands on
window; runtime dispatches element vs host-new constructor by type.
- Values: `x as Values` walks form inputs/selects/textareas, producing
{name: value | [value,…]}; duplicates promote to array; multi-select and
checkbox/radio handled.
- toggle *display/*visibility/*opacity: paired with sensible inline defaults
in the mock DOM so toggle flips block/visible/1 ↔ none/hidden/0.
- add/remove/put at array: emit-set paths route list mutations back through
the scoped binding; add hs-put-at! / hs-splice-at! / hs-dict-without.
- remove OBJ.KEY / KEY of OBJ: rebuild dict via hs-dict-without and reassign,
since SX dicts are copy-on-read across the bridge.
- dom-set-data: use (host-new "Object") rather than (dict) so element-local
storage actually persists between reads.
- fetch: hs-fetch normalizes JSON/Object/Text/Response format aliases;
compiler sets `the-result` when wrapping a fetch in the `let ((it …))`
chain, and __get-cmd shares one evaluation via __hs-g.
Mock DOM (tests/hs-run-filtered.js):
- parseHTMLFragments accepts void elements (<input>, <br>, …);
- setAttribute tracks name/type/checked/selected/multiple;
- select.options populated on appendChild;
- insertAdjacentHTML parses fragments and inserts real El children into the
parent so HS-activated handlers attach.
Generator (tests/playwright/generate-sx-tests.py):
- process_hs_val strips `//` / `--` line comments before newline→then
collapse, and strips spurious `then` before else/end/catch/finally.
- parse_dev_body interleaves window-setup ops and DOM resets between
actions/assertions; pre-html setups still emit up front.
- generate_test_pw compiles any `<script type=text/hyperscript>` (flattened
across JS string-concat) under guard, exposing def blocks.
- Ordered ops for `run()`-style tests check window.obj.prop via new
_js_window_expr_to_sx; add DOM-constructing evaluate + _hyperscript
pattern for `as Values` tests (result.key[i].toBe(…)).
- js_val_to_sx handles backticks and escapes embedded quotes.
Net delta across suites:
- if 16→18, make 0→8, toggle 12→21, add 9→10, remove 11→16, put 29→31,
fetch 11→15, repeat 14→26, expressions/asExpression 20→25, set 27→28,
core/scoping 12→14, when 39→39 (no regression).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
process_hs_val replaces newlines with `then` to give the HS parser a
statement separator, but `else then` and `catch foo then` are syntax
errors — `else` and `catch <name>` already open new blocks. Strip the
inserted `then` after them so multi-line if/try parses cleanly.
No net pass-count delta on smoke-tested suites (the if-with-window-state
tests fail for a separate reason: window setups all run before any click
rather than being interleaved with state changes), but the source now
parses correctly and matches what upstream HS sees.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three related changes for the `evaluate(() => window.X = Y)` setup pattern:
1. extract_window_setups now also matches the single-expression form
`evaluate(() => window.X = Y)` (no braces), in addition to the
block form `evaluate(() => { window.X = Y; ... })`.
2. js_expr_to_sx now recognises `function(args) { return X; }` (and
`function(args) { X; }`) in addition to arrow functions, so e.g.
`window.select2 = function(){ return "select2"; }` translates to
`(fn () "select2")`.
3. generate_test_chai / generate_test_pw (HTML+click test generators)
inject `(host-set! (host-global "window") "X" <sx>)` for each window
setup found in the test body, so HS code that reads `window.X` sees
the right value at activation time.
4. Test-helper preamble now defines `window` and `document` as
`(host-global "window")` / `(host-global "document")`, so HS
expressions like `window.tmp` resolve through the host instead of
erroring on an unbound `window` symbol.
Net effect on suites smoke-tested: nominal, because most affected tests
hit a separate `if/then/else` parser bug — the `then` keyword inserter
in process_hs_val turns multi-line if blocks into ones the HS parser
collapses to "always run the body". Fixing that is the next iteration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pattern 2's `parse_run_locals` only looked for `, {locals: {...}}`. Tests
that pass `me:` directly (e.g. `run("my foo", { me: { foo: "foo" } })`)
got an empty locals list, so `my foo` lost its receiver and returned
nothing. Now `me:` (object/array/string/number literal) is also bound
as a local on top of any `locals: {}`.
possessiveExpression 18/23 → 19/23 ("can access my properties").
"can access its properties" still fails because the upstream test passes
`result:` rather than `it:` — appears to be an upstream typo we'd need
the runtime to special-case to fix.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two related Pattern 1 bugs:
1. The locals capture used `\\{([^}]+)\\}` (greedy non-`}` chars), so
`locals: { that: [1, 2, 3] }` truncated at the first `,` inside `[...]`
and bound `that` to `"[1"`. Switched to balanced-brace extraction +
`split_top_level` so nested arrays/objects survive.
2. `{ me: <X> }` was only forwarded to the SX runtime when X was a single
integer (eval-hs-with-me only accepts numbers). For `me: [1, 2, 3]`
or `me: 1` alongside other locals, `me` was silently dropped, so
`I contain that` couldn't see its receiver. Now any non-numeric `me`
value is bound as a local (`(list (quote me) <val>)`); a numeric
`me` alongside other locals/setups is also bound, so the HS expr
always sees its `me`.
comparisonOperator 79/83 → 81/83 (+2: contains/includes works with arrays).
bind unchanged (43/44).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pattern 2 was binding all `expect(result)` assertions in a body to the
*first* `run()`, even when the body re-assigned `result` between checks:
let result = await run("'10' as Float") expect(result).toBe(10)
result = await run("'10.4' as Float") expect(result).toBe(10.4)
Both assertions ran against `'10' as Float`, so half failed. Now the
generator walks `run()` calls in order, parses per-call `{locals: {...}}`
opts (balanced-brace, with the closing `\)` anchoring the lazy quote
match), and pairs each `expect(result)` with the most recent preceding
run.
asExpression 15/42 → 19/42 (+4: as Float / Number / String / Fixed sub-
assertions now check the right expression). Other suites unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Parser (lib/hyperscript/parser.sx):
- parse-poss case for "(" (function call) was building (call ...) and
returning without recursing, so `f().x` lost the `.x` suffix and the
compiler emitted (let ((it (f))) (hs-query-first ".x")). Now it tail-
calls parse-poss on the constructed call so chains like f().x.y(),
obj.method().prop, etc. parse correctly.
Generator (tests/playwright/generate-sx-tests.py):
- New js_expr_to_sx: translates arrow functions ((args) => body), object
literals, simple property access / method calls / arith. Falls back
through js_val_to_sx for primitives.
- New extract_window_setups: scans `evaluate(() => { window.X = Y })`
blocks (with balanced-brace inner-body extraction) and returns
(name, sx_value) pairs.
- Pattern 1 / Pattern 2 in generate_eval_only_test merge those window
setups into the locals passed to eval-hs-locals, so HS expressions
can reference globals defined by the test prelude.
- Object literal value parsing now goes through js_expr_to_sx first,
so `{x: x, y: y}` yields `{:x x :y y}` (was `{:x "x" :y "y"}`).
Net: hs-upstream-expressions/functionCalls 0/12 → 5/12 (+5).
Smoke-checked put/set/scoping/possessiveExpression — no regressions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Generator changes (tests/playwright/generate-sx-tests.py):
- toHaveCSS regex: balance parens so `'rgb(255, 0, 0)'` is captured intact
(was truncating at first `)`)
- Map browser-computed colors `rgb(R,G,B)` back to CSS keywords
(red/green/blue/black/white) — our DOM mock returns the inline value
- js_val_to_sx now handles object literals `{a: 1, b: {c: 2}}` → `{:a 1 :b {:c 2}}`
- Pattern 2 (`var x = await run(...)`) now captures locals via balanced-brace
scan and emits `eval-hs-locals` instead of `eval-hs`
- Pattern 1 with locals: emit `eval-hs-locals` (was wrapping in `let`, which
doesn't reach the inner HS env)
- Stop collapsing `\"` → `"` in raw HTML (line 218): the backslash escapes
are legitimate in single-quoted `_='...'` HS attribute values containing
nested HS scripts
Test-framework changes (regenerated into spec/tests/test-hyperscript-behavioral.sx):
- `_hs-wrap-body`: returns expression value if non-nil, else `it`. Lets bare
expressions (`foo.foo`) and `it`-mutating scripts (`pick first 3 of arr;
set $test to it`) both round-trip through the same wrapper
- `eval-hs-locals` now injects locals via `(let ((name (quote val)) ...) sx)`
rather than `apply handler (cons nil vals)` — works around a JIT loop on
some compiled forms (e.g. `bar.doh of foo` with undefined `bar`)
Also synced lib/hyperscript/*.sx → shared/static/wasm/sx/hs-*.sx (the WASM
test runner reads from the wasm/sx/ copies).
Net per-cluster pass counts (vs prior baseline):
- put: 23 → 29 (+6)
- set: 21 → 28 (+7)
- show: 7 → 15 (+8)
- expressions/propertyAccess: 3 → 9 (+6)
- expressions/possessiveExpression: 17 → 18 (+1)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Several upstream regex-pick tests use JS ES6 shorthand to pass a
local declared earlier in the test body, e.g.
const haystack = "..."
await run(\`pick match of "\\\\d+" from haystack ...\`, {locals: {haystack}});
The generator's `(\\w+)\\s*:\\s*...` locals regex only matched explicit
`key: value` entries, so `{haystack}` produced zero local_pairs and the
HS script failed with "Undefined symbol: haystack". Now a second pass
scans for bare identifiers in the locals object and resolves each
against a preceding `const NAME = VALUE;` in the test body.
Net test-count is unchanged (the affected regex tests still fail — now
with TIMEOUT in the regex engine rather than Undefined-symbol, so this
just moves them closer to real coverage).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Tests using `run("expr", {locals: {x}})` were being translated to SX like
(let ((x val)) (eval-hs "expr") (assert= it EXPECTED))
That never worked: `it` is bound inside eval-hs's handler closure, not in
the outer SX scope, so the assertion errored "Undefined symbol: it".
Meanwhile `x` (bound by the outer let) wasn't reachable from the
eval-expr-cek'd handler either, so any script referencing `x` resolved
via global lookup — silently yielding stale values from earlier tests.
New `eval-hs-locals` helper injects locals as fn parameters of the
handler wrapper:
(fn (me arr str ...) (let ((it nil) (event nil)) <compiled-hs> it))
It's applied with the caller's values, returning the final `it`. The
generator now emits `(assert= (eval-hs-locals "..." (list ...)) EXP)`
for all four expect() patterns when locals are present.
New baseline: 1,055 / 1,496 pass (70.5%, up from 1,022 / 1,496 = 68.3%).
29 additional tests now pass — mostly `pick` (where locals are the
vehicle for passing arr/str test fixtures) plus cascades in
comparisonOperator, asExpression, mathOperator, etc.
Note: the remaining `pick` wins in this batch also depend on local
edits to lib/hyperscript/parser.sx and compiler.sx (not included here;
they're intertwined with pre-existing in-flight HS runtime work).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Pattern 1c emitter wrote `;; TODO: assert= ... against {...}` for
object-literal .toEqual() assertions it couldn't translate. It only
.strip()'d the literal, leaving internal newlines intact — so a
multi-line `{...}` leaked SX-invalid text onto subsequent lines and
broke the parse for the rest of the suite.
Collapse all whitespace inside the literal so the `;;` prefix covers the
whole comment.
After regenerating, 1,022/1,496 pass (was 1,013/1,496 with a hand-
patched behavioral.sx). No runtime changes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- scrape-hs-upstream.py: new scraper walks /tmp/hs-upstream/test/**/*.js
and emits body-style records for all 1,496 v0.9.90 tests (up from 831).
Widens coverage into 66 previously-missing categories — templates,
reactivity, behavior, worker, classRef, make, throw, htmx, tailwind,
viewTransition, and more.
- build-hs-manifest.py + hyperscript-upstream-manifest.{json,md}:
coverage manifest tagging each upstream test with a status
(runnable / skip-listed / untranslated / missing) and block reason.
- generate-sx-tests.py: emit (error "SKIP (...)") instead of silent
(hs-cleanup!) no-op for both skip-listed tests and generator-
untranslatable bodies. Stub counter now reports both buckets.
- hyperscript-feature-audit-0.9.90.md: gap audit against the 0.9.90
spec; pre-0.9.90.json backs up prior 831-test snapshot.
New honest baseline (ocaml runner, test-hyperscript-behavioral):
831 -> 1,496 tests; 645 -> 1,013 passing (67.7% conformance).
483 failures split: 45 skip-list, 151 untranslated, 287 real.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- parser `empty` no-target → (ref "me") (was bogus (sym "me"))
- parser `halt` modes distinguish: "all"/"bubbling"/"default" halt execution
(raise hs-return), "the-event"/"the event's" only stop propagation/default.
"'s" now matched as op token, not keyword.
- parser `get` cmd: dispatch + cmd-kw list + parse-get-cmd (parses expr with
optional `as TYPE`). Required for `get result as JSON` in fetch chains.
- compiler empty-target for (local X): emit (set! X (hs-empty-like X)) so
arrays/sets/maps clear the variable, not call DOM empty on the value.
- runtime hs-empty-like: container-of-same-type empty value.
- runtime hs-empty-target!: drop dead FORM branch that was short-circuiting
to innerHTML=""; the querySelectorAll-over-inputs branch now runs.
- runtime hs-halt!: take ev param (was free `event` lookup); raise hs-return
to stop execution unless mode is "the-event".
- runtime hs-reset!: type-aware — FORM → reset, INPUT/TEXTAREA → value/checked
from defaults, SELECT → defaultSelected option.
- runtime hs-open!/hs-close!: toggle `open` attribute on details elements
(not just the prop) so dom-has-attr? assertions work.
- runtime hs-coerce JSON: json-stringify dict/list (was str).
- test-runner mock: host-get on List + "length"/"size" (was only Dict);
dom-set-attr tracks defaultChecked / defaultSelected / defaultValue;
mock_query_all supports comma-separated selector groups.
- generator: emit boolean attrs (checked/selected/etc) even with null value;
drop overcautious "skip HS with bare quotes or embedded HTML" guard so
morph tests (source contains embedded <div>) emit properly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Tests with _=\"...\" attribute delimiters were garbled because
HTMLParser interpreted the backslash-quote as content, not delimiters.
Now html.replace('\"', '"') normalizes before parsing.
Fixes ~15 tests across toggle, transition, and other categories
that were previously running with corrupted HS source.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Parser:
- Relax (number? v) to v in parse-one-transition so (expr)unit works
- Add (match-kw "then") before parse-cmd-list in parse-for-cmd
- Handle "indexed by" syntax alongside "index" in for loops
- Add "indexed" to hs-keywords to prevent unit-suffix consumption
Compiler:
- Use map-indexed instead of for-each for indexed for-loops
Test generator:
- Preserve \" escapes in process_hs_val via placeholder/restore
Mock DOM:
- Coerce insertAdjacentHTML values via dom_stringify (match browser)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Parser: fetch command consumes {method:"POST"}, with {opts}, and
handles as-format both before and after options.
Mock: Number format case-insensitive, /test route has number field.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Compiler: do-blocks now compile to (let ((it cmd1)) (let ((it cmd2)) ...))
instead of (do cmd1 cmd2 ...). This chains the `it` variable through
command sequences, enabling `fetch X then put it into me` pattern.
Each command's result is bound to `it` for the next command.
Runtime: hs-fetch simplified to single perform (io-fetch url format)
instead of two-stage io-fetch + io-parse-text/json.
Parser: fetch URL /path handled by reading /+ident tokens.
Default fetch format changed to "text" (was "json").
Test runner: mock fetch routes with format-specific responses.
io-fetch handler returns content directly based on format param.
Fetch tests still need IO suspension to chain through let continuations.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Parser: handle /path URLs in fetch command by reading /+ident tokens.
Test runner: mock fetch routes (/test→yay, /test-json→{"foo":1}),
io-parse-text, io-parse-json, io-parse-html handlers in _driveAsync.
Fetch tests still fail (0/23) because the do-block halts after
hs-fetch's perform suspension — the CEK machine doesn't continue
to the next command (put it into me) after IO resume. This needs
the IO suspension model to properly chain do-block continuations.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Higher limits (500K, 1M) recover repeat tests but make on-suite
tests run 6-15s each, causing batch timeouts. The IO suspension
kernel needs to be fixed to use fewer steps, not worked around
with higher limits.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Compiler: return compiles to (raise (list "hs-return" value))
- Compiler: def wraps body in guard to catch hs-return exceptions
- Compiler: def params extract name from (ref name) nodes
- Test generator: extract <script type="text/hyperscript"> blocks
and compile def functions as setup before tests
- Test generator: add eval-hs-with-me for {me: N} opts
The return mechanism enables repeat-forever with early exit via return.
Direct SX guard/raise works (returns correct value), but the compiled
HS repeat-forever thunk body needs further debugging for full coverage.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Handle result["foo"] and result.foo property access after eval-hs
- Handle { locals: { x: 5, y: 5 } } opts with nested braces
- Handle { me: N } opts via eval-hs-with-me helper
- Add eval-hs-with-me to test framework for "I am between" tests
- Use host-get for property access on host handles (JSON.parse results)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Parser: skip unit suffix when next ident is a comparison keyword
(starts, ends, contains, matches, is, does, in, precedes, follows).
Fixes "123 starts with '12'" returning "123starts" instead of true.
eval-hs: use hs-compile directly instead of hs-to-sx-from-source with
"return " prefix, which was causing the parser to consume the comparison
as a string suffix.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- eval-hs: new test helper that compiles+evaluates a HS expression and
returns its result. Uses hs-to-sx-from-source with "return " prefix.
- Generator now emits eval-hs calls for expression-only tests
- no suite: 4/5 pass (was 0/5)
- evalStatically: 5/8 pass (was 0/8 stubs)
- pick: 7/7 pass (was 0/7 stubs)
- mathOperator: 3/5 pass (type issues on array concat)
477/831 (57.4%), +69 from session baseline of 408.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Parser now handles 'does not start with' and 'does not end with'
comparison operators, compiling to (not (starts-with? ...)) and
(not (ends-with? ...)) respectively.
Test runner: host-set!/host-get stringify innerHTML/textContent.
437/831 (52.6%) — parser fix doesn't change count yet (comparison tests
use 'is a' type checks which need separate fix).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
host-set! now stringifies values for innerHTML/textContent properties.
host-get returns string for innerHTML/textContent/value/className.
Fixes "Expected X, got X" type mismatch failures where number 22 != string "22".
437/831 (52.6%), +20 tests from stringify fix.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- sx_vm.ml: VM timeout now compares vm_insn_count > step_limit instead of
unconditionally throwing after 65536 instructions when limit > 0
- sx_browser.ml: Expose setStepLimit/resetStepCount APIs on SxKernel;
callFn now returns {__sx_error, message} on Eval_error instead of null
- compiler.sx: emit-set handles array-index targets (host-set! instead of
nth) and 'of' property chains (dom-set-prop with chain navigation)
- hs-run-fast.js: New Node.js test runner with step-limit timeouts,
SX-level guard for error detection, insertAdjacentHTML mock,
range selection (HS_START/HS_END), wall-clock timeout in driveAsync
- hs-debug-test.js: Single-test debugger with DOM state inspection
- hs-verify.js: Assertion verification (proves pass/fail detection works)
Test results: 415/831 (50%), up from 408/831 (49%) baseline.
Fixes: set my style["color"], set X of Y, put at end of (insertAdjacentHTML).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- parse_html now captures ALL elements (not just top-level) with
parent-child relationships
- emit_element_setup uses three phases: attributes, DOM tree, activation
- ref() maps positional names (d1, d2) to top-level elements only
- dom-scope: 9→14 (+5), reset: 3→6 (+3), take: 2→3, parser: 2→3
Net 0 due to regressions in dialog/halt/closest (needs investigation).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Don't insert 'then' inside for-in loop bodies or after 'repeat N times'
(fixes repeat from 1/30 → 5/30)
- Allow HS sources ending with " when they don't contain embedded HTML
(fixes set from 6/25 → 10/25, enables 18 previously-skipped tests)
- Fix assert= argument order: (actual expected), not (expected actual)
(error messages now correctly report Expected/Got)
395 → 402/831 (+7)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>