test: bootstrap tests
This commit is contained in:
parent
417215a1a5
commit
a060dd9ca9
9 changed files with 99 additions and 21 deletions
0
src/Duration.zig
Normal file
0
src/Duration.zig
Normal file
0
src/Now.zig
Normal file
0
src/Now.zig
Normal file
0
src/PlainDate.zig
Normal file
0
src/PlainDate.zig
Normal file
0
src/PlainDateTime.zig
Normal file
0
src/PlainDateTime.zig
Normal file
0
src/PlainMonthDay.zig
Normal file
0
src/PlainMonthDay.zig
Normal file
0
src/PlainTime.zig
Normal file
0
src/PlainTime.zig
Normal file
0
src/PlainYearMonth.zig
Normal file
0
src/PlainYearMonth.zig
Normal file
0
src/ZonedDateTime.zig
Normal file
0
src/ZonedDateTime.zig
Normal file
120
src/root.zig
120
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue