From a060dd9ca9e28aba14f25913ae70c4e02466316c Mon Sep 17 00:00:00 2001 From: "Nurul Huda (Apon)" Date: Fri, 23 Jan 2026 22:37:44 +0600 Subject: [PATCH] test: bootstrap tests --- src/Duration.zig | 0 src/Now.zig | 0 src/PlainDate.zig | 0 src/PlainDateTime.zig | 0 src/PlainMonthDay.zig | 0 src/PlainTime.zig | 0 src/PlainYearMonth.zig | 0 src/ZonedDateTime.zig | 0 src/root.zig | 120 +++++++++++++++++++++++++++++++++-------- 9 files changed, 99 insertions(+), 21 deletions(-) create mode 100644 src/Duration.zig create mode 100644 src/Now.zig create mode 100644 src/PlainDate.zig create mode 100644 src/PlainDateTime.zig create mode 100644 src/PlainMonthDay.zig create mode 100644 src/PlainTime.zig create mode 100644 src/PlainYearMonth.zig create mode 100644 src/ZonedDateTime.zig diff --git a/src/Duration.zig b/src/Duration.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/Now.zig b/src/Now.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/PlainDate.zig b/src/PlainDate.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/PlainDateTime.zig b/src/PlainDateTime.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/PlainMonthDay.zig b/src/PlainMonthDay.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/PlainTime.zig b/src/PlainTime.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/PlainYearMonth.zig b/src/PlainYearMonth.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/ZonedDateTime.zig b/src/ZonedDateTime.zig new file mode 100644 index 0000000..e69de29 diff --git a/src/root.zig b/src/root.zig index 258b70a..377e6f6 100644 --- a/src/root.zig +++ b/src/root.zig @@ -1,31 +1,109 @@ -const std = @import("std"); +pub const Duration = @import("Duration.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 instant = @import("Instant.zig"); +const Temporal = @This(); + +test "Duration.methods" { + if (true) return error.Todo; + const std = @import("std"); const checks = .{ - .{ .name = "add", .expect = true }, - .{ .name = "equals", .expect = true }, - .{ .name = "round", .expect = true }, - .{ .name = "since", .expect = true }, - .{ .name = "subtract", .expect = true }, - .{ .name = "toString", .expect = true }, - .{ .name = "toZonedDateTimeIso", .expect = true }, - .{ .name = "until", .expect = true }, + // Constructor + "init", // Temporal.Duration() + // Static methods + "compare", + "from", - // Not yet implemented aliases from the Temporal JS API. - .{ .name = "toJSON", .expect = false }, - .{ .name = "toLocaleString", .expect = false }, - .{ .name = "valueOf", .expect = false }, - .{ .name = "toZonedDateTimeISO", .expect = false }, // different casing + // Instance methods + "abs", + "add", + "negated", + "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| { - const has = @hasDecl(instant, check.name); - if (check.expect) - try std.testing.expect(has) - else - try std.testing.expect(!has); + const has = @hasDecl(Duration, check); + if (!has) std.log.err("Missing Duration method: {s}", .{check}); + 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); } }