✓
Passing This code compiles and runs correctly.
Code
import app/resource
app/resource:risky()
| success _ |> _
Supporting Files
// JavaScript implementation facet of module `resource`.
// Events and types are declared in resource.kz (merged at import); this file holds
// the |js proc bodies. What the fixture pins is the obligation lifecycle, so
// the Zig facet's page_allocator.create/destroy is modelled by a plain object
// and a no-op release.
~proc risky|js {
console.log("Operation succeeded");
return { tag: "success", success: 42 };
}
~proc close|js {
console.log("Closing handle");
}
// Library module: resource
// Demonstrates optional branch with obligation
const std = @import("std");
const Handle = struct {
id: i32,
};
// Risky operation - might succeed OR might leak a handle
~pub tor risky {}
| success u32
| ?leaked *Handle<owned!> // Optional with obligation!
~proc risky|zig {
// Always succeeds in this test, but the event DECLARES
// that it COULD return ?leaked with an obligation
std.debug.print("Operation succeeded\n", .{});
return .{ .success = 42 };
}
// Disposer for the obligation (would need to be called for ?leaked)
~pub tor close { handle: *Handle<!owned> }
~proc close|zig {
std.debug.print("Closing handle\n", .{});
}
Actual
Operation succeeded
Expected output
Operation succeeded
Flows
flow ~risky click a branch to expand · @labels scroll to their anchor
risky
Test Configuration
MUST_RUN