feature. See also
. The project being documented here (as the example) is the Zig library itself.
source_mapping.testParseAndRemoveLineCommands
fn testParseAndRemoveLineCommands(
expected: []const u8,
comptime expected_spans: []const ExpectedSourceSpan,
source: []const u8,
options: ParseAndRemoveLineCommandsOptions,
) !void
File
Code
fn testParseAndRemoveLineCommands(
expected: []const u8,
comptime expected_spans: []const ExpectedSourceSpan,
source: []const u8,
options: ParseAndRemoveLineCommandsOptions,
) !void {
var results = try parseAndRemoveLineCommandsAlloc(std.testing.allocator, source, options);
defer std.testing.allocator.free(results.result);
defer results.mappings.deinit(std.testing.allocator);
try std.testing.expectEqualStrings(expected, results.result);
expectEqualMappings(expected_spans, results.mappings) catch |err| {
std.debug.print("\nexpected mappings:\n", .{});
for (expected_spans, 0..) |span, i| {
const line_num = i + 1;
std.debug.print("{}: {s}:{}-{}\n", .{ line_num, span.filename, span.start_line, span.end_line });
}
std.debug.print("\nactual mappings:\n", .{});
var i: usize = 1;
while (i <= results.mappings.end_line) : (i += 1) {
const span = results.mappings.getCorrespondingSpan(i).?;
const filename = results.mappings.files.get(span.filename_offset);
std.debug.print("{}: {s}:{}-{}\n", .{ i, filename, span.start_line, span.end_line });
}
std.debug.print("\n", .{});
return err;
};
}