<commit_before>const builtin = @import("builtin");
const TypeId = builtin.TypeId;
const std = @import("std.zig");

/// This function is intended to be used only in tests. It prints diagnostics to stderr
/// and then aborts when actual_error_union is not expected_error.
pub fn expectError(expected_error: anyerror, actual_error_union: var) void {
    if (actual_error_union) |actual_payload| {
        // TODO remove workaround here for https://github.com/ziglang/zig/issues/557
        if (@sizeOf(@typeOf(actual_payload)) == 0) {
            std.debug.panic("expected error.{}, found {} value", .{
                @errorName(expected_error),
                @typeName(@typeOf(actual_payload)),
            });
        } else {
            std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });
        }
    } else |actual_error| {
        if (expected_error != actual_error) {
            std.debug.panic("expected error.{}, found error.{}", .{
                @errorName(expected_error),
                @errorName(actual_error),
            });
        }
    }
}

/// This function is intended to be used only in tests. When the two values are not
/// equal, prints diagnostics to stderr to show exactly how they are not equal,<commit_msg>remove no-longer-needed workaround for var args<commit_after>const builtin = @import("builtin");
const TypeId = builtin.TypeId;
const std = @import("std.zig");

/// This function is intended to be used only in tests. It prints diagnostics to stderr
/// and then aborts when actual_error_union is not expected_error.
pub fn expectError(expected_error: anyerror, actual_error_union: var) void {
    if (actual_error_union) |actual_payload| {
        std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });
    } else |actual_error| {
        if (expected_error != actual_error) {
            std.debug.panic("expected error.{}, found error.{}", .{
                @errorName(expected_error),
                @errorName(actual_error),
            });
        }
    }
}

/// This function is intended to be used only in tests. When the two values are not
/// equal, prints diagnostics to stderr to show exactly how they are not equal,
{'fraction_non_alphanumeric': 0.11962782454585734, 'fraction_numerical': 0.0017722640673460345, 'mean_word_length': 2.814189189189189, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1414528', 'n_tokens_mistral': 629, 'n_tokens_neox': 616, 'n_words': 194}