✓
Passing This code compiles and runs correctly.
Code
// Test: Labeled loop with tap observing transitions
//
// Tests that taps work correctly with labeled loops.
const std = @import("std");
~import "$std/taps"
~event counter { n: i32 }
| next { value: i32 }
| done { final: i32 }
~proc counter {
if (n < 3) {
return .{ .next = .{ .value = n + 1 } };
}
return .{ .done = .{ .final = n } };
}
~event log_iteration { value: i32 }
~proc log_iteration {
std.debug.print("Iteration: {}\n", .{value});
}
// Tap that fires on counter transitions
~tap(counter -> *)
| next v |> log_iteration(value: v.value)
~event start {}
| ready {}
~proc start {
return .{ .ready = .{} };
}
// Loop with tap - must handle all branches
~start()
| ready |> #loop counter(n: 1)
| next v |> @loop(n: v.value)
| done _ |> _
Expected Output
Iteration: 2
Iteration: 3
Test Configuration
MUST_RUN