test: add stub tests for all scopes

This commit is contained in:
Nurul Huda (Apon) 2026-01-26 15:23:08 +06:00
parent 162c2fc711
commit d804953db0
No known key found for this signature in database
GPG key ID: 5D3F1DE2855A2F79
9 changed files with 825 additions and 18 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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()