diff --git a/spec/tests/test-hyperscript-behavioral.sx b/spec/tests/test-hyperscript-behavioral.sx index 1f436a6b..e7124539 100644 --- a/spec/tests/test-hyperscript-behavioral.sx +++ b/spec/tests/test-hyperscript-behavioral.sx @@ -16,6 +16,15 @@ (fn () (dom-set-inner-html (dom-body) ""))) +;; Evaluate a hyperscript expression and return its result. +;; Compiles the expression, wraps in a thunk, evaluates, returns result. +(define eval-hs + (fn (src) + (let ((sx (hs-to-sx-from-source (str "return " src)))) + (let ((handler (eval-expr-cek + (list (quote fn) (list (quote me)) (list (quote let) (list (list (quote it) nil) (list (quote event) nil)) sx))))) + (handler nil))))) + ;; ── add (19 tests) ── (defsuite "hs-upstream-add" (deftest "can add class ref on a single div" diff --git a/tests/playwright/generate-sx-tests.py b/tests/playwright/generate-sx-tests.py index 171ced32..aff8f290 100644 --- a/tests/playwright/generate-sx-tests.py +++ b/tests/playwright/generate-sx-tests.py @@ -874,6 +874,15 @@ output.append('(define hs-cleanup!') output.append(' (fn ()') output.append(' (dom-set-inner-html (dom-body) "")))') output.append('') +output.append(';; Evaluate a hyperscript expression and return its result.') +output.append(';; Compiles the expression, wraps in a thunk, evaluates, returns result.') +output.append('(define eval-hs') +output.append(' (fn (src)') +output.append(' (let ((sx (hs-to-sx-from-source (str "return " src))))') +output.append(' (let ((handler (eval-expr-cek') +output.append(' (list (quote fn) (list (quote me)) (list (quote let) (list (list (quote it) nil) (list (quote event) nil)) sx)))))') +output.append(' (handler nil)))))') +output.append('') # Group by category categories = OrderedDict()