HS: block literals callable as zero-arg lambdas (+4 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 17s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 17s
Fix compiler: (block-literal () body) was emitting bare body instead of (fn () body). Now always wraps in fn regardless of param count. Generator: MANUAL_TEST_BODIES for all 4 blockLiteral tests using apply and SX map rather than JS array.map. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -164,6 +164,19 @@ MANUAL_TEST_BODIES = {
|
||||
' (assert (string-contains? caught "worker plugin"))',
|
||||
' (assert (string-contains? caught "hyperscript.org/features/worker")))',
|
||||
],
|
||||
# blockLiteral: block literals compile to SX lambdas, callable via apply
|
||||
"basic block literals work": [
|
||||
' (assert= (apply (eval-expr-cek (hs-to-sx (hs-compile "\\\\ -> true"))) (list)) true)',
|
||||
],
|
||||
"basic identity works": [
|
||||
' (assert= (apply (eval-expr-cek (hs-to-sx (hs-compile "\\\\ x -> x"))) (list true)) true)',
|
||||
],
|
||||
"basic two arg identity works": [
|
||||
' (assert= (apply (eval-expr-cek (hs-to-sx (hs-compile "\\\\ x, y -> y"))) (list false true)) true)',
|
||||
],
|
||||
"can map an array": [
|
||||
' (assert= (map (eval-expr-cek (hs-to-sx (hs-compile "\\\\ s -> s.length"))) (list "a" "ab" "abc")) (list 1 2 3))',
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user