Files
rose-ash/spec/tests/test-io-registry.sx
giles 33e8788781 Lambda→CEK dispatch: enable IO suspension through sx_call
Lambda calls in sx_call now go through the CEK machine instead of
returning a Thunk for the tree-walker trampoline. This lets perform/
IO suspension work everywhere — including hyperscript wait/bounce.

Key changes:
- sx_runtime: Lambda case calls _cek_eval_lambda_ref (forward ref)
- sx_vm: initializes ref with cek_step_loop + stub VM for suspension
- sx_apply_cek: VmSuspended → __vm_suspended marker dict (not exception)
- continue_with_call callable path: handles __vm_suspended with
  vm-resume-frame, matching the existing JIT Lambda pattern
- sx_render: let VmSuspended propagate through try_catch
- Remove invalid io-contract test (perform now suspends, not errors)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 16:19:30 +00:00

88 lines
2.3 KiB
Plaintext

;; IO registry tests — defio, *io-registry*, accessor functions, io contract
(defsuite
"io-registry-basic"
(deftest
"defio registers an IO operation"
(defio
"test-io-basic"
:category :data
:params ()
:returns "string"
:doc "Basic test op.")
(assert (io-registered? "test-io-basic")))
(deftest
"io-lookup returns spec dict"
(defio
"test-io-lookup"
:category :effect
:params (x)
:returns "nil"
:doc "Test effect.")
(let
((spec (io-lookup "test-io-lookup")))
(assert= (get spec "name") "test-io-lookup")
(assert= (keyword-name (get spec "category")) "effect")
(assert= (get spec "returns") "nil")
(assert= (get spec "doc") "Test effect.")))
(deftest
"io-registered? returns false for unknown"
(assert (not (io-registered? "nonexistent-io-op"))))
(deftest
"io-names includes registered ops"
(defio
"test-io-names"
:category :data
:params ()
:returns "any"
:doc "Names test.")
(assert (contains? (io-names) "test-io-names")))
(deftest
"defio returns the spec dict"
(let
((result (defio "test-io-ret" :category :code :params (a b) :returns "string" :doc "Return test.")))
(assert= (get result "name") "test-io-ret")
(assert= (keyword-name (get result "category")) "code"))))
(defsuite
"io-registry-kwargs"
(deftest
"defio parses batchable flag"
(defio
"test-io-batch"
:category :code
:params (code lang)
:returns "string"
:batchable true
:doc "Batchable op.")
(assert= (get (io-lookup "test-io-batch") "batchable") true))
(deftest
"defio parses cacheable flag"
(defio
"test-io-cache"
:category :data
:params ()
:returns "list"
:cacheable true
:doc "Cacheable op.")
(assert= (get (io-lookup "test-io-cache") "cacheable") true))
(deftest
"defio parses params list"
(defio
"test-io-params"
:category :data
:params (a b c)
:returns "list"
:doc "Multi param.")
(assert= (len (get (io-lookup "test-io-params") "params")) 3)))
(defsuite
"io-contract"
(deftest
"io rejects unregistered operations"
(let
((caught false))
(try-catch
(fn () (io "totally-unknown-op-xyz"))
(fn (err) (set! caught true)))
(assert caught))))