vecmath: Update to zig 0.16.0, harden tests and add test build step

This commit is contained in:
2026-05-12 23:33:33 +02:00
parent 0cce9d9bce
commit 380145a986
27 changed files with 121 additions and 13 deletions

View File

@@ -1,7 +1,19 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
_ = b.addModule("vecmath", .{
const target = b.standardTargetOptions(.{});
const mod = b.addModule("vecmath", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
});
const mod_tests = b.addTest(.{
.root_module = mod,
});
const run_mod_tests = b.addRunArtifact(mod_tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step);
}

View File

@@ -1,7 +1,7 @@
.{
.name = .vecmath,
.version = "0.0.0",
.minimum_zig_version = "0.15.2",
.minimum_zig_version = "0.16.0",
.paths = .{
"src",
"build.zig",

View File

@@ -93,7 +93,11 @@ pub const Color = extern struct {
return @bitCast(self);
}
pub fn format(self: Color, w: *std.io.Writer) !void {
pub fn format(self: Color, w: *std.Io.Writer) !void {
try w.print("#{X:0>2}{X:0>2}{X:0>2}{X:0>2}", .{ self.r, self.g, self.b, self.a });
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -24,7 +24,11 @@ pub const ColorHdr = extern struct {
return @bitCast(self);
}
pub fn format(self: ColorHdr, w: *std.io.Writer) !void {
pub fn format(self: ColorHdr, w: *std.Io.Writer) !void {
try w.print("ColorHdr[{d}, {d}, {d}, {d}]", .{ self.r, self.g, self.b, self.a });
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -252,4 +252,8 @@ pub const Matrix3x2 = extern struct {
.ty = -inv_det * (self.tx * iy + self.ty * jy),
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -406,4 +406,8 @@ pub const Matrix3x2x8 = struct {
.ty = -inv_det * (self.tx * iy + self.ty * jy),
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -507,4 +507,8 @@ pub const Matrix4x4 = extern struct {
// zig fmt: on
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -763,4 +763,8 @@ pub const Matrix4x4x8 = extern struct {
// zig fmt: on
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -110,5 +110,5 @@ pub inline fn unlerpInt64(a: i64, b: i64, x: i64) f32 {
}
test "refAllDecls" {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}

View File

@@ -123,7 +123,11 @@ pub const Complex = extern struct {
};
}
pub fn format(self: Complex, w: *std.io.Writer) !void {
pub fn format(self: Complex, w: *std.Io.Writer) !void {
try w.print("Complex[{d:.3}, {d:.3}]", .{ self.re, self.im });
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -193,4 +193,8 @@ pub const Complex_x8 = struct {
.im = @mulAdd(vm.f32x8, vm.ps(t), b.im, @mulAdd(vm.f32x8, -vm.ps(t), a.im, a.im)),
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -179,7 +179,11 @@ pub const Quaternion = extern struct {
};
}
pub fn format(self: Quaternion, w: *std.io.Writer) !void {
pub fn format(self: Quaternion, w: *std.Io.Writer) !void {
try w.print("Quaternion[{d:.3}, {d:.3}, {d:.3}, {d:.3}]", .{ self.x, self.y, self.z, self.w });
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -278,4 +278,8 @@ pub const Quaternion_x8 = struct {
.w = @mulAdd(vm.f32x8, vm.ps(t), b.w, @mulAdd(vm.f32x8, -vm.ps(t), a.w, a.w)),
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -31,3 +31,7 @@ pub inline fn epi64(value: i64) i64x4 {
pub inline fn epu64(value: u64) u64x4 {
return @splat(value);
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}

View File

@@ -235,3 +235,7 @@ test cossin_x8 {
cossin_x8(.{ -1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75 }),
);
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}

View File

@@ -167,7 +167,11 @@ pub const Vector2 = extern struct {
};
}
pub fn format(self: Vector2, w: *std.io.Writer) !void {
pub fn format(self: Vector2, w: *std.Io.Writer) !void {
try w.print("[{d}, {d}]", .{ self.x, self.y });
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -110,10 +110,14 @@ pub const Vector2Int = extern struct {
return self.x * other.y - self.y * other.x;
}
pub fn format(self: Vector2Int, w: *std.io.Writer) !void {
pub fn format(self: Vector2Int, w: *std.Io.Writer) !void {
try w.print("[{X:0>8}, {X:0>8}]", .{
@as(u32, @bitCast(self.x)),
@as(u32, @bitCast(self.y)),
});
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -171,4 +171,8 @@ pub const Vector2Int_x8 = struct {
pub inline fn cross(self: Vector2Int_x8, other: Vector2Int_x8) vm.i32x8 {
return self.x * other.y - self.y * other.x;
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -231,4 +231,8 @@ pub const Vector2x8 = struct {
.y = self.x * vm.ps(m.iy) + self.y * vm.ps(m.jy),
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -192,7 +192,11 @@ pub const Vector3 = extern struct {
};
}
pub fn format(self: Vector3, w: *std.io.Writer) !void {
pub fn format(self: Vector3, w: *std.Io.Writer) !void {
try w.print("[{d}, {d}, {d}]", .{ self.x, self.y, self.z });
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -117,11 +117,15 @@ pub const Vector3Int = extern struct {
};
}
pub fn format(self: Vector3Int, w: *std.io.Writer) !void {
pub fn format(self: Vector3Int, w: *std.Io.Writer) !void {
try w.print("[{X:0>8}, {X:0>8}, {X:0>8}]", .{
@as(u32, @bitCast(self.x)),
@as(u32, @bitCast(self.y)),
@as(u32, @bitCast(self.z)),
});
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -180,4 +180,8 @@ pub const Vector3Int_x8 = struct {
.z = self.x * other.y - self.y * other.x,
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -258,4 +258,8 @@ pub const Vector3x8 = struct {
.z = v.x * vm.ps(self.iz) + v.y * vm.ps(self.jz) + v.z * vm.ps(self.kz),
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -147,7 +147,11 @@ pub const Vector4 = extern struct {
};
}
pub fn format(self: Vector4, w: *std.io.Writer) !void {
pub fn format(self: Vector4, w: *std.Io.Writer) !void {
try w.print("[{d}, {d}, {d}, {d}]", .{ self.x, self.y, self.z, self.w });
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -112,7 +112,7 @@ pub const Vector4Int = extern struct {
return self.x * other.x + self.y * other.y + self.z * other.z + self.w * other.w;
}
pub fn format(self: Vector4Int, w: *std.io.Writer) !void {
pub fn format(self: Vector4Int, w: *std.Io.Writer) !void {
try w.print("[{X:0>8}, {X:0>8}, {X:0>8}, {X:0>8}]", .{
@as(u32, @bitCast(self.x)),
@as(u32, @bitCast(self.y)),
@@ -120,4 +120,8 @@ pub const Vector4Int = extern struct {
@as(u32, @bitCast(self.w)),
});
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -177,4 +177,8 @@ pub const Vector4Int_x8 = struct {
pub inline fn dot(self: Vector4Int_x8, other: Vector4Int_x8) vm.i32x8 {
return self.x * other.x + self.y * other.y + self.z * other.z + self.w * other.w;
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};

View File

@@ -217,4 +217,8 @@ pub const Vector4x8 = struct {
.w = self.x * vm.ps(m.iw) + self.y * vm.ps(m.jw) + self.z * vm.ps(m.kw) + self.w * vm.ps(m.tw),
};
}
test "refAllDecls" {
std.testing.refAllDecls(@This());
}
};