diff options
Diffstat (limited to 'vendor/libghostty-vt/src/lib/compat/testing.zig')
| -rw-r--r-- | vendor/libghostty-vt/src/lib/compat/testing.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/lib/compat/testing.zig b/vendor/libghostty-vt/src/lib/compat/testing.zig new file mode 100644 index 00000000..e826eb40 --- /dev/null +++ b/vendor/libghostty-vt/src/lib/compat/testing.zig @@ -0,0 +1,19 @@ +//! Code taken from 0.15.2 `std.testing`. See README.md for license and +//! details. +const builtin = @import("builtin"); +const std = @import("std"); + +/// Given a type, recursively references all the declarations inside, so that the semantic analyzer sees them. +/// For deep types, you may use `@setEvalBranchQuota`. +pub fn refAllDeclsRecursive(comptime T: type) void { + if (!builtin.is_test) return; + inline for (comptime std.meta.declarations(T)) |decl| { + if (@TypeOf(@field(T, decl.name)) == type) { + switch (@typeInfo(@field(T, decl.name))) { + .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(@field(T, decl.name)), + else => {}, + } + } + _ = &@field(T, decl.name); + } +} |
