From 809a09bc8f0acd5ebdfc4f790d4c409b9ff78f04 Mon Sep 17 00:00:00 2001 From: "Nurul Huda (Apon)" Date: Mon, 26 Jan 2026 15:23:08 +0600 Subject: [PATCH] test: add stub tests for all scopes --- src/Duration.zig | 8 +- src/Now.zig | 51 +++++++++++ src/PlainDate.zig | 145 +++++++++++++++++++++++++++++++ src/PlainDateTime.zig | 157 +++++++++++++++++++++++++++++++++ src/PlainMonthDay.zig | 65 ++++++++++++++ src/PlainTime.zig | 103 ++++++++++++++++++++++ src/PlainYearMonth.zig | 108 +++++++++++++++++++++++ src/ZonedDateTime.zig | 192 +++++++++++++++++++++++++++++++++++++++++ src/root.zig | 14 --- 9 files changed, 825 insertions(+), 18 deletions(-) diff --git a/src/Duration.zig b/src/Duration.zig index e97c127..1627090 100644 --- a/src/Duration.zig +++ b/src/Duration.zig @@ -162,15 +162,15 @@ fn compareWithProvider(self: Duration, other: Duration, relative_to: RelativeTo, /// Get the total value of the duration in the specified unit (Temporal.Duration.prototype.total). pub fn total(self: Duration, options: TotalOptions) !f64 { - const relative_to = if (options.relative_to) |rt| rt.toCApi() else abi.c.RelativeTo{ .date = null, .zoned = null }; - const res = abi.c.temporal_rs_Duration_total(self._inner, options.unit.toCApi(), relative_to); + const rel = if (options.relative_to) |r| r.toCApi() else abi.c.RelativeTo{ .date = null, .zoned = null }; + const res = abi.c.temporal_rs_Duration_total(self._inner, options.unit.toCApi(), rel); return abi.success(res) orelse return error.TemporalError; } /// Get the total value of the duration with an explicit provider. fn totalWithProvider(self: Duration, options: TotalOptions, provider: *const abi.c.Provider) !f64 { - const relative_to = if (options.relative_to) |rt| rt.toCApi() else abi.c.RelativeTo{ .date = null, .zoned = null }; - const res = abi.c.temporal_rs_Duration_total_with_provider(self._inner, options.unit.toCApi(), relative_to, provider); + const rel = if (options.relative_to) |r| r.toCApi() else abi.c.RelativeTo{ .date = null, .zoned = null }; + const res = abi.c.temporal_rs_Duration_total_with_provider(self._inner, options.unit.toCApi(), rel, provider); return abi.success(res) orelse return error.TemporalError; } diff --git a/src/Now.zig b/src/Now.zig index e69de29..d3f40d8 100644 --- a/src/Now.zig +++ b/src/Now.zig @@ -0,0 +1,51 @@ +const Now = @This(); +const Instant = @import("Instant.zig"); +const PlainDate = @import("PlainDate.zig"); +const PlainDateTime = @import("PlainDateTime.zig"); +const PlainTime = @import("PlainTime.zig"); +const ZonedDateTime = @import("ZonedDateTime.zig"); + +pub fn instant() error{Todo}!Instant { + return error.Todo; +} + +pub fn plainDateISO() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn plainDateTimeISO() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn plainTimeISO() error{Todo}!PlainTime { + return error.Todo; +} + +pub fn timeZoneId() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn zonedDateTimeISO() error{Todo}!ZonedDateTime { + return error.Todo; +} + +// --- Tests --------------------- +test instant { + if (true) return error.Todo; +} + +test plainDateISO { + if (true) return error.Todo; +} +test plainDateTimeISO { + if (true) return error.Todo; +} +test plainTimeISO { + if (true) return error.Todo; +} +test timeZoneId { + if (true) return error.Todo; +} +test zonedDateTimeISO { + if (true) return error.Todo; +} diff --git a/src/PlainDate.zig b/src/PlainDate.zig index e69de29..7fb3937 100644 --- a/src/PlainDate.zig +++ b/src/PlainDate.zig @@ -0,0 +1,145 @@ +const std = @import("std"); +const PlainDate = @This(); +const PlainDateTime = @import("PlainDateTime.zig"); +const PlainMonthDay = @import("PlainMonthDay.zig"); +const PlainYearMonth = @import("PlainYearMonth.zig"); +const ZonedDateTime = @import("ZonedDateTime.zig"); +const Duration = @import("Duration.zig"); + +pub var calendarId: []const u8 = ""; +pub var day: i64 = 0; +pub var dayOfWeek: i64 = 0; +pub var dayOfYear: i64 = 0; +pub var daysInMonth: i64 = 0; +pub var daysInWeek: i64 = 0; +pub var daysInYear: i64 = 0; +pub var era: []const u8 = ""; +pub var eraYear: i64 = 0; +pub var inLeapYear: bool = false; +pub var month: i64 = 0; +pub var monthCode: []const u8 = ""; +pub var monthsInYear: i64 = 0; +pub var weekOfYear: i64 = 0; +pub var year: i64 = 0; +pub var yearOfWeek: i64 = 0; + +pub fn init() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn compare() error{Todo}!i8 { + return error.Todo; +} + +pub fn from() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn add() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn equals() error{Todo}!bool { + return error.Todo; +} + +pub fn since() error{Todo}!Duration { + return error.Todo; +} + +pub fn subtract() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn toJSON() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toLocaleString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toPlainDateTime() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn toPlainMonthDay() error{Todo}!PlainMonthDay { + return error.Todo; +} + +pub fn toPlainYearMonth() error{Todo}!PlainYearMonth { + return error.Todo; +} + +pub fn toString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toZonedDateTime() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn until() error{Todo}!Duration { + return error.Todo; +} + +pub fn valueOf() error{Todo}!void { + return error.Todo; +} + +pub fn with() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn withCalendar() error{Todo}!PlainDate { + return error.Todo; +} + +test compare { + if (true) return error.Todo; +} +test from { + if (true) return error.Todo; +} +test add { + if (true) return error.Todo; +} +test equals { + if (true) return error.Todo; +} +test since { + if (true) return error.Todo; +} +test subtract { + if (true) return error.Todo; +} +test toJSON { + if (true) return error.Todo; +} +test toLocaleString { + if (true) return error.Todo; +} +test toPlainDateTime { + if (true) return error.Todo; +} +test toPlainMonthDay { + if (true) return error.Todo; +} +test toPlainYearMonth { + if (true) return error.Todo; +} +test toString { + if (true) return error.Todo; +} +test toZonedDateTime { + if (true) return error.Todo; +} +test until { + if (true) return error.Todo; +} +test with { + if (true) return error.Todo; +} +test withCalendar { + if (true) return error.Todo; +} diff --git a/src/PlainDateTime.zig b/src/PlainDateTime.zig index e69de29..8379e33 100644 --- a/src/PlainDateTime.zig +++ b/src/PlainDateTime.zig @@ -0,0 +1,157 @@ +const std = @import("std"); +const PlainDateTime = @This(); +const PlainDate = @import("PlainDate.zig"); +const PlainTime = @import("PlainTime.zig"); +const ZonedDateTime = @import("ZonedDateTime.zig"); +const Duration = @import("Duration.zig"); + +pub var calendarId: []const u8 = ""; +pub var day: i64 = 0; +pub var dayOfWeek: i64 = 0; +pub var dayOfYear: i64 = 0; +pub var daysInMonth: i64 = 0; +pub var daysInWeek: i64 = 0; +pub var daysInYear: i64 = 0; +pub var era: []const u8 = ""; +pub var eraYear: i64 = 0; +pub var hour: i64 = 0; +pub var inLeapYear: bool = false; +pub var microsecond: i64 = 0; +pub var millisecond: i64 = 0; +pub var minute: i64 = 0; +pub var month: i64 = 0; +pub var monthCode: []const u8 = ""; +pub var monthsInYear: i64 = 0; +pub var nanosecond: i64 = 0; +pub var second: i64 = 0; +pub var weekOfYear: i64 = 0; +pub var year: i64 = 0; +pub var yearOfWeek: i64 = 0; + +pub fn init() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn compare() error{Todo}!i8 { + return error.Todo; +} + +pub fn from() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn add() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn equals() error{Todo}!bool { + return error.Todo; +} + +pub fn round() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn since() error{Todo}!Duration { + return error.Todo; +} + +pub fn subtract() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn toJSON() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toLocaleString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toPlainDate() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn toPlainTime() error{Todo}!PlainTime { + return error.Todo; +} + +pub fn toString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toZonedDateTime() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn until() error{Todo}!Duration { + return error.Todo; +} + +pub fn valueOf() error{Todo}!void { + return error.Todo; +} + +pub fn with() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn withCalendar() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn withPlainTime() error{Todo}!PlainDateTime { + return error.Todo; +} + +test compare { + if (true) return error.Todo; +} +test from { + if (true) return error.Todo; +} +test add { + if (true) return error.Todo; +} +test equals { + if (true) return error.Todo; +} +test round { + if (true) return error.Todo; +} +test since { + if (true) return error.Todo; +} +test subtract { + if (true) return error.Todo; +} +test toJSON { + if (true) return error.Todo; +} +test toLocaleString { + if (true) return error.Todo; +} +test toPlainDate { + if (true) return error.Todo; +} +test toPlainTime { + if (true) return error.Todo; +} +test toString { + if (true) return error.Todo; +} +test toZonedDateTime { + if (true) return error.Todo; +} +test until { + if (true) return error.Todo; +} +test with { + if (true) return error.Todo; +} +test withCalendar { + if (true) return error.Todo; +} +test withPlainTime { + if (true) return error.Todo; +} diff --git a/src/PlainMonthDay.zig b/src/PlainMonthDay.zig index e69de29..f9fce12 100644 --- a/src/PlainMonthDay.zig +++ b/src/PlainMonthDay.zig @@ -0,0 +1,65 @@ +const std = @import("std"); +const PlainMonthDay = @This(); +const PlainDate = @import("PlainDate.zig"); + +pub var calendarId: []const u8 = ""; +pub var day: i64 = 0; +pub var monthCode: []const u8 = ""; + +pub fn init() error{Todo}!PlainMonthDay { + return error.Todo; +} + +pub fn from() error{Todo}!PlainMonthDay { + return error.Todo; +} + +pub fn equals() error{Todo}!bool { + return error.Todo; +} + +pub fn toJSON() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toLocaleString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toPlainDate() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn toString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn valueOf() error{Todo}!void { + return error.Todo; +} + +pub fn with() error{Todo}!PlainMonthDay { + return error.Todo; +} + +test from { + if (true) return error.Todo; +} +test equals { + if (true) return error.Todo; +} +test toJSON { + if (true) return error.Todo; +} +test toLocaleString { + if (true) return error.Todo; +} +test toPlainDate { + if (true) return error.Todo; +} +test toString { + if (true) return error.Todo; +} +test with { + if (true) return error.Todo; +} diff --git a/src/PlainTime.zig b/src/PlainTime.zig index e69de29..37f4596 100644 --- a/src/PlainTime.zig +++ b/src/PlainTime.zig @@ -0,0 +1,103 @@ +const std = @import("std"); +const PlainTime = @This(); +const Duration = @import("Duration.zig"); + +pub var hour: i64 = 0; +pub var microsecond: i64 = 0; +pub var millisecond: i64 = 0; +pub var minute: i64 = 0; +pub var nanosecond: i64 = 0; +pub var second: i64 = 0; + +pub fn init() error{Todo}!PlainTime { + return error.Todo; +} + +pub fn compare() error{Todo}!i8 { + return error.Todo; +} + +pub fn from() error{Todo}!PlainTime { + return error.Todo; +} + +pub fn add() error{Todo}!PlainTime { + return error.Todo; +} + +pub fn equals() error{Todo}!bool { + return error.Todo; +} + +pub fn round() error{Todo}!PlainTime { + return error.Todo; +} + +pub fn since() error{Todo}!Duration { + return error.Todo; +} + +pub fn subtract() error{Todo}!PlainTime { + return error.Todo; +} + +pub fn toJSON() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toLocaleString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn until() error{Todo}!Duration { + return error.Todo; +} + +pub fn valueOf() error{Todo}!void { + return error.Todo; +} + +pub fn with() error{Todo}!PlainTime { + return error.Todo; +} + +test compare { + if (true) return error.Todo; +} +test from { + if (true) return error.Todo; +} +test add { + if (true) return error.Todo; +} +test equals { + if (true) return error.Todo; +} +test round { + if (true) return error.Todo; +} +test since { + if (true) return error.Todo; +} +test subtract { + if (true) return error.Todo; +} +test toJSON { + if (true) return error.Todo; +} +test toLocaleString { + if (true) return error.Todo; +} +test toString { + if (true) return error.Todo; +} +test until { + if (true) return error.Todo; +} +test with { + if (true) return error.Todo; +} diff --git a/src/PlainYearMonth.zig b/src/PlainYearMonth.zig index e69de29..f636228 100644 --- a/src/PlainYearMonth.zig +++ b/src/PlainYearMonth.zig @@ -0,0 +1,108 @@ +const std = @import("std"); +const PlainYearMonth = @This(); +const PlainDate = @import("PlainDate.zig"); +const Duration = @import("Duration.zig"); + +pub var calendarId: []const u8 = ""; +pub var daysInMonth: i64 = 0; +pub var daysInYear: i64 = 0; +pub var era: []const u8 = ""; +pub var eraYear: i64 = 0; +pub var inLeapYear: bool = false; +pub var month: i64 = 0; +pub var monthCode: []const u8 = ""; +pub var monthsInYear: i64 = 0; +pub var year: i64 = 0; + +pub fn init() error{Todo}!PlainYearMonth { + return error.Todo; +} + +pub fn compare() error{Todo}!i8 { + return error.Todo; +} + +pub fn from() error{Todo}!PlainYearMonth { + return error.Todo; +} + +pub fn add() error{Todo}!PlainYearMonth { + return error.Todo; +} + +pub fn equals() error{Todo}!bool { + return error.Todo; +} + +pub fn since() error{Todo}!Duration { + return error.Todo; +} + +pub fn subtract() error{Todo}!PlainYearMonth { + return error.Todo; +} + +pub fn toJSON() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toLocaleString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toPlainDate() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn toString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn until() error{Todo}!Duration { + return error.Todo; +} + +pub fn valueOf() error{Todo}!void { + return error.Todo; +} + +pub fn with() error{Todo}!PlainYearMonth { + return error.Todo; +} + +test compare { + if (true) return error.Todo; +} +test from { + if (true) return error.Todo; +} +test add { + if (true) return error.Todo; +} +test equals { + if (true) return error.Todo; +} +test since { + if (true) return error.Todo; +} +test subtract { + if (true) return error.Todo; +} +test toJSON { + if (true) return error.Todo; +} +test toLocaleString { + if (true) return error.Todo; +} +test toPlainDate { + if (true) return error.Todo; +} +test toString { + if (true) return error.Todo; +} +test until { + if (true) return error.Todo; +} +test with { + if (true) return error.Todo; +} diff --git a/src/ZonedDateTime.zig b/src/ZonedDateTime.zig index e69de29..96d3e3a 100644 --- a/src/ZonedDateTime.zig +++ b/src/ZonedDateTime.zig @@ -0,0 +1,192 @@ +const std = @import("std"); +const ZonedDateTime = @This(); +const Instant = @import("Instant.zig"); +const PlainDate = @import("PlainDate.zig"); +const PlainDateTime = @import("PlainDateTime.zig"); +const PlainTime = @import("PlainTime.zig"); +const Duration = @import("Duration.zig"); + +pub var calendarId: []const u8 = ""; +pub var day: i64 = 0; +pub var dayOfWeek: i64 = 0; +pub var dayOfYear: i64 = 0; +pub var daysInMonth: i64 = 0; +pub var daysInWeek: i64 = 0; +pub var daysInYear: i64 = 0; +pub var epochMilliseconds: i64 = 0; +pub var epochNanoseconds: i128 = 0; +pub var era: []const u8 = ""; +pub var eraYear: i64 = 0; +pub var hour: i64 = 0; +pub var hoursInDay: i64 = 0; +pub var inLeapYear: bool = false; +pub var microsecond: i64 = 0; +pub var millisecond: i64 = 0; +pub var minute: i64 = 0; +pub var month: i64 = 0; +pub var monthCode: []const u8 = ""; +pub var monthsInYear: i64 = 0; +pub var nanosecond: i64 = 0; +pub var offset: []const u8 = ""; +pub var offsetNanoseconds: i64 = 0; +pub var second: i64 = 0; +pub var timeZoneId: []const u8 = ""; +pub var weekOfYear: i64 = 0; +pub var year: i64 = 0; +pub var yearOfWeek: i64 = 0; + +pub fn init() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn compare() error{Todo}!i8 { + return error.Todo; +} + +pub fn from() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn add() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn equals() error{Todo}!bool { + return error.Todo; +} + +pub fn getTimeZoneTransition() error{Todo}!?Instant { + return error.Todo; +} + +pub fn round() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn since() error{Todo}!Duration { + return error.Todo; +} + +pub fn startOfDay() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn subtract() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn toInstant() error{Todo}!Instant { + return error.Todo; +} + +pub fn toJSON() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toLocaleString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn toPlainDate() error{Todo}!PlainDate { + return error.Todo; +} + +pub fn toPlainDateTime() error{Todo}!PlainDateTime { + return error.Todo; +} + +pub fn toPlainTime() error{Todo}!PlainTime { + return error.Todo; +} + +pub fn toString() error{Todo}![]const u8 { + return error.Todo; +} + +pub fn until() error{Todo}!Duration { + return error.Todo; +} + +pub fn valueOf() error{Todo}!void { + return error.Todo; +} + +pub fn with() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn withCalendar() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn withPlainTime() error{Todo}!ZonedDateTime { + return error.Todo; +} + +pub fn withTimeZone() error{Todo}!ZonedDateTime { + return error.Todo; +} + +test compare { + if (true) return error.Todo; +} +test from { + if (true) return error.Todo; +} +test add { + if (true) return error.Todo; +} +test equals { + if (true) return error.Todo; +} +test getTimeZoneTransition { + if (true) return error.Todo; +} +test round { + if (true) return error.Todo; +} +test since { + if (true) return error.Todo; +} +test startOfDay { + if (true) return error.Todo; +} +test subtract { + if (true) return error.Todo; +} +test toInstant { + if (true) return error.Todo; +} +test toJSON { + if (true) return error.Todo; +} +test toLocaleString { + if (true) return error.Todo; +} +test toPlainDate { + if (true) return error.Todo; +} +test toPlainDateTime { + if (true) return error.Todo; +} +test toPlainTime { + if (true) return error.Todo; +} +test toString { + if (true) return error.Todo; +} +test until { + if (true) return error.Todo; +} +test with { + if (true) return error.Todo; +} +test withCalendar { + if (true) return error.Todo; +} +test withPlainTime { + if (true) return error.Todo; +} +test withTimeZone { + if (true) return error.Todo; +} diff --git a/src/root.zig b/src/root.zig index 0a5b051..6293f27 100644 --- a/src/root.zig +++ b/src/root.zig @@ -123,8 +123,6 @@ test Instant { } test Now { - if (true) return error.Todo; - const checks = .{ // Static methods "instant", @@ -139,8 +137,6 @@ test Now { } test PlainDate { - if (true) return error.Todo; - const checks = .{ // Constructor "init", // Temporal.PlainDate() @@ -189,8 +185,6 @@ test PlainDate { } test PlainDateTime { - if (true) return error.Todo; - const checks = .{ // Constructor "init", // Temporal.PlainDateTime() @@ -246,8 +240,6 @@ test PlainDateTime { } test PlainMonthDay { - if (true) return error.Todo; - const checks = .{ // Constructor "init", // Temporal.PlainMonthDay() @@ -274,8 +266,6 @@ test PlainMonthDay { } test PlainTime { - if (true) return error.Todo; - const checks = .{ // Constructor "init", // Temporal.PlainTime() @@ -310,8 +300,6 @@ test PlainTime { } test PlainYearMonth { - if (true) return error.Todo; - const checks = .{ // Constructor "init", // Temporal.PlainYearMonth() @@ -350,8 +338,6 @@ test PlainYearMonth { } test ZonedDateTime { - if (true) return error.Todo; - const checks = .{ // Constructor "init", // Temporal.ZonedDateTime()