cli: add recoverable endian APIs and qualified std enums

This commit is contained in:
dev committed 2026-10-06 15:12:55 +03:00
1 parent 10a370471b
commit a2ca293506
45 files changed
+1205 -89

No files matched your search

+20
View File
@@ -144,3 +144,23 @@ test "standard source provenance maps diagnostics to the library file" {
try std.testing.expectEqualStrings("std/math.aji", d.span.?.file);
try std.testing.expectEqual(@as(u32, 20), d.span.?.line);
}
test "standard type diagnostics use the public source name" {
var a = std.heap.ArenaAllocator.init(std.testing.allocator);
defer a.deinit();
const arena = a.allocator();
const cases = [_]struct { body: []const u8, found: []const u8 }{
.{ .body = "let value: u16 = std.bytes.read_u16_le(b\"xx\");", .found = "std.bytes.ReadU16" },
.{ .body = "let values = [std.bytes.ReadU16::ok(42); 2]; let value: [u16; 2] = values;", .found = "array<std.bytes.ReadU16, 2>" },
};
for (cases) |case| {
const source = try std.fmt.allocPrint(arena, "module t\nimport std.bytes;\nfn main() -> u8\neffects []\n{{ {s} return 0; }}\n", .{case.body});
const report = try checkFile(arena, "client.aji", source);
try std.testing.expectEqual(Status.rejected, report.status);
try std.testing.expectEqualStrings("E7005", report.diagnostics[0].code.id);
const found = for (report.diagnostics[0].fields) |field| {
if (std.mem.eql(u8, field.name, "found")) break field.value.str;
} else return error.TestUnexpectedResult;
try std.testing.expectEqualStrings(case.found, found);
}
}