diff --git a/lib/hyperscript/compiler.sx b/lib/hyperscript/compiler.sx index e5329532..046cad78 100644 --- a/lib/hyperscript/compiler.sx +++ b/lib/hyperscript/compiler.sx @@ -1078,10 +1078,7 @@ (let ((params (map make-symbol (nth ast 1))) (body (hs-to-sx (nth ast 2)))) - (if - (= (len params) 0) - body - (list (quote fn) params body)))) + (list (quote fn) params body))) ((= head (quote me)) (quote me)) ((= head (quote beingTold)) (quote beingTold)) ((= head (quote it)) (quote it)) diff --git a/shared/static/wasm/sx/hs-compiler.sx b/shared/static/wasm/sx/hs-compiler.sx index e5329532..046cad78 100644 --- a/shared/static/wasm/sx/hs-compiler.sx +++ b/shared/static/wasm/sx/hs-compiler.sx @@ -1078,10 +1078,7 @@ (let ((params (map make-symbol (nth ast 1))) (body (hs-to-sx (nth ast 2)))) - (if - (= (len params) 0) - body - (list (quote fn) params body)))) + (list (quote fn) params body))) ((= head (quote me)) (quote me)) ((= head (quote beingTold)) (quote beingTold)) ((= head (quote it)) (quote it)) diff --git a/spec/tests/test-hyperscript-behavioral.sx b/spec/tests/test-hyperscript-behavioral.sx index fb539388..eed2aafc 100644 --- a/spec/tests/test-hyperscript-behavioral.sx +++ b/spec/tests/test-hyperscript-behavioral.sx @@ -3984,13 +3984,17 @@ ;; ── expressions/blockLiteral (4 tests) ── (defsuite "hs-upstream-expressions/blockLiteral" (deftest "basic block literals work" - (error "SKIP (untranslated): basic block literals work")) + (assert= (apply (eval-expr-cek (hs-to-sx (hs-compile "\\ -> true"))) (list)) true) + ) (deftest "basic identity works" - (error "SKIP (untranslated): basic identity works")) + (assert= (apply (eval-expr-cek (hs-to-sx (hs-compile "\\ x -> x"))) (list true)) true) + ) (deftest "basic two arg identity works" - (error "SKIP (untranslated): basic two arg identity works")) + (assert= (apply (eval-expr-cek (hs-to-sx (hs-compile "\\ x, y -> y"))) (list false true)) true) + ) (deftest "can map an array" - (error "SKIP (untranslated): 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)) + ) ) ;; ── expressions/boolean (2 tests) ── diff --git a/tests/playwright/generate-sx-tests.py b/tests/playwright/generate-sx-tests.py index cb575f94..d61ee950 100644 --- a/tests/playwright/generate-sx-tests.py +++ b/tests/playwright/generate-sx-tests.py @@ -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))', + ], }