✓
Passing This code compiles and runs correctly.
Code
// Test: Resource bridge - external handle pool persists handles
~import "$std/runtime"
~import "$std/io"
const std = @import("std");
const HandlePool = @import("root").koru_std.interpreter.HandlePool;
// External pool (simulates bridge)
var test_pool = HandlePool.init(std.heap.page_allocator);
// Events with obligations
~pub event open { path: []const u8 }
| opened []const u8[opened!]
~open = opened "file_1"
~pub event close { handle: []const u8[!opened] }
~proc close {
std.debug.print("close() called\n", .{});
}
~std.runtime:register(scope: "test") {
open(10)
close(1)
}
const TEST_SOURCE = "~open(path: \"test.txt\")\n| opened f |> result { path: \"test.txt\" }";
~std.runtime:run(source: TEST_SOURCE, scope: "test", budget: 100, handle_pool: &test_pool, auto_discharge: false)
| result r |> std.io:print.ln("PASS: external pool has {{ r.handles:d }} handle(s)")
| exhausted _ |> std.io:println(text: "FAIL: exhausted")
| parse_error _ |> std.io:println(text: "FAIL: parse_error")
| validation_error _ |> std.io:println(text: "FAIL: validation_error")
| event_denied _ |> std.io:println(text: "FAIL: event_denied")
| dispatch_error _ |> std.io:println(text: "FAIL: dispatch_error")
| scope_not_found _ |> std.io:println(text: "FAIL: scope_not_found")
Test Configuration
MUST_RUN