✓
Passing This code compiles and runs correctly.
Code
// TEST: Array literal with flow bindings
//
// Koru array literals can reference bindings from the flow scope.
// This is essential for collecting results from multiple events.
//
// Expected: Compiles and runs, array contains bound values
const std = @import("std");
~event getValue { id: i32 } -> i32
~proc getValue|zig {
return id * 10;
}
~event sumAll { values: []const i32 } -> i32
~proc sumAll|zig {
var sum: i32 = 0;
for (values) |v| {
sum += v;
}
return sum;
}
~event check { expected: i32, actual: i32 }
~proc check|zig {
if (expected != actual) {
std.debug.print("FAIL: expected {}, got {}\n", .{ expected, actual });
std.process.exit(1);
}
std.debug.print("PASS: {} == {}\n", .{ expected, actual });
}
// Chain events and collect results in array literal
~getValue(id: 1): a |> getValue(id: 2): b |> getValue(id: 3): c |> sumAll(values: [a, b, c]): t |> check(expected: 60, actual: t)
Actual
PASS: 60 == 60
Must contain:
PASS: 60 == 60Flows
flow ~getValue click a branch to expand · @labels scroll to their anchor
getValue (id: 1)
Test Configuration
MUST_RUN