HS: ask/answer + prompt/confirm mock (+4 tests)
Wire up the `ask` and `answer` commands end-to-end:
- tokenizer.sx: register `ask` and `answer` as hs-keywords.
- parser.sx: cmd-kw? gains both; parse-cmd dispatches to new
parse-ask-cmd (emits `(ask MSG)`) and parse-answer-cmd, which
reads `answer MSG [with YES or NO]`. The with/or pair reads
yes/no via parse-atom — parse-expr would collapse
`"Yes" or "No"` into `(or "Yes" "No")` before match-kw "or"
could fire. The no-`with` form emits `(answer-alert MSG)`.
- compiler.sx: three new cond branches (ask, answer, answer-alert)
compile to a let that binds __hs-a, sets `the-result` and `it`,
and returns the value — so `then put it into ...` works.
- runtime.sx: hs-ask / hs-answer / hs-answer-alert call
window.prompt / confirm / alert via host-call + host-global.
- tests/hs-run-filtered.js: test-name-keyed globalThis.{alert,
confirm,prompt}; __currentHsTestName is updated before each
test. Host-set! for innerHTML/textContent now coerces JS
null → "null" (browser behaviour) so `prompt → null` →
`put it into #out` renders literal text "null", which the
fourth test depends on.
Suite hs-upstream-askAnswer: 1/5 -> 5/5.
Smoke 0-195: 166/195 -> 170/195.
This commit is contained in:
@@ -4,10 +4,10 @@ Live tally for `plans/hs-conformance-to-100.md`. Update after every cluster comm
|
||||
|
||||
```
|
||||
Baseline: 1213/1496 (81.1%)
|
||||
Merged: 1260/1496 (84.2%) delta +47
|
||||
Merged: 1264/1496 (84.5%) delta +51
|
||||
Worktree: all landed
|
||||
Target: 1496/1496 (100.0%)
|
||||
Remaining: ~236 tests
|
||||
Remaining: ~232 tests
|
||||
```
|
||||
|
||||
## Cluster ledger
|
||||
@@ -53,7 +53,7 @@ Remaining: ~236 tests
|
||||
|---|---------|--------|---|--------|
|
||||
| 26 | resize observer mock + `on resize` | done | +3 | 304a52d2 |
|
||||
| 27 | intersection observer mock + `on intersection` | done | +3 | 0c31dd27 |
|
||||
| 28 | `ask`/`answer` + prompt/confirm mock | pending | (+4 est) | — |
|
||||
| 28 | `ask`/`answer` + prompt/confirm mock | done | +4 | SHA-PENDING |
|
||||
| 29 | `hyperscript:before:init` / `:after:init` / `:parse-error` | pending | (+4–6 est) | — |
|
||||
| 30 | `logAll` config | done | +1 | 64bcefff |
|
||||
|
||||
@@ -87,7 +87,7 @@ Defer until A–D drain. Estimated ~25 recoverable tests.
|
||||
|--------|-----:|--------:|--------:|--------:|--------:|------------:|------:|
|
||||
| A | 12 | 4 | 0 | 0 | 1 | — | 17 |
|
||||
| B | 5 | 0 | 0 | 1 | 1 | — | 7 |
|
||||
| C | 3 | 0 | 0 | 2 | 0 | — | 5 |
|
||||
| C | 4 | 0 | 0 | 1 | 0 | — | 5 |
|
||||
| D | 0 | 0 | 0 | 5 | 0 | — | 5 |
|
||||
| E | 0 | 0 | 0 | 0 | 0 | 5 | 5 |
|
||||
| F | — | — | — | ~10 | — | — | ~10 |
|
||||
|
||||
@@ -107,7 +107,7 @@ Orchestrator cherry-picks worktree commits onto `architecture` one at a time; re
|
||||
|
||||
27. **[done (+3)] intersection observer mock + `on intersection`** — 3 tests. Mock `IntersectionObserver`; compile `on intersection` with margin/threshold modifiers. Expected: +3.
|
||||
|
||||
28. **[pending] `ask`/`answer` + prompt/confirm mock** — `askAnswer` 4 tests. **Requires test-name-keyed mock**: first test wants `confirm → true`, second `confirm → false`, third `prompt → "Alice"`, fourth `prompt → null`. Keyed via `_current-test-name` in the runner. Expected: +4.
|
||||
28. **[done (+4)] `ask`/`answer` + prompt/confirm mock** — `askAnswer` 4 tests. **Requires test-name-keyed mock**: first test wants `confirm → true`, second `confirm → false`, third `prompt → "Alice"`, fourth `prompt → null`. Keyed via `_current-test-name` in the runner. Expected: +4.
|
||||
|
||||
29. **[pending] `hyperscript:before:init` / `:after:init` / `:parse-error` events** — 6 tests in `bootstrap` + `parser`. Fire DOM events at activation boundaries. Expected: +4-6.
|
||||
|
||||
@@ -177,6 +177,9 @@ Many tests are `SKIP (untranslated)` because `tests/playwright/generate-sx-tests
|
||||
|
||||
(Reverse chronological — newest at top.)
|
||||
|
||||
### 2026-04-24 — cluster 28 ask/answer + prompt/confirm mock
|
||||
- **SHA-PENDING** — `HS: ask/answer + prompt/confirm mock (+4 tests)`. Five-part change: (a) `tokenizer.sx` registers `ask` and `answer` as hs-keywords. (b) `parser.sx` — `cmd-kw?` gains both, `parse-cmd` gains cond branches dispatching to new `parse-ask-cmd` (emits `(ask MSG)`) and `parse-answer-cmd` which reads `answer MSG [with YES or NO]` with `parse-atom` for the choices (using `parse-expr` there collapsed `"Yes" or "No"` into `(or "Yes" "No")` before `match-kw "or"` could fire — parse-atom skips the logical layer). No-`with` form emits `(answer-alert MSG)`. (c) `compiler.sx` — three new cond branches (`ask`, `answer`, `answer-alert`) compile to `(let ((__hs-a (hs-XXX ...))) (begin (set! the-result __hs-a) (set! it __hs-a) __hs-a))` so `then put it into …` works. (d) `runtime.sx` — `hs-ask`, `hs-answer`, `hs-answer-alert` call `window.prompt`/`confirm`/`alert` via `host-call (host-global "window") …`. (e) `tests/hs-run-filtered.js` — test-name-keyed stubs for `globalThis.{alert,confirm,prompt}`, `__currentHsTestName` updated before each test. One extra tweak: `host-set!` innerHTML/textContent now coerces JS `null` → the string `"null"` (matching browser behaviour) so `prompt` returning null → `put it into #out` renders literal `"null"` text — the fourth test depends on exactly this. Suite hs-upstream-askAnswer: 1/5 → 5/5. Smoke 0-195: 166/195 → 170/195.
|
||||
|
||||
### 2026-04-24 — cluster 25 parenthesized commands and features
|
||||
- **d7a88d85** — `HS: parenthesized commands and features (+1 test)`. Parser-only fix in `lib/hyperscript/parser.sx`. Three additions: (a) `parse-feat` gets a new cond branch — on `paren-open`, advance, recurse `parse-feat`, consume `paren-close`; lets features like `(on click ...)` be grouped. (b) `parse-cmd` gets two new cond branches — on `paren-close` return nil (so `cl-collect` terminates when the outer paren group ends), and on `paren-open` advance+recurse+close (parenthesized single commands like `(log me)`). (c) The key missing piece: `cl-collect` previously only recursed when the next token was a recognised command keyword (`cmd-kw?`), so after the first `(log me)` the next `(trigger foo)` would end the body. Extended the recursion predicate to also fire when the next token is `paren-open`. Result: `on click (log me) (trigger foo)` now emits both commands inside the handler body, not the second as a sibling top-level feature. Suite hs-upstream-core/parser: 9/14 → 10/14. Smoke 0-195: 165/195 → 166/195.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user