✓
Passing This code compiles and runs correctly.
Code
// ============================================================================
// VERIFIED REGRESSION TEST - DO NOT MODIFY WITHOUT DISCUSSION
// ============================================================================
// Test 007: Multiple branches in events
// Tests that events can have multiple branches and procs can return different ones
const std = @import("std");
~event check { value: i32 }
| positive i32
| zero
| negative i32
~proc check|zig {
if (value > 0) return .{ .positive = value };
if (value < 0) return .{ .negative = value };
return .{ .zero = .{} };
}
~event handle-positive { n: i32 }
~proc handle-positive|zig {
std.debug.print("Positive branch works: {}\n", .{n});
}
~event handle-zero {}
~proc handle-zero|zig {
std.debug.print("Zero branch works\n", .{});
}
~event handle-negative { n: i32 }
~proc handle-negative|zig {
std.debug.print("Negative branch works: {}\n", .{n});
}
// Test 1: Positive value (42)
~check(value: 42)
| positive p |> handle-positive(n: p)
| zero |> handle-zero()
| negative n |> handle-negative(n)
// Test 2: Zero value (0)
~check(value: 0)
| positive p |> handle-positive(n: p)
| zero |> handle-zero()
| negative n |> handle-negative(n)
// Test 3: Negative value (-7)
~check(value: -7)
| positive p |> handle-positive(n: p)
| zero |> handle-zero()
| negative n |> handle-negative(n)Actual
Positive branch works: 42
Zero branch works
Negative branch works: -7
Expected output
Positive branch works: 42
Zero branch works
Negative branch works: -7Test Configuration
MUST_RUN