mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-09 19:36:45 +00:00
Add proper Zig stdlib attribution
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
|
// The contents of this file is largely based on testing.zig from the Zig 0.15.1
|
||||||
|
// stdlib, distributed under the MIT license, copyright (c) Zig contributors
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
/// Generic, recursive equality testing utility using approximate comparison for
|
/// Generic, recursive equality testing utility using approximate comparison for
|
||||||
/// floats and equality for everything else
|
/// floats and equality for everything else
|
||||||
///
|
///
|
||||||
/// Based on the source code of `std.testing.expectEqual`,
|
/// Based on `std.testing.expectEqual` and `std.testing.expectEqualSlices`.
|
||||||
/// `std.testing.expectEqualSlices`, and `std.meta.eql`, as of Zig 0.15.1.
|
|
||||||
///
|
///
|
||||||
/// The relative tolerance is currently hardcoded to `sqrt(eps(float_type))`.
|
/// The relative tolerance is currently hardcoded to `sqrt(eps(float_type))`.
|
||||||
pub inline fn expectApproxEqual(expected: anytype, actual: anytype) !void {
|
pub inline fn expectApproxEqual(expected: anytype, actual: anytype) !void {
|
||||||
@@ -95,7 +96,7 @@ fn expectApproxEqualInner(comptime T: type, expected: T, actual: T) !void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy of std.testing.print (not public) as of Zig 0.15.1
|
/// Copy of std.testing.print (not public)
|
||||||
fn print(comptime fmt: []const u8, args: anytype) void {
|
fn print(comptime fmt: []const u8, args: anytype) void {
|
||||||
if (@inComptime()) {
|
if (@inComptime()) {
|
||||||
@compileError(std.fmt.comptimePrint(fmt, args));
|
@compileError(std.fmt.comptimePrint(fmt, args));
|
||||||
@@ -104,6 +105,7 @@ fn print(comptime fmt: []const u8, args: anytype) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests based on the `expectEqual` tests in the Zig stdlib
|
||||||
test "expectApproxEqual.union(enum)" {
|
test "expectApproxEqual.union(enum)" {
|
||||||
const T = union(enum) {
|
const T = union(enum) {
|
||||||
a: i32,
|
a: i32,
|
||||||
|
Reference in New Issue
Block a user