✓
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.contents)
| parsed |> app.lib.io.transform:uppercase(text: s.contents)
| transformed t |> app.lib.io.file:write(path: "output.txt", data: t.result)
| written |> _
| ioerror |> _
| notfound |> _
| ioerror |> _
Imported Files
// File I/O module
const std = @import("std");
~pub event read { path: []const u8 }
| success { contents: []const u8 }
| notfound {}
| ioerror { msg: []const u8 }
~pub event write { path: []const u8, data: []const u8 }
| written {}
| ioerror { msg: []const u8 }
~proc read {
// Stub implementation for test
return .{ .@"notfound" = .{} };
}
~proc write {
// Stub implementation for test
return .{ .@"ioerror" = .{ .msg = "write not implemented" } };
}
// Parse module
const std = @import("std");
~pub event lines { text: []const u8 }
| parsed { lines: [][]const u8 }
~proc lines {
// Stub implementation for test
const empty: [][]const u8 = &.{};
return .{ .@"parsed" = .{ .lines = empty } };
}
// Transform module
const std = @import("std");
~pub event uppercase { text: []const u8 }
| transformed { result: []const u8 }
~proc uppercase {
// Stub implementation for test
return .{ .@"transformed" = .{ .result = "" } };
}
Test Configuration
Expected Behavior:
BACKEND_COMPILE_ERROR