Inline test runner: 5/5 temperature converter tests passing
Fixed three fundamental issues: 1. cek-try arg passing: handler was called with raw string instead of (List [String msg]), causing "lambda expects 1 args, got N" errors 2. Silent island hydration failures: hydrate-island now wraps body render in cek-try, displaying red error box with stack trace instead of empty div. No more silent failures. 3. swap! thunk leak: apply result wasn't trampolined, storing thunks as signal values instead of evaluated results Also fixed: assert= uses = instead of equal? for value comparison, assert-signal-value uses deref instead of signal-value, HTML entity decoding in script tag test source via host-call replaceAll. Temperature converter demo page now shows live test results: ✓ initial celsius is 20 ✓ computed fahrenheit = celsius * 1.8 + 32 ✓ +5 increments celsius ✓ fahrenheit updates on celsius change ✓ multiple clicks accumulate 1116/1116 OCaml tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -65,7 +65,18 @@ let make_test_env () =
|
||||
ignore (Sx_types.env_bind env name (NativeFn (name, fn)))
|
||||
in
|
||||
|
||||
(* --- 5 platform functions required by test-framework.sx --- *)
|
||||
(* --- platform functions required by test-framework.sx --- *)
|
||||
|
||||
bind "cek-try" (fun args ->
|
||||
match args with
|
||||
| [thunk; handler] ->
|
||||
(try Sx_ref.cek_call thunk Nil
|
||||
with Eval_error msg -> Sx_ref.cek_call handler (List [String msg]))
|
||||
| [thunk] ->
|
||||
(try let r = Sx_ref.cek_call thunk Nil in
|
||||
List [Symbol "ok"; r]
|
||||
with Eval_error msg -> List [Symbol "error"; String msg])
|
||||
| _ -> Nil);
|
||||
|
||||
bind "try-call" (fun args ->
|
||||
match args with
|
||||
|
||||
@@ -389,7 +389,7 @@ let setup_evaluator_bridge env =
|
||||
match args with
|
||||
| [thunk; handler] ->
|
||||
(try Sx_ref.cek_call thunk Nil
|
||||
with Eval_error msg -> Sx_ref.cek_call handler (String msg))
|
||||
with Eval_error msg -> Sx_ref.cek_call handler (List [String msg]))
|
||||
| [thunk] ->
|
||||
(try let r = Sx_ref.cek_call thunk Nil in
|
||||
List [Symbol "ok"; r]
|
||||
|
||||
@@ -481,7 +481,7 @@ let () =
|
||||
match args with
|
||||
| [thunk; handler] ->
|
||||
(try Sx_ref.cek_call thunk Nil
|
||||
with Eval_error msg -> Sx_ref.cek_call handler (String msg))
|
||||
with Eval_error msg -> Sx_ref.cek_call handler (List [String msg]))
|
||||
| [thunk] ->
|
||||
(try let r = Sx_ref.cek_call thunk Nil in
|
||||
List [Symbol "ok"; r]
|
||||
|
||||
Reference in New Issue
Block a user