test: bootstrap tests

This commit is contained in:
Nurul Huda (Apon) 2026-01-23 22:37:44 +06:00
parent 417215a1a5
commit a060dd9ca9
9 changed files with 99 additions and 21 deletions

0
src/Duration.zig Normal file
View file

0
src/Now.zig Normal file
View file

0
src/PlainDate.zig Normal file
View file

0
src/PlainDateTime.zig Normal file
View file

0
src/PlainMonthDay.zig Normal file
View file

0
src/PlainTime.zig Normal file
View file

0
src/PlainYearMonth.zig Normal file
View file

0
src/ZonedDateTime.zig Normal file
View file

View file

@ -1,31 +1,109 @@
const std = @import("std"); pub const Duration = @import("Duration.zig");
pub const Instant = @import("Instant.zig"); pub const Instant = @import("Instant.zig");
pub const Now = @import("Now.zig");
pub const PlainDate = @import("PlainDate.zig");
pub const PlainDateTime = @import("PlainDateTime.zig");
pub const PlainMonthDay = @import("PlainMonthDay.zig");
pub const PlainTime = @import("PlainTime.zig");
pub const PlainYearMonth = @import("PlainYearMonth.zig");
pub const ZonedDateTime = @import("ZonedDateTime.zig");
test "Instant.methods" { const Temporal = @This();
const instant = @import("Instant.zig");
test "Duration.methods" {
if (true) return error.Todo;
const std = @import("std");
const checks = .{ const checks = .{
.{ .name = "add", .expect = true }, // Constructor
.{ .name = "equals", .expect = true }, "init", // Temporal.Duration()
.{ .name = "round", .expect = true }, // Static methods
.{ .name = "since", .expect = true }, "compare",
.{ .name = "subtract", .expect = true }, "from",
.{ .name = "toString", .expect = true },
.{ .name = "toZonedDateTimeIso", .expect = true },
.{ .name = "until", .expect = true },
// Not yet implemented aliases from the Temporal JS API. // Instance methods
.{ .name = "toJSON", .expect = false }, "abs",
.{ .name = "toLocaleString", .expect = false }, "add",
.{ .name = "valueOf", .expect = false }, "negated",
.{ .name = "toZonedDateTimeISO", .expect = false }, // different casing "round",
"subtract",
"toJSON",
"toLocaleString",
"toString",
"total",
"valueOf",
"with",
// Properties
"blank",
"days",
"hours",
"microseconds",
"milliseconds",
"minutes",
"months",
"nanoseconds",
"seconds",
"sign",
"weeks",
"years",
}; };
inline for (checks) |check| { inline for (checks) |check| {
const has = @hasDecl(instant, check.name); const has = @hasDecl(Duration, check);
if (check.expect) if (!has) std.log.err("Missing Duration method: {s}", .{check});
try std.testing.expect(has) try std.testing.expect(has);
else }
try std.testing.expect(!has); }
test "Instant.methods" {
const std = @import("std");
const checks = .{
// Constructor
"init", // Temporal.Instant()
// Instance methods
"add",
"equals",
"round",
"since",
"subtract",
"toString",
"toZonedDateTimeIso", // Temporal.Instant.toZonedDateTimeISO
"until",
// Not yet implemented aliases from the Temporal JS API.
// "toJSON",
// "toLocaleString",
// "valueOf",
};
inline for (checks) |check| {
const has = @hasDecl(Instant, check);
if (!has) std.log.err("Missing Instant method: {s}", .{check});
try std.testing.expect(has);
}
}
test "Temporal.scopes" {
const std = @import("std");
const expected_scopes = .{
"Duration",
"Instant",
"Now",
"PlainDate",
"PlainDateTime",
"PlainMonthDay",
"PlainTime",
"PlainYearMonth",
"ZonedDateTime",
};
inline for (expected_scopes) |scope| {
const has = @hasDecl(Temporal, scope);
if (!has) std.log.err("Missing Temporal scope: {s}", .{scope});
try std.testing.expect(has);
} }
} }