✓
Passing This code compiles and runs correctly.
Code
// Test 831: File processor (realistic I/O pattern with directory imports)
//
// Common pattern: read file -> process lines -> transform -> write output
// Tests: directory imports, multiple modules from same package, error handling
const std = @import("std");
// Import directory 'lib/io' containing:
// - file.kz (read, write events)
// - parse.kz (lines event)
// - transform.kz (uppercase event)
~import app/lib/io
// The full pipeline using directory imports
~app/lib/io/file:read(path: "input.txt")
| success s |> app/lib/io/parse:lines(text: s)
| parsed _ |> app/lib/io/transform:uppercase(text: s)
| transformed t |> app/lib/io/file:write(path: "output.txt", data: t)
| written _ |> _
| ioerror _ |> _
| notfound _ |> _
| ioerror _ |> _
Actual
read input.txt
parse lines (11 chars)
uppercase (11 chars)
write output.txt (11 bytes)
Expected output
read input.txt
parse lines (11 chars)
uppercase (11 chars)
write output.txt (11 bytes)
Imported Files
// File I/O module
const std = @import("std");
~pub event read { path: []const u8 }
| success []const u8
| notfound []const u8
| ioerror []const u8
~pub event write { path: []const u8, data: []const u8 }
| written i32
| ioerror []const u8
~proc read|zig {
std.debug.print("read {s}\n", .{path});
return .{ .@"success" = "hello world" };
}
~proc write|zig {
std.debug.print("write {s} ({} bytes)\n", .{ path, data.len });
return .{ .@"written" = @intCast(data.len) };
}
// Parse module
const std = @import("std");
~pub event lines { text: []const u8 }
| parsed [][]const u8
~proc lines|zig {
std.debug.print("parse lines ({} chars)\n", .{text.len});
const empty: [][]const u8 = &.{};
return .{ .@"parsed" = empty };
}
// Transform module
const std = @import("std");
~pub event uppercase { text: []const u8 }
| transformed []const u8
~proc uppercase|zig {
std.debug.print("uppercase ({} chars)\n", .{text.len});
return .{ .@"transformed" = "HELLO WORLD" };
}
Test Configuration
MUST_RUN