✓
Passing This code compiles and runs correctly.
Code
// Test 836: Complex multi-module flow with directory imports
//
// Tests realistic HTTP server pattern using multiple modules from same package
// Demonstrates: net/tcp:server.listen() → net/tcp:connection.read() → net/http:request.parse()
const std = @import("std");
~import app/lib/net
// HTTP server flow using multiple modules from 'net' package
~app/lib/net/tcp:server.listen(port: 8080)
| listening l |> app/lib/net/tcp:server.accept(l)
| connection c |> app/lib/net/tcp:connection.read(c)
| data d |> app/lib/net/http:request.parse(d)
| request _ |> app/lib/net/http:response.build(status: 200, body: "OK")
| response resp |> app/lib/net/tcp:connection.write(c, data: resp)
| sent _ |> _
| failed _ |> _
| invalid _ |> app/lib/net/http:response.build(status: 400, body: "Bad Request")
| response resp |> app/lib/net/tcp:connection.write(c, data: resp)
| sent _ |> _
| failed _ |> _
| failed _ |> _
| failed _ |> _
| failed _ |> _
Actual
listening on port 8080
accepted on server 1
read from conn 100
parsed request (14 bytes)
built response status 200
wrote 15 bytes to conn 100
Expected output
listening on port 8080
accepted on server 1
read from conn 100
parsed request (14 bytes)
built response status 200
wrote 15 bytes to conn 100
Imported Files
// HTTP protocol module
const std = @import("std");
~pub event request.parse { bytes: []const u8 }
| request { method: []const u8, path: []const u8 }
| invalid []const u8
~pub event response.build { status: i32, body: []const u8 }
| response []const u8
~proc request.parse|zig {
std.debug.print("parsed request ({} bytes)\n", .{bytes.len});
return .{ .@"request" = .{ .method = "GET", .path = "/" } };
}
~proc response.build|zig {
std.debug.print("built response status {}\n", .{status});
return .{ .@"response" = "HTTP/1.1 200 OK" };
}
// TCP networking module
const std = @import("std");
~pub event server.listen { port: i32 }
| listening i32
| failed []const u8
~pub event server.accept { server_id: i32 }
| connection i32
| failed []const u8
~pub event connection.read { conn_id: i32 }
| data []const u8
| failed []const u8
~pub event connection.write { conn_id: i32, data: []const u8 }
| sent i32
| failed []const u8
~proc server.listen|zig {
std.debug.print("listening on port {}\n", .{port});
return .{ .@"listening" = 1 };
}
~proc server.accept|zig {
std.debug.print("accepted on server {}\n", .{server_id});
return .{ .@"connection" = 100 };
}
~proc connection.read|zig {
std.debug.print("read from conn {}\n", .{conn_id});
return .{ .@"data" = "GET / HTTP/1.1" };
}
~proc connection.write|zig {
std.debug.print("wrote {} bytes to conn {}\n", .{ data.len, conn_id });
return .{ .@"sent" = 100 };
}
Test Configuration
MUST_RUN