✓
Passing This code compiles and runs correctly.
Code
// Test: interpreted `if` end to end through the surface — source with a
// condition and then/else continuations dispatches into the taken branch.
~import std/runtime
~import std/io
const std = @import("std");
~pub tor yes { result: string } -> u64
~proc yes|zig {
std.debug.print("YES: {s}\n", .{result});
return 1;
}
~pub tor no { result: string } -> u64
~proc no|zig {
std.debug.print("NO: {s}\n", .{result});
return 0;
}
~std/runtime:register(scope: "t") {
yes(1)
no(1)
}
const TEST_SOURCE = "if(true)\n| then |> yes(result: \"passed\")\n| else |> no(result: \"failed\")";
~std/runtime:run(source: TEST_SOURCE, scope: "t")
| result _ |> std/io:print.ln("OK")
| exhausted _ |> std/io:print.ln("EXHAUSTED")
| parse-error _ |> std/io:print.ln("PARSE ERROR")
| validation-error _ |> std/io:print.ln("VALIDATION ERROR")
| shape-error _ |> std/io:print.ln("SHAPE ERROR")
| event-denied _ |> std/io:print.ln("EVENT DENIED")
| dispatch-error _ |> std/io:print.ln("DISPATCH ERROR")
| scope-not-found _ |> std/io:print.ln("SCOPE NOT FOUND")
const TEST_SOURCE_ELSE = "if(false)\n| then |> yes(result: \"failed\")\n| else |> no(result: \"passed\")";
~std/runtime:run(source: TEST_SOURCE_ELSE, scope: "t")
| result _ |> std/io:print.ln("OK ELSE")
| exhausted _ |> std/io:print.ln("EXHAUSTED")
| parse-error _ |> std/io:print.ln("PARSE ERROR")
| validation-error _ |> std/io:print.ln("VALIDATION ERROR")
| shape-error _ |> std/io:print.ln("SHAPE ERROR")
| event-denied _ |> std/io:print.ln("EVENT DENIED")
| dispatch-error _ |> std/io:print.ln("DISPATCH ERROR")
| scope-not-found _ |> std/io:print.ln("SCOPE NOT FOUND")
Actual
YES: passed
OK
NO: passed
OK ELSE
Expected output
YES: passed
OK
NO: passed
OK ELSE
Flows
flow ~register click a branch to expand · @labels scroll to their anchor
register (scope: "t", source: yes(1)
no(1))
flow ~run click a branch to expand · @labels scroll to their anchor
run (source: TEST_SOURCE, scope: "t")
flow ~run click a branch to expand · @labels scroll to their anchor
run (source: TEST_SOURCE_ELSE, scope: "t")
Test Configuration
MUST_RUN